diff options
author | shennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2011-12-08 20:16:57 +0000 |
---|---|---|
committer | shennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2011-12-08 20:16:57 +0000 |
commit | e2242c698fe16395fc7c8739d990e0c0ff8639e3 (patch) | |
tree | d9ce075145d431349b3fb8752dd0adc887f9d9d5 /src/map/itemdb.c | |
parent | c6e5d51e40a8e8e36af20abd39dc1bd44c863f64 (diff) | |
download | hercules-e2242c698fe16395fc7c8739d990e0c0ff8639e3.tar.gz hercules-e2242c698fe16395fc7c8739d990e0c0ff8639e3.tar.bz2 hercules-e2242c698fe16395fc7c8739d990e0c0ff8639e3.tar.xz hercules-e2242c698fe16395fc7c8739d990e0c0ff8639e3.zip |
@reloaditemdb Fix for bugreport:5104
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@15030 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/itemdb.c')
-rw-r--r-- | src/map/itemdb.c | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/src/map/itemdb.c b/src/map/itemdb.c index cbe462db9..8d897a707 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -27,6 +27,17 @@ static struct item_group itemgroup_db[MAX_ITEMGROUP]; struct item_data dummy_item; //This is the default dummy item used for non-existant items. [Skotlex] +/** + * [Ind] The following fixes the @reloaditemdb issue that'd clear the mob-dropped data (which is populated by mob_db stuff) + * - It saves the data before it is refreshed in this array, and quickly re-populates it with this same data after refresh is done. + **/ +struct { + struct { + unsigned short chance; + int id; + } mob[MAX_SEARCH]; +} temporaryMonsterDrop[MAX_ITEMDB]; + /*========================================== * 名前で検索用 *------------------------------------------*/ @@ -858,7 +869,9 @@ static bool itemdb_parse_dbrow(char** str, const char* source, int line, int scr id->equip_script = parse_script(str[20], source, line, scriptopt); if (*str[21]) id->unequip_script = parse_script(str[21], source, line, scriptopt); - + // [Ind] re-populate the temporaryMonsterDrop data + if( temporaryMonsterDrop[nameid].mob[0].id ) + memmove(&id->mob, &temporaryMonsterDrop[nameid].mob, sizeof(temporaryMonsterDrop[nameid].mob)); return true; } @@ -1093,39 +1106,23 @@ void itemdb_reload(void) struct map_session_data* sd; int i; - /** - * [Ind] The following fixes the @reloaditemdb issue that'd clear the mob-dropped data (which is populated by mob_db stuff) - * - It saves the data before it is refreshed in this array, and quickly re-populates it with this same data after refresh is done. - **/ - struct { - struct { - unsigned short chance; - int id; - } mob[MAX_SEARCH]; - } temporaryMonsterDrop[MAX_ITEMDB]; - - // [Ind] capture the existent temporaryMonsterDrop data - for( i = 0; i < ARRAYLENGTH(itemdb_array); ++i ) - if( itemdb_array[i] ) - memcpy(&temporaryMonsterDrop[i].mob, &itemdb_array[i]->mob, sizeof(itemdb_array[i]->mob)); + memset(temporaryMonsterDrop, 0, sizeof(temporaryMonsterDrop)); + // clear the previous itemdb data for( i = 0; i < ARRAYLENGTH(itemdb_array); ++i ) - if( itemdb_array[i] ) + if( itemdb_array[i] ) { + memmove(&temporaryMonsterDrop[i].mob, &itemdb_array[i]->mob, sizeof(itemdb_array[i]->mob));//hijack the existent mob drop data destroy_item_data(itemdb_array[i], 1); + } itemdb_other->clear(itemdb_other, itemdb_final_sub); memset(itemdb_array, 0, sizeof(itemdb_array)); - + // read new data itemdb_read(); - // [Ind] re-populate the temporaryMonsterDrop data - for( i = 0; i < ARRAYLENGTH(itemdb_array); ++i ) - if( itemdb_array[i] ) - memcpy(&itemdb_array[i]->mob, &temporaryMonsterDrop[i].mob, sizeof(temporaryMonsterDrop[i].mob)); - // readjust itemdb pointer cache for each player iter = mapit_geteachpc(); for( sd = (struct map_session_data*)mapit_first(iter); mapit_exists(iter); sd = (struct map_session_data*)mapit_next(iter) ) @@ -1152,6 +1149,7 @@ int do_init_itemdb(void) { memset(itemdb_array, 0, sizeof(itemdb_array)); itemdb_other = idb_alloc(DB_OPT_BASE); + memset(temporaryMonsterDrop, 0, sizeof(temporaryMonsterDrop)); create_dummy_data(); //Dummy data item. itemdb_read(); |