diff options
author | shennetsind <ind@henn.et> | 2013-07-18 05:34:34 -0300 |
---|---|---|
committer | shennetsind <ind@henn.et> | 2013-07-18 05:34:34 -0300 |
commit | e26c9504e825abe8fe50eca28bf3b89de8e4bd9c (patch) | |
tree | cb329c296924f8f8ff47033e90e9b528bb4bd9cf | |
parent | 586c0f7983f81e97ca70c57712e25d4d51453d6b (diff) | |
download | hercules-e26c9504e825abe8fe50eca28bf3b89de8e4bd9c.tar.gz hercules-e26c9504e825abe8fe50eca28bf3b89de8e4bd9c.tar.bz2 hercules-e26c9504e825abe8fe50eca28bf3b89de8e4bd9c.tar.xz hercules-e26c9504e825abe8fe50eca28bf3b89de8e4bd9c.zip |
Fixed Bug #7525
Item name constants conflicting with script var names will now result in a map server warning/notice and in the background map server will prioritise the script variable over the item name constant.
http://hercules.ws/board/tracker/issue-7525-set-variable-is-not-recognized-causing-freezing/
---
Also followup 586c0f7983f81e97ca70c57712e25d4d51453d6b sc_config.txt update
Signed-off-by: shennetsind <ind@henn.et>
-rw-r--r-- | db/sc_config.txt | 6 | ||||
-rw-r--r-- | src/map/itemdb.c | 14 | ||||
-rw-r--r-- | src/map/itemdb.h | 1 | ||||
-rw-r--r-- | src/map/npc.c | 6 | ||||
-rw-r--r-- | src/map/script.c | 29 | ||||
-rw-r--r-- | src/map/script.h | 1 |
6 files changed, 51 insertions, 6 deletions
diff --git a/db/sc_config.txt b/db/sc_config.txt index c286d9cce..4143b8b2e 100644 --- a/db/sc_config.txt +++ b/db/sc_config.txt @@ -383,6 +383,12 @@ SC_FULL_THROTTLE, 18 SC_REBOUND, 18 SC_TELEKINESIS_INTENSE,18 +//Guild Auras should not be saved +SC_LEADERSHIP,2 +SC_GLORYWOUNDS,2 +SC_SOULCOLD,2 +SC_HAWKEYES,2 + // Unremovable SC_WEIGHTOVER50, 79 SC_WEIGHTOVER90, 79 diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 3c77c4b14..223c67a3a 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -1942,9 +1942,6 @@ static void itemdb_read(void) { sv->readdb(iMap->db_path, DBPATH"item_buyingstore.txt", ',', 1, 1, -1, &itemdb_read_buyingstore); sv->readdb(iMap->db_path, "item_nouse.txt", ',', 3, 3, -1, &itemdb_read_nouse); - - itemdb->name_constants(); - itemdb_uid_load(); } @@ -2111,6 +2108,16 @@ 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) { int i; @@ -2168,6 +2175,7 @@ void itemdb_defaults(void) { itemdb->final = do_final_itemdb; itemdb->reload = itemdb_reload;//incomplete 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 93bb8e0b9..41f40895b 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -280,6 +280,7 @@ 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/npc.c b/src/map/npc.c index 77c101f14..6aa19198f 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -3844,7 +3844,9 @@ int npc_reload(void) { "\t-'"CL_WHITE"%d"CL_RESET"' Mobs Cached\n" "\t-'"CL_WHITE"%d"CL_RESET"' Mobs Not Cached\n", npc_id - npc_new_min, npc_warp, npc_shop, npc_script, npc_mob, npc_cache_mob, npc_delay_mob); - + + itemdb->name_constants(); + for(i = 0; i < instance->instances; i++) { instance->destroy(i); } @@ -3999,6 +4001,8 @@ int do_init_npc(void) "\t-'"CL_WHITE"%d"CL_RESET"' Mobs Not Cached\n", npc_id - START_NPC_NUM, npc_warp, npc_shop, npc_script, npc_mob, npc_cache_mob, npc_delay_mob); + itemdb->name_constants(); + iMap->zone_init(); npc->motd = npc_name2id("HerculesMOTD"); /* [Ind/Hercules] */ diff --git a/src/map/script.c b/src/map/script.c index 4a457bd28..02fbf00ed 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -1964,10 +1964,15 @@ void script_set_constant(const char* name, int value, bool isparameter) { ShowError("script_set_constant: Invalid name for %s '%s' (already defined as %s).\n", isparameter ? "parameter" : "constant", name, script_op2name(script->str_data[n].type)); } } -/* will override if necessary */ +/* adds data to a existent constant in the database, inserted normally via parse */ void script_set_constant2(const char *name, int value, bool isparameter) { int n = 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 item/script var '%s', prioritising the script var\n",name); + return; + } + if( script->str_data[n].type != C_NOP ) { script->str_data[n].func = NULL; script->str_data[n].backpatch = -1; @@ -1976,6 +1981,22 @@ void script_set_constant2(const char *name, int value, bool isparameter) { script->str_data[n].type = isparameter ? C_PARAM : C_INT; 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 = 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 @@ -3869,6 +3890,9 @@ int script_reload() { db_clear(script->st_db); mapreg_reload(); + + itemdb->force_name_constants(); + return 0; } @@ -18175,6 +18199,7 @@ 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; diff --git a/src/map/script.h b/src/map/script.h index 25a891897..8e2c4a6f5 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -384,6 +384,7 @@ 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); /* */ |