diff options
author | shennetsind <ind@henn.et> | 2014-01-13 23:53:31 -0200 |
---|---|---|
committer | shennetsind <ind@henn.et> | 2014-01-13 23:53:31 -0200 |
commit | 18291e8b8834d74e5775baeb296104cfaebe9e54 (patch) | |
tree | b9d8497fa0d2ea73453534a7ccb6bcf5c0d33386 /src | |
parent | e1a0059919dbc4f5c7e803a496b8d150c0a070f5 (diff) | |
parent | 9832e82b0e8dbda38bf4feb18e48cf5335e213ee (diff) | |
download | hercules-18291e8b8834d74e5775baeb296104cfaebe9e54.tar.gz hercules-18291e8b8834d74e5775baeb296104cfaebe9e54.tar.bz2 hercules-18291e8b8834d74e5775baeb296104cfaebe9e54.tar.xz hercules-18291e8b8834d74e5775baeb296104cfaebe9e54.zip |
Merge branch 'master' of https://github.com/HerculesWS/Hercules
Diffstat (limited to 'src')
-rw-r--r-- | src/map/itemdb.c | 11 | ||||
-rw-r--r-- | src/map/itemdb.h | 1 | ||||
-rw-r--r-- | src/map/script.c | 40 | ||||
-rw-r--r-- | src/map/script.h | 1 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking.HPMHooksCore.inc | 8 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking.HookingPoints.inc | 2 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking.Hooks.inc | 50 |
7 files changed, 17 insertions, 96 deletions
diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 3f7d06e36..3bed3e03d 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -2249,16 +2249,6 @@ void itemdb_name_constants(void) { dbi_destroy(iter); } -/* used to clear conflicts during script reload */ -void itemdb_force_name_constants(void) { - DBIterator *iter = db_iterator(itemdb->names); - struct item_data *data; - - for( data = dbi_first(iter); dbi_exists(iter); data = dbi_next(iter) ) - script->set_constant_force(data->name,data->nameid,0); - - dbi_destroy(iter); -} void do_final_itemdb(void) { itemdb->clear(true); @@ -2286,7 +2276,6 @@ void itemdb_defaults(void) { itemdb->final = do_final_itemdb; itemdb->reload = itemdb_reload; itemdb->name_constants = itemdb_name_constants; - itemdb->force_name_constants = itemdb_force_name_constants; /* */ itemdb->groups = NULL; itemdb->group_count = 0; diff --git a/src/map/itemdb.h b/src/map/itemdb.h index d74b92d4b..b3ff606df 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -499,7 +499,6 @@ struct itemdb_interface { void (*final) (void); void (*reload) (void); void (*name_constants) (void); - void (*force_name_constants) (void); /* */ struct item_group *groups; unsigned short group_count; diff --git a/src/map/script.c b/src/map/script.c index 64943dd2a..75469a345 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -2068,8 +2068,18 @@ void script_set_constant(const char* name, int value, bool isparameter) { void script_set_constant2(const char *name, int value, bool isparameter) { int n = script->add_str(name); - if( ( script->str_data[n].type == C_NAME || script->str_data[n].type == C_PARAM ) && ( script->str_data[n].val != 0 || script->str_data[n].backpatch != -1 ) ) { // existing parameter or constant - ShowNotice("Conflicting var name '%s', prioritising the script var\n",name); + if( script->str_data[n].type == C_PARAM ) { + ShowError("script_set_constant2: Attempted to overwrite existing parameter '%s' with a constant (value=%d).\n", name, value); + return; + } + + if( script->str_data[n].type == C_NAME && script->str_data[n].val ) { + ShowWarning("script_set_constant2: Attempted to overwrite existing variable '%s' with a constant (value=%d).\n", name, value); + return; + } + + if( script->str_data[n].type == C_INT && value && value != script->str_data[n].val ) { // existing constant + ShowWarning("script_set_constant2: Attempted to overwrite existing constant '%s' (old value=%d, new value=%d).\n", name, script->str_data[n].val, value); return; } @@ -2083,21 +2093,6 @@ void script_set_constant2(const char *name, int value, bool isparameter) { script->str_data[n].val = value; } -/* same as constant2 except it will override if necessary, used to clear conflicts during reload */ -void script_set_constant_force(const char *name, int value, bool isparameter) { - int n = script->add_str(name); - - if( script->str_data[n].type == C_PARAM ) - return;/* the one type we don't mess with, reload doesn't affect it. */ - - if( script->str_data[n].type != C_NOP ) { - script->str_data[n].type = C_NOP; - script->str_data[n].val = 0; - script->str_data[n].func = NULL; - script->str_data[n].backpatch = -1; - script->str_data[n].label = -1; - } -} /*========================================== * Reading constant databases * const.txt @@ -2606,7 +2601,7 @@ void script_array_ensure_zero(struct script_state *st, struct map_session_data * struct script_array *sa = NULL; bool insert = false; - if( sd ) /* when sd comes, st isn't available */ + if( sd && !st ) /* when sd comes, st isn't available */ insert = true; else { if( is_string_variable(name) ) { @@ -3603,7 +3598,7 @@ void script_check_buildin_argtype(struct script_state* st, int func) } break; case 'r': - if( !data_isreference(data) ) + if( !data_isreference(data) || reference_toconstant(data) ) {// variables ShowWarning("Unexpected type for argument %d. Expected variable, got %s.\n", idx-1,script->op2name(data->type)); script->reportdata(data); @@ -4351,7 +4346,7 @@ int script_reload(void) { mapreg->reload(); - itemdb->force_name_constants(); + itemdb->name_constants(); return 0; } @@ -5509,7 +5504,7 @@ BUILDIN(setr) { data = script_getdata(st,2); //datavalue = script_getdata(st,3); - if( !data_isreference(data) ) { + if( !data_isreference(data) || reference_toconstant(data) ) { ShowError("script:set: not a variable\n"); script->reportdata(script_getdata(st,2)); st->state = END; @@ -5596,7 +5591,7 @@ BUILDIN(setarray) TBL_PC* sd = NULL; data = script_getdata(st, 2); - if( !data_isreference(data) ) + if( !data_isreference(data) || reference_toconstant(data) ) { ShowError("script:setarray: not a variable\n"); script->reportdata(data); @@ -19136,7 +19131,6 @@ void script_defaults(void) { script->pop_stack = pop_stack; script->set_constant = script_set_constant; script->set_constant2 = script_set_constant2; - script->set_constant_force = script_set_constant_force; script->get_constant = script_get_constant; script->label_add = script_label_add; script->run = run_script; diff --git a/src/map/script.h b/src/map/script.h index 7a643fa3e..97db2a775 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -575,7 +575,6 @@ struct script_interface { void (*pop_stack) (struct script_state* st, int start, int end); void (*set_constant) (const char* name, int value, bool isparameter); void (*set_constant2) (const char *name, int value, bool isparameter); - void (*set_constant_force) (const char *name, int value, bool isparameter); bool (*get_constant) (const char* name, int* value); void (*label_add)(int key, int pos); void (*run) (struct script_code *rootscript,int pos,int rid,int oid); diff --git a/src/plugins/HPMHooking/HPMHooking.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking.HPMHooksCore.inc index 77dfef632..7f26bd208 100644 --- a/src/plugins/HPMHooking/HPMHooking.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking.HPMHooksCore.inc @@ -2459,8 +2459,6 @@ struct { struct HPMHookPoint *HP_itemdb_reload_post; struct HPMHookPoint *HP_itemdb_name_constants_pre; struct HPMHookPoint *HP_itemdb_name_constants_post; - struct HPMHookPoint *HP_itemdb_force_name_constants_pre; - struct HPMHookPoint *HP_itemdb_force_name_constants_post; struct HPMHookPoint *HP_itemdb_read_groups_pre; struct HPMHookPoint *HP_itemdb_read_groups_post; struct HPMHookPoint *HP_itemdb_read_chains_pre; @@ -4055,8 +4053,6 @@ struct { struct HPMHookPoint *HP_script_set_constant_post; struct HPMHookPoint *HP_script_set_constant2_pre; struct HPMHookPoint *HP_script_set_constant2_post; - struct HPMHookPoint *HP_script_set_constant_force_pre; - struct HPMHookPoint *HP_script_set_constant_force_post; struct HPMHookPoint *HP_script_get_constant_pre; struct HPMHookPoint *HP_script_get_constant_post; struct HPMHookPoint *HP_script_label_add_pre; @@ -7486,8 +7482,6 @@ struct { int HP_itemdb_reload_post; int HP_itemdb_name_constants_pre; int HP_itemdb_name_constants_post; - int HP_itemdb_force_name_constants_pre; - int HP_itemdb_force_name_constants_post; int HP_itemdb_read_groups_pre; int HP_itemdb_read_groups_post; int HP_itemdb_read_chains_pre; @@ -9082,8 +9076,6 @@ struct { int HP_script_set_constant_post; int HP_script_set_constant2_pre; int HP_script_set_constant2_post; - int HP_script_set_constant_force_pre; - int HP_script_set_constant_force_post; int HP_script_get_constant_pre; int HP_script_get_constant_post; int HP_script_label_add_pre; diff --git a/src/plugins/HPMHooking/HPMHooking.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking.HookingPoints.inc index c964054e1..e6f593187 100644 --- a/src/plugins/HPMHooking/HPMHooking.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking.HookingPoints.inc @@ -1248,7 +1248,6 @@ struct HookingPointData HookingPoints[] = { { HP_POP(itemdb->final, HP_itemdb_final) }, { HP_POP(itemdb->reload, HP_itemdb_reload) }, { HP_POP(itemdb->name_constants, HP_itemdb_name_constants) }, - { HP_POP(itemdb->force_name_constants, HP_itemdb_force_name_constants) }, { HP_POP(itemdb->read_groups, HP_itemdb_read_groups) }, { HP_POP(itemdb->read_chains, HP_itemdb_read_chains) }, { HP_POP(itemdb->read_packages, HP_itemdb_read_packages) }, @@ -2061,7 +2060,6 @@ struct HookingPointData HookingPoints[] = { { HP_POP(script->pop_stack, HP_script_pop_stack) }, { HP_POP(script->set_constant, HP_script_set_constant) }, { HP_POP(script->set_constant2, HP_script_set_constant2) }, - { HP_POP(script->set_constant_force, HP_script_set_constant_force) }, { HP_POP(script->get_constant, HP_script_get_constant) }, { HP_POP(script->label_add, HP_script_label_add) }, { HP_POP(script->run, HP_script_run) }, diff --git a/src/plugins/HPMHooking/HPMHooking.Hooks.inc b/src/plugins/HPMHooking/HPMHooking.Hooks.inc index 9bbb01ade..2e4b62835 100644 --- a/src/plugins/HPMHooking/HPMHooking.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking.Hooks.inc @@ -31324,31 +31324,6 @@ void HP_itemdb_name_constants(void) { } return; } -void HP_itemdb_force_name_constants(void) { - int hIndex = 0; - if( HPMHooks.count.HP_itemdb_force_name_constants_pre ) { - void (*preHookFunc) (void); - for(hIndex = 0; hIndex < HPMHooks.count.HP_itemdb_force_name_constants_pre; hIndex++ ) { - preHookFunc = HPMHooks.list.HP_itemdb_force_name_constants_pre[hIndex].func; - preHookFunc(); - } - if( *HPMforce_return ) { - *HPMforce_return = false; - return; - } - } - { - HPMHooks.source.itemdb.force_name_constants(); - } - if( HPMHooks.count.HP_itemdb_force_name_constants_post ) { - void (*postHookFunc) (void); - for(hIndex = 0; hIndex < HPMHooks.count.HP_itemdb_force_name_constants_post; hIndex++ ) { - postHookFunc = HPMHooks.list.HP_itemdb_force_name_constants_post[hIndex].func; - postHookFunc(); - } - } - return; -} void HP_itemdb_read_groups(void) { int hIndex = 0; if( HPMHooks.count.HP_itemdb_read_groups_pre ) { @@ -52283,31 +52258,6 @@ void HP_script_set_constant2(const char *name, int value, bool isparameter) { } return; } -void HP_script_set_constant_force(const char *name, int value, bool isparameter) { - int hIndex = 0; - if( HPMHooks.count.HP_script_set_constant_force_pre ) { - void (*preHookFunc) (const char *name, int *value, bool *isparameter); - for(hIndex = 0; hIndex < HPMHooks.count.HP_script_set_constant_force_pre; hIndex++ ) { - preHookFunc = HPMHooks.list.HP_script_set_constant_force_pre[hIndex].func; - preHookFunc(name, &value, &isparameter); - } - if( *HPMforce_return ) { - *HPMforce_return = false; - return; - } - } - { - HPMHooks.source.script.set_constant_force(name, value, isparameter); - } - if( HPMHooks.count.HP_script_set_constant_force_post ) { - void (*postHookFunc) (const char *name, int *value, bool *isparameter); - for(hIndex = 0; hIndex < HPMHooks.count.HP_script_set_constant_force_post; hIndex++ ) { - postHookFunc = HPMHooks.list.HP_script_set_constant_force_post[hIndex].func; - postHookFunc(name, &value, &isparameter); - } - } - return; -} bool HP_script_get_constant(const char *name, int *value) { int hIndex = 0; bool retVal___ = false; |