summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2016-01-25 16:52:27 +0100
committerHaru <haru@dotalux.com>2016-01-25 17:10:00 +0100
commite3253b4ccc3e78ce482b54c920c6856109575aa6 (patch)
treee6cf272f01dacc106f19118adaa06f8c7bbfe04c /src
parentb77735473db348a65b749a79549852713f142dc1 (diff)
downloadhercules-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>
Diffstat (limited to 'src')
-rw-r--r--src/map/script.c40
-rw-r--r--src/map/script.h1
2 files changed, 34 insertions, 7 deletions
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);