浏览代码

Further changes and reorganize in the access level rewrite (requires [L2110]):
* Fields being renamed after the camelCase naming convention.
* Field types slightly altered to better contain their data.
* Adding documentation for the access level system as comments in the .sql files.
* Adding some general SQL documentation.
(tnx nbd^)

DrLecter 17 年之前
父节点
当前提交
153ff8f9b4

+ 66 - 21
datapack_development/sql/access_levels.sql

@@ -1,28 +1,73 @@
+-- How to configure the SQL based access level system :
+-- 
+-- There are two tables.
+-- 
+-- First one is named acess_levels and it's meant to define the different possible
+-- groups a GM can belong to.
+-- 
+-- You can see in this table six predefined GM groups. Each group has a different 
+-- accessLevel, and GM's access_level in the characters table should match with 
+-- one of these. You could define as many groups as needed and give them whatever
+-- number you wanted to, from 1 to 255. Nevertheless please note the fact that 
+-- there is one group that will be reserved for allmighty administrators, and this
+-- group is bound to the following rules:
+-- 
+--    * There's no need/way to restrict the commands this group is able to run, its
+--      members will be able to perform ANY admin_command.
+--
+--    * One number must be reserved for this group, and by default it is set to 127.
+--
+--    * In order to change this default group number or its name/title colors,
+--      you should look at the Character.properties configuration file and
+--      change the value of MasterAccessLevel, MasterNameColor and MasterTitleColor
+--      respectively.
+--
+--    * You should better not use this group as a part of any childs hierarchy.
+-- 
+-- In our predefined set of examples, access_level=1 is for the highest admin,
+-- and access_level=3 is for Event GMs.
+-- 
+-- The rest of the access_levels table columns are expected to be self explanatory.
+-- 
+-- And there is a second table named admin_command_access_rights and in this table
+-- administrators should add every command they wanted GMs to use.
+-- 
+-- We left just one query here to show how commands should be added to the table:
+-- 
+-- INSERT IGNORE INTO `admin_command_access_rights` VALUES ('admin_admin','6');
+-- 
+-- If an administrator wanted to grant his GMs from group 4 the usage of the //para
+-- command, he should just copy our example and replace values like this:
+-- 
+-- INSERT IGNORE INTO `admin_command_access_rights` VALUES ('admin_para','4');
+-- 
+-- So on, for each command there should be a record in this table. And it would be 
+-- advisable to use one query per command to avoid messups ;)
+
 -- ---------------------------------
 -- Table structure for access_levels
 -- ---------------------------------
 CREATE TABLE IF NOT EXISTS `access_levels` (
-  `access_level` mediumint(9) NOT NULL,
-  `name` varchar(255) NOT NULL default '',
-  `name_color` varchar(6) NOT NULL default 'FFFFFF',
-  `title_color` varchar(6) NOT NULL default 'FFFFFF',
-  `child_access` varchar(255) NOT NULL default '',
-  `is_gm` tinyint(1) NOT NULL default 0,
-  `allow_peace_attack` tinyint(1) NOT NULL default 0,
-  `allow_fixed_res` tinyint(1) NOT NULL default 0,
-  `allow_transaction` tinyint(1) NOT NULL default 0,
-  `allow_altg` tinyint(1) NOT NULL default 0,
-  `give_damage` tinyint(1) NOT NULL default 0,
-  `take_aggro` tinyint(1) NOT NULL default 0,
-  `gain_exp` tinyint(1) NOT NULL default 0,
-  PRIMARY KEY  (`access_level`)
+  `accessLevel` MEDIUMINT(9) NOT NULL,
+  `name` VARCHAR(255) NOT NULL DEFAULT '',
+  `nameColor` CHAR(6) NOT NULL DEFAULT 'FFFFFF',
+  `titleColor` CHAR(6) NOT NULL DEFAULT 'FFFFFF',
+  `childAccess` VARCHAR(255) NOT NULL DEFAULT '',
+  `isGm` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
+  `allowPeaceAttack` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
+  `allowFixedRes` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
+  `allowTransaction` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
+  `allowAltg` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
+  `giveDamage` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
+  `takeAggro` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
+  `gainExp` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
+  PRIMARY KEY  (`accessLevel`)
 ) ;
 
 INSERT IGNORE INTO `access_levels` VALUES 
-(1,'Admin','0FF000','FFFFFF','2;3;4;5;6',1,1,1,1,1,1,1,1),
-(2,'Head GM','0C0000','FFFFFF','5;6',0,0,1,1,1,1,1,1),
-(3,'Event GM','00C000','FFFFFF','5;6',0,0,1,0,1,0,0,0),
-(4,'Support GM','000C00','FFFFFF','5;6',0,0,1,0,1,0,0,0),
-(5,'General GM','0000C0','FFFFFF','6',0,0,1,0,1,0,0,0),
-(6,'Test GM','FFFFFF','FFFFFF','','0',0,1,0,1,0,0,0);
-
+(1,'Admin','0FF000','0FF000','2;3;4;5;6',1,1,1,1,1,1,1,1),
+(2,'Head GM','0C0000','0C0000','5;6',0,0,1,1,1,1,1,1),    
+(3,'Event GM','00C000','00C000','5;6',0,0,1,0,1,0,0,0),   
+(4,'Support GM','000C00','000C00','5;6',0,0,1,0,1,0,0,0), 
+(5,'General GM','0000C0','0000C0','6',0,0,1,0,1,0,0,0),   
+(6,'Test GM','FFFFFF','FFFFFF','','0',0,1,0,1,0,0,0);

+ 7 - 3
datapack_development/sql/admin_command_access_rights.sql

@@ -1,10 +1,14 @@
+-- 
+-- For further information on the usage of this table, please refer to the 
+-- documentation comments in the access_levels.sql file
+-- 
 -- -----------------------------------------------
 -- Table structure for admin_command_access_rights
 -- -----------------------------------------------
 CREATE TABLE IF NOT EXISTS `admin_command_access_rights` (
-  `admin_command` varchar(255) NOT NULL default 'admin_',
-  `access_levels` varchar(255) NOT NULL,
-  PRIMARY KEY  (`admin_command`)
+  `adminCommand` varchar(255) NOT NULL default 'admin_',
+  `accessLevels` varchar(255) NOT NULL,
+  PRIMARY KEY  (`adminCommand`)
 ) ;
 
 INSERT IGNORE INTO `admin_command_access_rights` VALUES 

+ 17 - 0
datapack_development/sql/documentation.txt

@@ -0,0 +1,17 @@
+This directory contains table definitions and data dumps you need to import into your L2J database in order to run a vanilla  L2J server. Additionally, there are directories whose content serve different purposes. You should read documentation.txt files included inside these directories for further explanation about them.
+
+In general, and unless otherwise stated by specific conventions or guidelines the following tips should be considered:
+
+- File names should be made by using underscore_separation, instead of camelCase.
+
+- Field names should be made by using camelCase, instead of underscore_separation. This is not (totally) arbitrary, but trying to keep an acceptable balance between name length, readability, and intuitive model perception.
+
+- Field types should be defined according to the actual domain they're meant to describe. Said in other words, we shouldn't have atrocities such as INTEGER(14) for 'level' just because somebody was too lazy to check column ranges in a manual and preferred to be on the safe side by guessing ;)
+
+- Further, when specifying a numeric type, INTEGER or its variations should be chosen instead of DECIMAL(M,0).
+
+- Since L2J supports MySQL as its one and only data management backend, we should not hesitate to introduce any standards extension or column type MySQL provides as a non-portable feature. This statement applies particularly when we could obtain any gain either from a readability, code maintenance or system performance perspective.
+
+- During data dump queries, no quotes should be used for numeric values and spaces after field separation commas should be ommited. This is in order to reduce file sizes.
+
+- Comments should be used at the developers discretion, to either serve as separators between structure and data, description of the ingame meaning of an statement or any other form of documentation intended to help administrators to understand the way they should use a table, or how could it be customized.

+ 15 - 0
datapack_development/sql/updates/20080517update.sql

@@ -0,0 +1,15 @@
+ALTER TABLE `access_levels` CHANGE `access_level` `accessLevel` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0;
+ALTER TABLE `access_levels` CHANGE `name_color` `nameColor` CHAR(6);
+ALTER TABLE `access_levels` CHANGE `title_color` `titleColor` CHAR(6);
+ALTER TABLE `access_levels` CHANGE `child_access` `childAccess` VARCHAR(255);
+ALTER TABLE `access_levels` CHANGE `is_gm` `isGm` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0;
+ALTER TABLE `access_levels` CHANGE `allow_peace_attack` `allowPeaceAttack` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0;
+ALTER TABLE `access_levels` CHANGE `allow_fixed_res` `allowFixedRes` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0;
+ALTER TABLE `access_levels` CHANGE `allow_transaction` `allowTransaction` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0;
+ALTER TABLE `access_levels` CHANGE `allow_altg` `allowAltg` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0;
+ALTER TABLE `access_levels` CHANGE `give_damage` `giveDamage` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0;
+ALTER TABLE `access_levels` CHANGE `take_aggro` `takeAggro` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0;
+ALTER TABLE `access_levels` CHANGE `gain_exp` `gainExp` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0;
+
+ALTER TABLE `admin_command_access_rights` CHANGE `admin_command` `adminCommand` VARCHAR(255);
+ALTER TABLE `admin_command_access_rights` CHANGE `access_levels` `accessLevels` VARCHAR(255);