diff options
author | Haru <haru@dotalux.com> | 2016-01-25 16:52:27 +0100 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2016-01-25 17:10:00 +0100 |
commit | e3253b4ccc3e78ce482b54c920c6856109575aa6 (patch) | |
tree | e6cf272f01dacc106f19118adaa06f8c7bbfe04c | |
parent | b77735473db348a65b749a79549852713f142dc1 (diff) | |
download | hercules-e3253b4ccc3e78ce482b54c920c6856109575aa6.tar.gz hercules-e3253b4ccc3e78ce482b54c920c6856109575aa6.tar.bz2 hercules-e3253b4ccc3e78ce482b54c920c6856109575aa6.tar.xz hercules-e3253b4ccc3e78ce482b54c920c6856109575aa6.zip |
Added source support for special comments in the constdb
- To be used by the constdb2doc plugin
Signed-off-by: Haru <haru@dotalux.com>
-rw-r--r-- | db/constants.conf | 87 | ||||
-rw-r--r-- | src/map/script.c | 40 | ||||
-rw-r--r-- | src/map/script.h | 1 |
3 files changed, 76 insertions, 52 deletions
diff --git a/db/constants.conf b/db/constants.conf index 98de6ac98..5440c521e 100644 --- a/db/constants.conf +++ b/db/constants.conf @@ -43,7 +43,7 @@ constants_db: { // implementation values assigned by scripts to parameters will affect // runtime values, such as Zeny, as well (see pc_readparam/pc_setparam). - /** Weekdays */ + comment__: "Weekdays" SUNDAY: 0 MONDAY: 1 TUESDAY: 2 @@ -52,7 +52,7 @@ constants_db: { FRIDAY: 5 SATURDAY: 6 - /** Months */ + comment__: "Months" JANUARY: 1 FEBRUARY: 2 MARCH: 3 @@ -66,7 +66,7 @@ constants_db: { NOVEMBER: 11 DECEMBER: 12 - /** Job IDs */ + comment__: "Job IDs" Job_Novice: 0 Job_Swordman: 1 Job_Mage: 2 @@ -225,7 +225,7 @@ constants_db: { Job_Oboro: 4212 Job_Rebellion: 4215 - /** Job masks / Job map_ids */ + comment__: "Job masks / Job map_ids" EAJL_2_1: 0x0100 EAJL_2_2: 0x0200 EAJL_2: 0x0300 @@ -359,8 +359,7 @@ constants_db: { EAJ_BABY_GENETIC: 0x6205 EAJ_BABY_CHASER: 0x6206 - - /** Broadcast flags */ + comment__: "Broadcast flags" bc_all: 0 bc_map: 1 bc_area: 2 @@ -371,7 +370,7 @@ constants_db: { bc_blue: 16 bc_woe: 32 - /** Mapflags */ + comment__: "Mapflags" mf_nomemo: 0 mf_noteleport: 1 mf_nosave: 2 @@ -426,7 +425,7 @@ constants_db: { mf_nocashshop: 54 mf_noviewid: 55 - /** Cell Properties */ + comment__: "Cell Properties" cell_walkable: 0 cell_shootable: 1 cell_water: 2 @@ -436,7 +435,7 @@ constants_db: { cell_novending: 6 cell_nochat: 7 - /** Cell checks */ + comment__: "Cell checks" //cell_gettype: 0 cell_chkwall: 1 cell_chkwater: 2 @@ -452,7 +451,7 @@ constants_db: { cell_chknovending: 12 cell_chknochat: 13 - /** Parameters */ + comment__: "Parameters" BaseExp: { Value: 1 Parameter: true @@ -570,7 +569,7 @@ constants_db: { Parameter: true } - /** Bonuses / Parameter IDs */ + comment__: "Bonuses / Parameter IDs" bMaxHP: 6 bMaxSP: 8 bStr: 13 @@ -752,10 +751,8 @@ constants_db: { bAddRaceTolerance: 2061 bAddMaxWeight: 2062 - /** - * Equip index - * reference to script.c::script_defaults():equip[] array used for easy-conversion - */ + comment__: "Equip index" + /* reference to script.c::script_defaults():equip[] array used for easy-conversion */ EQI_HEAD_TOP: 1 EQI_ARMOR: 2 EQI_HAND_L: 3 @@ -777,7 +774,7 @@ constants_db: { EQI_SHADOW_ACC_R: 19 EQI_SHADOW_ACC_L: 20 - /** Status effects */ + comment__: "Status effects" Eff_Stone: 0 Eff_Freeze: 1 Eff_Stun: 2 @@ -794,7 +791,7 @@ constants_db: { Eff_Burning: 13 Eff_Deepsleep: 14 - /** Elements */ + comment__: "Elements" Ele_Neutral: 0 Ele_Water: 1 Ele_Earth: 2 @@ -807,7 +804,7 @@ constants_db: { Ele_Undead: 9 Ele_All: 255 - /** Races */ + comment__: "Races" RC_Formless: 0 RC_Undead: 1 RC_Brute: 2 @@ -827,7 +824,7 @@ constants_db: { RC_NonDemiPlayer: 17 RC_All: 255 - /** Subraces */ + comment__: "Subraces" RC2_None: 0 RC2_Goblin: 1 RC2_Kobold: 2 @@ -838,12 +835,12 @@ constants_db: { RC2_Scaraba: 7 RC2_Turtle: 8 - /** Sizes */ + comment__: "Sizes" Size_Small: 0 Size_Medium: 1 Size_Large: 2 - /** Battle Flags */ + comment__: "Battle Flags" BF_WEAPON: 0x0001 BF_MAGIC: 0x0002 BF_MISC: 0x0004 @@ -852,7 +849,7 @@ constants_db: { BF_SKILL: 0x0100 BF_NORMAL: 0x0200 - /** Attack Flags */ + comment__: "Attack Flags" ATF_SELF: 0x01 ATF_TARGET: 0x02 ATF_SHORT: 0x04 @@ -862,7 +859,7 @@ constants_db: { ATF_MISC: 0x40 ATF_SKILL: 0x60 - /** Status Changes */ + comment__: "Status Changes" SC_ALL: -1 SC_STONE: 0 SC_FREEZE: 1 @@ -1501,7 +1498,7 @@ constants_db: { SC_G_LIFEPOTION: 640 SC_MYSTICPOWDER: 641 - /** Emotes */ + comment__: "Emotes" e_gasp: 0 e_what: 1 e_ho: 2 @@ -1584,14 +1581,14 @@ constants_db: { e_panic: 79 e_whisp: 80 - /** petstat */ + comment__: "petstat" PET_CLASS: 1 PET_NAME: 2 PET_LEVEL: 3 PET_HUNGRY: 4 PET_INTIMATE: 5 - /** getmonsterinfo */ + comment__: "getmonsterinfo" MOB_NAME: 0 MOB_LV: 1 MOB_MAXHP: 2 @@ -1616,12 +1613,12 @@ constants_db: { MOB_MODE: 21 MOB_MVPEXP: 22 - /** mercenary guilds */ + comment__: "mercenary guilds" ARCH_MERC_GUILD: 0 SPEAR_MERC_GUILD: 1 SWORD_MERC_GUILD: 2 - /** Effects */ + comment__: "Effects" EF_NONE: -1 EF_HIT1: 0 EF_HIT2: 1 @@ -2722,7 +2719,7 @@ constants_db: { EF_SPRITEMABLE: 1096 EF_TUNAPARTY: 1097 - /** NPC sprite IDs */ + comment__: "NPC sprite IDs" FAKE_NPC: -1 WARPNPC: 45 1_ETC_01: 46 @@ -3586,7 +3583,7 @@ constants_db: { 4_GIBBET: 10177 4_DULLAHAN: 10178 - /** Mercenary IDs */ + comment__: "Mercenary IDs" MER_LIF: 6001 MER_AMISTR: 6002 MER_FILIR: 6003 @@ -3634,12 +3631,12 @@ constants_db: { MER_SWORDMAN09: 6045 MER_SWORDMAN10: 6046 - /** checkquest */ + comment__: "checkquest" HAVEQUEST: 0 PLAYTIME: 1 HUNTING: 2 - /** questinfo */ + comment__: "questinfo" QTYPE_NONE: 0x270f QTYPE_QUEST: 0x00 QTYPE_QUEST2: 0x01 @@ -3650,7 +3647,7 @@ constants_db: { QTYPE_WARG: 0x06 QTYPE_WARG2: 0x08 - /** Font weight */ + comment__: "Font weight" FW_DONTCARE: 0 FW_THIN: 100 FW_EXTRALIGHT: 200 @@ -3662,7 +3659,7 @@ constants_db: { FW_EXTRABOLD: 800 FW_HEAVY: 900 - /** old setlook (use LOOK_* constants instead) */ + comment__: "old setlook (use LOOK_* constants instead)" VAR_HEAD: { Value: 1 Deprecated: true // Use LOOK_HAIR @@ -3700,7 +3697,7 @@ constants_db: { Deprecated: true // Use LOOK_SHOES } - /** Directions */ + comment__: "Directions" DIR_NORTH: 0 DIR_NORTHWEST: 1 DIR_WEST: 2 @@ -3710,7 +3707,7 @@ constants_db: { DIR_EAST: 6 DIR_NORTHEAST: 7 - /** Item types */ + comment__: "Item types" IT_HEALING: 0 IT_USABLE: 2 IT_ETC: 3 @@ -3723,30 +3720,30 @@ constants_db: { IT_DELAYCONSUME: 11 IT_CASH: 18 - /** queueopt */ + comment__: "queueopt" QUEUEOPT_LOGOUT: 1 QUEUEOPT_DEATH: 2 QUEUEOPT_MAPCHANGE: 3 - /** Instance owner type */ + comment__: "Instance owner type" IOT_NONE: 0 IOT_CHAR: 1 IOT_PARTY: 2 IOT_GUILD: 3 - /** tradertype */ + comment__: "tradertype" NST_ZENY: 0 NST_CASH: 1 NST_MARKET: 2 NST_CUSTOM: 3 - /** strcharinfo */ + comment__: "strcharinfo" PC_NAME: 0 PC_PARTY: 1 PC_GUILD: 2 PC_MAP: 3 - /** sc_start */ + comment__: "sc_start" SCFLAG_NONE: 0x00 SCFLAG_NOAVOID: 0x01 SCFLAG_FIXEDTICK: 0x02 @@ -3754,7 +3751,7 @@ constants_db: { SCFLAG_FIXEDRATE: 0x08 SCFLAG_NOICON: 0x10 - /** Mount types */ + comment__: "Mount types" MOUNT_NONE: 0 MOUNT_PECO: 1 MOUNT_WUG: 2 @@ -3766,7 +3763,7 @@ constants_db: { MOUNT_DRAGON_BLUE: 7 MOUNT_DRAGON_RED: 8 - /** gettime */ + comment__: "gettime" GETTIME_SECOND: 1 GETTIME_MINUTE: 2 GETTIME_HOUR: 3 @@ -3776,7 +3773,7 @@ constants_db: { GETTIME_YEAR: 7 GETTIME_DAYOFYEAR: 8 - /** unit types */ + comment__: "unit types" UNITTYPE_PC: 0 UNITTYPE_NPC: 1 UNITTYPE_PET: 2 @@ -3785,7 +3782,7 @@ constants_db: { UNITTYPE_MER: 5 UNITTYPE_ELEM: 6 - /** Colors */ + comment__: "Colors" C_AQUA: 0x00FFFF C_BLACK: 0x000000 C_BLUE: 0x0000FF diff --git a/src/map/script.c b/src/map/script.c index 5a3d1507f..ca53b6f6d 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -2322,6 +2322,15 @@ void read_constdb(void) ShowWarning("read_constdb: Invalid constant name %s. Skipping.\n", name); continue; } + if (strcmp(name, "comment__") == 0) { + const char *comment = libconfig->setting_get_string(t); + if (comment == NULL) + continue; + if (*comment == '\0') + comment = NULL; + script->constdb_comment(comment); + continue; + } if (config_setting_is_aggregate(t)) { int i32; if (!libconfig->setting_lookup_int(t, "Value", &i32)) { @@ -2342,9 +2351,22 @@ void read_constdb(void) } script->set_constant(name, value, is_parameter, is_deprecated); } + script->constdb_comment(NULL); libconfig->destroy(&constants_conf); } +/** + * Sets the current constdb comment. + * + * This function does nothing (used by plugins only) + * + * @param comment The comment to set (NULL to unset) + */ +void script_constdb_comment(const char *comment) +{ + (void)comment; +} + // Standard UNIX tab size is 8 #define TAB_SIZE 8 #define update_tabstop(tabstop,chars) \ @@ -20820,9 +20842,11 @@ void script_label_add(int key, int pos) { **/ void script_hardcoded_constants(void) { + script->constdb_comment("Boolean"); script->set_constant("true", 1, false, false); script->set_constant("false", 0, false, false); - /* server defines */ + + script->constdb_comment("Server defines"); script->set_constant("PACKETVER",PACKETVER,false, false); script->set_constant("MAX_LEVEL",MAX_LEVEL,false, false); script->set_constant("MAX_STORAGE",MAX_STORAGE,false, false); @@ -20834,7 +20858,7 @@ void script_hardcoded_constants(void) script->set_constant("MAX_CHAT_USERS",MAX_CHAT_USERS,false, false); script->set_constant("MAX_REFINE",MAX_REFINE,false, false); - /* status options */ + script->constdb_comment("status options"); script->set_constant("Option_Nothing",OPTION_NOTHING,false, false); script->set_constant("Option_Sight",OPTION_SIGHT,false, false); script->set_constant("Option_Hide",OPTION_HIDE,false, false); @@ -20860,11 +20884,11 @@ void script_hardcoded_constants(void) script->set_constant("Option_Hanbok",OPTION_HANBOK,false, false); script->set_constant("Option_Oktoberfest",OPTION_OKTOBERFEST,false, false); - /* status option compounds */ + script->constdb_comment("status option compounds"); script->set_constant("Option_Dragon",OPTION_DRAGON,false, false); script->set_constant("Option_Costume",OPTION_COSTUME,false, false); - /* send_target */ + script->constdb_comment("send_target"); script->set_constant("ALL_CLIENT",ALL_CLIENT,false, false); script->set_constant("ALL_SAMEMAP",ALL_SAMEMAP,false, false); script->set_constant("AREA",AREA,false, false); @@ -20898,7 +20922,7 @@ void script_hardcoded_constants(void) script->set_constant("BG_AREA_WOS",BG_AREA_WOS,false, false); script->set_constant("BG_QUEUE",BG_QUEUE,false, false); - /* LOOK_ constants, use in setlook/changelook script commands */ + script->constdb_comment("LOOK_ constants, use in setlook/changelook script commands"); script->set_constant("LOOK_BASE", LOOK_BASE, false, false); script->set_constant("LOOK_HAIR", LOOK_HAIR, false, false); script->set_constant("LOOK_WEAPON", LOOK_WEAPON, false, false); @@ -20914,7 +20938,7 @@ void script_hardcoded_constants(void) script->set_constant("LOOK_ROBE", LOOK_ROBE, false, false); script->set_constant("LOOK_BODY2", LOOK_BODY2, false, false); - /* Equip Position in Bits, use with *getiteminfo type 5, or @inventorylist_equip */ + script->constdb_comment("Equip Position in Bits, use with *getiteminfo type 5, or @inventorylist_equip"); script->set_constant("EQP_HEAD_LOW", EQP_HEAD_LOW, false, false); script->set_constant("EQP_HEAD_MID", EQP_HEAD_MID, false, false); script->set_constant("EQP_HEAD_TOP", EQP_HEAD_TOP, false, false); @@ -20937,7 +20961,7 @@ void script_hardcoded_constants(void) script->set_constant("EQP_SHADOW_ACC_R", EQP_SHADOW_ACC_R, false, false); script->set_constant("EQP_SHADOW_ACC_L", EQP_SHADOW_ACC_L, false, false); - /* Renewal */ + script->constdb_comment("Renewal"); #ifdef RENEWAL script->set_constant("RENEWAL", 1, false, false); #else @@ -20973,6 +20997,7 @@ void script_hardcoded_constants(void) #else script->set_constant("RENEWAL_ASPD", 0, false, false); #endif + script->constdb_comment(NULL); } /** @@ -21150,6 +21175,7 @@ void script_defaults(void) { script->parse_expr = parse_expr; script->parse_line = parse_line; script->read_constdb = read_constdb; + script->constdb_comment = script_constdb_comment; script->print_line = script_print_line; script->errorwarning_sub = script_errorwarning_sub; script->set_reg = set_reg; diff --git a/src/map/script.h b/src/map/script.h index dbb0f8a03..e6164092e 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -726,6 +726,7 @@ struct script_interface { const char* (*parse_expr) (const char *p); const char* (*parse_line) (const char *p); void (*read_constdb) (void); + void (*constdb_comment) (const char *comment); const char* (*print_line) (StringBuf *buf, const char *p, const char *mark, int line); void (*errorwarning_sub) (StringBuf *buf, const char *src, const char *file, int start_line, const char *error_msg, const char *error_pos); int (*set_reg) (struct script_state *st, struct map_session_data *sd, int64 num, const char *name, const void *value, struct reg_db *ref); |