diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 9f9557d258..6811dbc432 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -1813,32 +1813,16 @@ static int itemdb_randomopt_free(DBKey key, DBData *data, va_list ap) { } /** -* Reload Item DB -*/ -void itemdb_reload(void) { - struct s_mapiterator* iter; - struct map_session_data* sd; + * Re-link monster drop data with item data + * Fixes the need of a @reloadmobdb after a @reloaditemdb + * @author Epoque + */ +void itemdb_reload_itemmob_data(void) { + int i; - int i,d,k; - - itemdb_group->clear(itemdb_group, itemdb_group_free); - itemdb_randomopt->clear(itemdb_randomopt, itemdb_randomopt_free); - itemdb->clear(itemdb, itemdb_final_sub); - db_clear(itemdb_combo); - if (battle_config.feature_roulette) - itemdb_roulette_free(); - - // read new data - itemdb_read(); - cashshop_reloaddb(); - - if (battle_config.feature_roulette) - itemdb_parse_roulette_db(); - - //Epoque's awesome @reloaditemdb fix - thanks! [Ind] - //- Fixes the need of a @reloadmobdb after a @reloaditemdb to re-link monster drop data for( i = 0; i < MAX_MOB_DB; i++ ) { struct mob_db *entry = mob_db(i); + int d, k; for(d = 0; d < MAX_MOB_DROP; d++) { struct item_data *id; @@ -1860,6 +1844,30 @@ void itemdb_reload(void) { id->mob[k].id = i; } } +} + +/** +* Reload Item DB +*/ +void itemdb_reload(void) { + struct s_mapiterator* iter; + struct map_session_data* sd; + + itemdb_group->clear(itemdb_group, itemdb_group_free); + itemdb_randomopt->clear(itemdb_randomopt, itemdb_randomopt_free); + itemdb->clear(itemdb, itemdb_final_sub); + db_clear(itemdb_combo); + if (battle_config.feature_roulette) + itemdb_roulette_free(); + + // read new data + itemdb_read(); + cashshop_reloaddb(); + + if (battle_config.feature_roulette) + itemdb_parse_roulette_db(); + + itemdb_reload_itemmob_data(); // readjust itemdb pointer cache for each player iter = mapit_geteachpc(); diff --git a/src/map/itemdb.h b/src/map/itemdb.h index fd4e2e4c7f..8b59695da5 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -920,6 +920,7 @@ bool itemdb_parse_roulette_db(void); struct s_random_opt_data *itemdb_randomopt_exists(short id); +void itemdb_reload_itemmob_data(void); void itemdb_reload(void); void do_final_itemdb(void); diff --git a/src/map/script.c b/src/map/script.c index 82c50b2099..6273d21fbf 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -16702,6 +16702,7 @@ BUILDIN_FUNC(addmonsterdrop) if(c) { //Fill in the slot with the item and rate mob->dropitem[c].nameid = item_id; mob->dropitem[c].p = (rate > 10000)?10000:rate; + itemdb_reload_itemmob_data(); // Reload the mob search data stored in the item_data script_pushint(st,1); } else //No place to put the new drop script_pushint(st,0); @@ -16747,6 +16748,7 @@ BUILDIN_FUNC(delmonsterdrop) if(mob->dropitem[i].nameid == item_id) { mob->dropitem[i].nameid = 0; mob->dropitem[i].p = 0; + itemdb_reload_itemmob_data(); // Reload the mob search data stored in the item_data script_pushint(st,1); return SCRIPT_CMD_SUCCESS; }