diff options
author | Kevin <Kevin@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2008-04-27 09:15:05 +0000 |
---|---|---|
committer | Kevin <Kevin@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2008-04-27 09:15:05 +0000 |
commit | 55434bd1ddfeb0b66247dbe4c420048863d44446 (patch) | |
tree | fb053a26628370a14b6f596265fcb89c0475541e /src/map/itemdb.c | |
parent | 677598256feaad3bcef53805ad8c70e744a9b7d3 (diff) | |
download | hercules-55434bd1ddfeb0b66247dbe4c420048863d44446.tar.gz hercules-55434bd1ddfeb0b66247dbe4c420048863d44446.tar.bz2 hercules-55434bd1ddfeb0b66247dbe4c420048863d44446.tar.xz hercules-55434bd1ddfeb0b66247dbe4c420048863d44446.zip |
Changed the last commit so it must be called with @reloaditemdb2. @reloaditemdb only removes the item_data from the itemdb subsystem. If you don't like my code you can uncomment the macro I_HATE_KEVIN in item_db.c so it isn't even compiled.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12662 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/itemdb.c')
-rw-r--r-- | src/map/itemdb.c | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 6cfbbca97..5fc174989 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -1015,18 +1015,6 @@ static void destroy_item_data(struct item_data* self, int free_self) /*========================================== * Looks for an item, returns NULL if not found *------------------------------------------*/ -struct item_data* itemdb_search2(int nameid) -{ - if( nameid >= 0 && nameid < ARRAYLENGTH(itemdb_array) ) - { - DBKey key; - if( itemdb_array[nameid] ) - return itemdb_array[nameid]; - key.i = nameid; - return NULL; - } - return (struct item_data*)idb_get(itemdb_other,nameid); -} static int itemdb_final_sub(DBKey key,void *data,va_list ap) { @@ -1038,6 +1026,9 @@ static int itemdb_final_sub(DBKey key,void *data,va_list ap) return 0; } +//Uncomment this if you're an elitist jerk who thinks this code is unecessary +//#define I_HATE_KEVIN +#ifndef I_HATE_KEVIN int itemdb_reload_check_npc(DBKey key,void * data,va_list ap) { struct npc_data * nd = (struct npc_data *)data; @@ -1049,7 +1040,7 @@ int itemdb_reload_check_npc(DBKey key,void * data,va_list ap) while(i < nd->u.shop.count) { - if(itemdb_search2(nd->u.shop.shop_item[i].nameid) == NULL) + if(itemdb_exists(nd->u.shop.shop_item[i].nameid) == NULL) { nd->u.shop.count--; @@ -1094,7 +1085,7 @@ static int itemdb_reload_check(DBKey key,void *data,va_list ap) if(!sd->status.inventory[i].nameid) continue; - id = itemdb_search2(sd->status.inventory[i].nameid); + id = itemdb_exists(sd->status.inventory[i].nameid); if(id == NULL) { sd->inventory_data[i] = NULL; @@ -1112,7 +1103,7 @@ static int itemdb_reload_check(DBKey key,void *data,va_list ap) if(!sd->status.cart[i].nameid) continue; - id = itemdb_search2(sd->status.cart[i].nameid); + id = itemdb_exists(sd->status.cart[i].nameid); if(id == NULL) { sd->inventory_data[i] = NULL; @@ -1131,7 +1122,7 @@ static int itemdb_reload_check(DBKey key,void *data,va_list ap) if(!sd->status.inventory[i].nameid) continue; - if(itemdb_search2(sd->status.inventory[i].nameid) == NULL) + if(itemdb_exists(sd->status.inventory[i].nameid) == NULL) storage_delitem(sd, stor, i, stor->storage_[i].amount); } } @@ -1154,7 +1145,7 @@ void itemdb_foreach_mobdb(void) continue; for(j=0; j < MAX_MOB_DROP; j++) { - id = itemdb_search2(mdb->dropitem[j].nameid); + id = itemdb_exists(mdb->dropitem[j].nameid); if(id == NULL) { mdb->dropitem[j].nameid = 0; @@ -1163,17 +1154,21 @@ void itemdb_foreach_mobdb(void) } } } +#endif -void itemdb_reload(void) +void itemdb_reload(int flag) { do_final_itemdb(); do_init_itemdb(); - //Update ALL items on the server - map_foreachpc(itemdb_reload_check); - npc_foreach(itemdb_reload_check_npc); - itemdb_foreach_mobdb(); + if(flag) + { + //Update ALL items on the server + map_foreachpc(itemdb_reload_check); + npc_foreach(itemdb_reload_check_npc); + itemdb_foreach_mobdb(); + } } void do_final_itemdb(void) |