From 1b73ceaad27dcd2226bc73c10e305e93609a084e Mon Sep 17 00:00:00 2001 From: gumi Date: Fri, 13 Jul 2018 12:49:52 -0400 Subject: reload the const db on script reload --- src/map/script.c | 26 ++++++++++++------------- src/map/script.h | 2 +- src/plugins/HPMHooking/HPMHooking.Defs.inc | 4 ++-- src/plugins/HPMHooking/HPMHooking_map.Hooks.inc | 12 ++++++------ 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/src/map/script.c b/src/map/script.c index 9adf6b44d..abaeaea2d 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -2258,7 +2258,7 @@ static void script_set_constant(const char *name, int value, bool is_parameter, { int n = script->add_str(name); - if( script->str_data[n].type == C_NOP ) {// new + if (script->str_data[n].type == C_NOP) { script->str_data[n].type = is_parameter ? C_PARAM : C_INT; script->str_data[n].val = value; script->str_data[n].deprecated = is_deprecated ? 1 : 0; @@ -2302,7 +2302,7 @@ static void script_set_constant2(const char *name, int value, bool is_parameter, /** * Loads the constants database from constants.conf */ -static void read_constdb(void) +static void read_constdb(bool reload) { struct config_t constants_conf; char filepath[256]; @@ -2321,7 +2321,6 @@ static void read_constdb(void) } while ((t = libconfig->setting_get_elem(cdb, i++))) { - bool is_parameter = false; bool is_deprecated = false; int value = 0; const char *name = config_setting_name(t); @@ -2352,10 +2351,6 @@ static void read_constdb(void) continue; } value = i32; - if (libconfig->setting_lookup_bool(t, "Parameter", &i32)) { - if (i32 != 0) - is_parameter = true; - } if (libconfig->setting_lookup_bool(t, "Deprecated", &i32)) { if (i32 != 0) is_deprecated = true; @@ -2363,9 +2358,13 @@ static void read_constdb(void) } else { value = libconfig->setting_get_int(t); } - if (is_parameter) - ShowWarning("read_constdb: Defining parameters in the constants configuration is deprecated and will no longer be possible in a future version. Parameters should be defined in source. (parameter = '%s')\n", name); - script->set_constant(name, value, is_parameter, is_deprecated); + + if (reload) { + int n = script->add_str(name); + script->str_data[n].type = C_NOP; // ensures it will be overwritten + } + + script->set_constant(name, value, false, is_deprecated); } script->constdb_comment(NULL); libconfig->destroy(&constants_conf); @@ -5593,7 +5592,7 @@ static void do_init_script(bool minimal) VECTOR_INIT(script->hqi); script->parse_builtin(); - script->read_constdb(); + script->read_constdb(false); script->load_parameters(); script->hardcoded_constants(); @@ -5645,12 +5644,11 @@ static int script_reload(void) script->parse_cleanup_timer_id = INVALID_TIMER; } - mapreg->reload(); - + script->read_constdb(true); itemdb->name_constants(); - clan->set_constants(); + mapreg->reload(); sysinfo->vcsrevision_reload(); return 0; diff --git a/src/map/script.h b/src/map/script.h index a0cfb7692..fd1391678 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -872,7 +872,7 @@ struct script_interface { void (*add_translatable_string) (const struct script_string_buf *string, const char *start_point); const char *(*parse_expr) (const char *p); const char *(*parse_line) (const char *p); - void (*read_constdb) (void); + void (*read_constdb) (bool reload); void (*constdb_comment) (const char *comment); void (*load_parameters) (void); const char* (*print_line) (StringBuf *buf, const char *p, const char *mark, int line); diff --git a/src/plugins/HPMHooking/HPMHooking.Defs.inc b/src/plugins/HPMHooking/HPMHooking.Defs.inc index 691401277..0a3bbed82 100644 --- a/src/plugins/HPMHooking/HPMHooking.Defs.inc +++ b/src/plugins/HPMHooking/HPMHooking.Defs.inc @@ -6500,8 +6500,8 @@ typedef const char* (*HPMHOOK_pre_script_parse_expr) (const char **p); typedef const char* (*HPMHOOK_post_script_parse_expr) (const char* retVal___, const char *p); typedef const char* (*HPMHOOK_pre_script_parse_line) (const char **p); typedef const char* (*HPMHOOK_post_script_parse_line) (const char* retVal___, const char *p); -typedef void (*HPMHOOK_pre_script_read_constdb) (void); -typedef void (*HPMHOOK_post_script_read_constdb) (void); +typedef void (*HPMHOOK_pre_script_read_constdb) (bool *reload); +typedef void (*HPMHOOK_post_script_read_constdb) (bool reload); typedef void (*HPMHOOK_pre_script_constdb_comment) (const char **comment); typedef void (*HPMHOOK_post_script_constdb_comment) (const char *comment); typedef void (*HPMHOOK_pre_script_load_parameters) (void); diff --git a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc index c055c6c09..53f3b3043 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc @@ -67280,14 +67280,14 @@ const char* HP_script_parse_line(const char *p) { } return retVal___; } -void HP_script_read_constdb(void) { +void HP_script_read_constdb(bool reload) { int hIndex = 0; if (HPMHooks.count.HP_script_read_constdb_pre > 0) { - void (*preHookFunc) (void); + void (*preHookFunc) (bool *reload); *HPMforce_return = false; for (hIndex = 0; hIndex < HPMHooks.count.HP_script_read_constdb_pre; hIndex++) { preHookFunc = HPMHooks.list.HP_script_read_constdb_pre[hIndex].func; - preHookFunc(); + preHookFunc(&reload); } if (*HPMforce_return) { *HPMforce_return = false; @@ -67295,13 +67295,13 @@ void HP_script_read_constdb(void) { } } { - HPMHooks.source.script.read_constdb(); + HPMHooks.source.script.read_constdb(reload); } if (HPMHooks.count.HP_script_read_constdb_post > 0) { - void (*postHookFunc) (void); + void (*postHookFunc) (bool reload); for (hIndex = 0; hIndex < HPMHooks.count.HP_script_read_constdb_post; hIndex++) { postHookFunc = HPMHooks.list.HP_script_read_constdb_post[hIndex].func; - postHookFunc(); + postHookFunc(reload); } } return; -- cgit v1.2.3-60-g2f50 From 053dac2f0e62b64877e3dd04cc531452bce9d4aa Mon Sep 17 00:00:00 2001 From: gumi Date: Fri, 13 Jul 2018 15:43:47 -0400 Subject: remove the param documentation --- db/constants.conf | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/db/constants.conf b/db/constants.conf index e51ccb9bd..b7bc24985 100644 --- a/db/constants.conf +++ b/db/constants.conf @@ -33,15 +33,9 @@ constants_db: { ************* Entry structure (full) ************************************* Identifier: { Value: value // (int) - Parameter: true // (boolean) Defaults to false. Deprecated: true // (boolean) Defaults to false. } **************************************************************************/ -// NOTE: -// Parameters are special in that they retrieve certain runtime values -// depending on the specified ID in field Value. Depending on the -// implementation values assigned by scripts to parameters will affect -// runtime values, such as Zeny, as well (see pc_readparam/pc_setparam). comment__: "Weekdays" SUNDAY: 0 @@ -1397,7 +1391,7 @@ constants_db: { SC_TUNAPARTY: 649 SC_SHRIMP: 650 SC_FRESHSHRIMP: 651 - + SC_DAILYSENDMAILCNT: 653 // Summer 2 Costume -- cgit v1.2.3-60-g2f50