summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorshennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec>2011-12-08 20:52:10 +0000
committershennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec>2011-12-08 20:52:10 +0000
commitfc32c0656e13f0fb477c125c383d016fc2a3155e (patch)
tree7a7077185f431468c2af91f8a14ecc7cb9b51398 /src/map
parente2242c698fe16395fc7c8739d990e0c0ff8639e3 (diff)
downloadhercules-fc32c0656e13f0fb477c125c383d016fc2a3155e.tar.gz
hercules-fc32c0656e13f0fb477c125c383d016fc2a3155e.tar.bz2
hercules-fc32c0656e13f0fb477c125c383d016fc2a3155e.tar.xz
hercules-fc32c0656e13f0fb477c125c383d016fc2a3155e.zip
Optimized/Improved r15030, credits to Epoque!
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@15031 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r--src/map/itemdb.c52
1 files changed, 31 insertions, 21 deletions
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index 8d897a707..3fc0a5704 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -27,17 +27,6 @@ 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];
-
/*==========================================
* 名前で検索用
*------------------------------------------*/
@@ -869,9 +858,7 @@ 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;
}
@@ -1105,16 +1092,12 @@ void itemdb_reload(void)
struct s_mapiterator* iter;
struct map_session_data* sd;
- int i;
-
- memset(temporaryMonsterDrop, 0, sizeof(temporaryMonsterDrop));
+ int i,d,k;
// clear the previous itemdb data
for( i = 0; i < ARRAYLENGTH(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
+ if( itemdb_array[i] )
destroy_item_data(itemdb_array[i], 1);
- }
itemdb_other->clear(itemdb_other, itemdb_final_sub);
@@ -1122,6 +1105,34 @@ void itemdb_reload(void)
// read new data
itemdb_read();
+
+ //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;
+ if( !((i < 1324 || i > 1363) && (i < 1938 || i > 1946)) )
+ continue;
+ entry = mob_db(i);
+ for(d = 0; d < MAX_MOB_DROP; d++) {
+ struct item_data *id;
+ if( !entry->dropitem[d].nameid )
+ continue;
+ id = itemdb_search(entry->dropitem[d].nameid);
+
+ for (k = 0; k < MAX_SEARCH; k++) {
+ if (id->mob[k].chance <= entry->dropitem[d].p)
+ break;
+ }
+
+ if (k == MAX_SEARCH)
+ continue;
+
+ if (id->mob[k].id != i)
+ memmove(&id->mob[k+1], &id->mob[k], (MAX_SEARCH-k-1)*sizeof(id->mob[0]));
+ id->mob[k].chance = entry->dropitem[d].p;
+ id->mob[k].id = i;
+ }
+ }
// readjust itemdb pointer cache for each player
iter = mapit_geteachpc();
@@ -1149,7 +1160,6 @@ 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();