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://svn.code.sf.net/p/rathena/svn/trunk@12662 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
Kevin 2008-04-27 09:15:05 +00:00
parent 26a70ed737
commit 1f6d5057bc
7 changed files with 49 additions and 46 deletions

View File

@ -700,6 +700,9 @@ mapflag: 99
// Re-load item database (admin command) // Re-load item database (admin command)
reloaditemdb: 99 reloaditemdb: 99
// Re-load item database and delete all references to it (admin command)
reloaditemdb2: 99
// Re-load monsters database (admin command) // Re-load monsters database (admin command)
reloadmobdb: 99 reloadmobdb: 99

View File

@ -4049,12 +4049,25 @@ int atcommand_partyrecall(const int fd, struct map_session_data* sd, const char*
int atcommand_reloaditemdb(const int fd, struct map_session_data* sd, const char* command, const char* message) int atcommand_reloaditemdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
{ {
nullpo_retr(-1, sd); nullpo_retr(-1, sd);
itemdb_reload(); itemdb_reload(0);
clif_displaymessage(fd, msg_txt(97)); // Item database reloaded. clif_displaymessage(fd, msg_txt(97)); // Item database reloaded.
return 0; return 0;
} }
/*==========================================
*
*------------------------------------------*/
int atcommand_reloaditemdb2(const int fd, struct map_session_data* sd, const char* command, const char* message)
{
nullpo_retr(-1, sd);
itemdb_reload(1);
clif_displaymessage(fd, msg_txt(97)); // Item database reloaded.
return 0;
}
/*========================================== /*==========================================
* *
*------------------------------------------*/ *------------------------------------------*/
@ -8373,6 +8386,7 @@ AtCommandInfo atcommand_info[] = {
{ "localbroadcast", 40, atcommand_localbroadcast }, // + /lb and /nlb { "localbroadcast", 40, atcommand_localbroadcast }, // + /lb and /nlb
{ "recallall", 80, atcommand_recallall }, { "recallall", 80, atcommand_recallall },
{ "reloaditemdb", 99, atcommand_reloaditemdb }, { "reloaditemdb", 99, atcommand_reloaditemdb },
{ "reloaditemdb2", 99, atcommand_reloaditemdb2 },
{ "reloadmobdb", 99, atcommand_reloadmobdb }, { "reloadmobdb", 99, atcommand_reloadmobdb },
{ "reloadskilldb", 99, atcommand_reloadskilldb }, { "reloadskilldb", 99, atcommand_reloadskilldb },
{ "reloadscript", 99, atcommand_reloadscript }, { "reloadscript", 99, atcommand_reloadscript },

View File

@ -1894,27 +1894,20 @@ void clif_storagelist(struct map_session_data *sd,struct storage *stor)
if(stor->storage_[i].nameid<=0) if(stor->storage_[i].nameid<=0)
continue; continue;
id = itemdb_search(stor->storage_[i].nameid); id = itemdb_search(stor->storage_[i].nameid);
if(!id) if(!itemdb_isstackable2(id))
{ { //Equippable
//Item not found, was probably deleted and then map server reloaded/item db reloaded WBUFW(bufe,ne*20+4)=i+1;
storage_delitem(sd, stor, i, stor->storage_[i].amount); clif_item_sub(bufe, ne*20+6, &stor->storage_[i], id, id->equip);
return; clif_addcards(WBUFP(bufe, ne*20+16), &stor->storage_[i]);
} ne++;
else } else { //Stackable
if(!itemdb_isstackable2(id)) WBUFW(buf,n*s+4)=i+1;
{ //Equippable clif_item_sub(buf, n*s+6, &stor->storage_[i], id,-1);
WBUFW(bufe,ne*20+4)=i+1;
clif_item_sub(bufe, ne*20+6, &stor->storage_[i], id, id->equip);
clif_addcards(WBUFP(bufe, ne*20+16), &stor->storage_[i]);
ne++;
} else { //Stackable
WBUFW(buf,n*s+4)=i+1;
clif_item_sub(buf, n*s+6, &stor->storage_[i], id,-1);
#if PACKETVER >= 5 #if PACKETVER >= 5
clif_addcards(WBUFP(buf,n*s+14), &stor->storage_[i]); clif_addcards(WBUFP(buf,n*s+14), &stor->storage_[i]);
#endif #endif
n++; n++;
} }
} }
if(n){ if(n){
#if PACKETVER < 5 #if PACKETVER < 5

View File

@ -1594,7 +1594,7 @@ int guild_broken(int guild_id,int flag)
if( (gc=guild_castle_search(i)) != NULL ){ if( (gc=guild_castle_search(i)) != NULL ){
if(gc->guild_id == guild_id){ if(gc->guild_id == guild_id){
safestrncpy(name, gc->castle_event, 50); safestrncpy(name, gc->castle_event, 50);
npc_event_do(strcat(name,"::OnGuildBreak")); npc_event_do("::OnGuildBreak");
} }
} }
} }

View File

@ -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 * 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) 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; 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) int itemdb_reload_check_npc(DBKey key,void * data,va_list ap)
{ {
struct npc_data * nd = (struct npc_data *)data; 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) 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--; 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) if(!sd->status.inventory[i].nameid)
continue; continue;
id = itemdb_search2(sd->status.inventory[i].nameid); id = itemdb_exists(sd->status.inventory[i].nameid);
if(id == NULL) if(id == NULL)
{ {
sd->inventory_data[i] = 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) if(!sd->status.cart[i].nameid)
continue; continue;
id = itemdb_search2(sd->status.cart[i].nameid); id = itemdb_exists(sd->status.cart[i].nameid);
if(id == NULL) if(id == NULL)
{ {
sd->inventory_data[i] = 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) if(!sd->status.inventory[i].nameid)
continue; 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); storage_delitem(sd, stor, i, stor->storage_[i].amount);
} }
} }
@ -1154,7 +1145,7 @@ void itemdb_foreach_mobdb(void)
continue; continue;
for(j=0; j < MAX_MOB_DROP; j++) 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) if(id == NULL)
{ {
mdb->dropitem[j].nameid = 0; 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_final_itemdb();
do_init_itemdb(); do_init_itemdb();
//Update ALL items on the server if(flag)
map_foreachpc(itemdb_reload_check); {
npc_foreach(itemdb_reload_check_npc); //Update ALL items on the server
itemdb_foreach_mobdb(); map_foreachpc(itemdb_reload_check);
npc_foreach(itemdb_reload_check_npc);
itemdb_foreach_mobdb();
}
} }
void do_final_itemdb(void) void do_final_itemdb(void)

View File

@ -137,7 +137,7 @@ int itemdb_isidentified(int);
int itemdb_isstackable(int); int itemdb_isstackable(int);
int itemdb_isstackable2(struct item_data *); int itemdb_isstackable2(struct item_data *);
void itemdb_reload(void); void itemdb_reload(int flag);
void do_final_itemdb(void); void do_final_itemdb(void);
int do_init_itemdb(void); int do_init_itemdb(void);

View File

@ -11,7 +11,6 @@ struct item;
//#include "map.h" //#include "map.h"
struct map_session_data; struct map_session_data;
struct storage *account2storage2(int account_id);
int storage_storageopen(struct map_session_data *sd); int storage_storageopen(struct map_session_data *sd);
int storage_storageadd(struct map_session_data *sd,int index,int amount); int storage_storageadd(struct map_session_data *sd,int index,int amount);
int storage_storageget(struct map_session_data *sd,int index,int amount); int storage_storageget(struct map_session_data *sd,int index,int amount);
@ -24,7 +23,6 @@ void do_final_storage(void);
void do_reconnect_storage(void); void do_reconnect_storage(void);
struct storage* account2storage(int account_id); struct storage* account2storage(int account_id);
struct storage* account2storage2(int account_id); struct storage* account2storage2(int account_id);
int storage_delete(int account_id);
int storage_storage_quit(struct map_session_data *sd, int flag); int storage_storage_quit(struct map_session_data *sd, int flag);
int storage_storage_save(int account_id, int final); int storage_storage_save(int account_id, int final);
int storage_storage_saved(int account_id); //Ack from char server that guild store was saved. int storage_storage_saved(int account_id); //Ack from char server that guild store was saved.