Forráskód Böngészése

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
Kevin 17 éve
szülő
commit
1f6d5057bc
7 módosított fájl, 49 hozzáadás és 46 törlés
  1. 3 0
      conf/atcommand_athena.conf
  2. 15 1
      src/map/atcommand.c
  3. 12 19
      src/map/clif.c
  4. 1 1
      src/map/guild.c
  5. 17 22
      src/map/itemdb.c
  6. 1 1
      src/map/itemdb.h
  7. 0 2
      src/map/storage.h

+ 3 - 0
conf/atcommand_athena.conf

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

+ 15 - 1
src/map/atcommand.c

@@ -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)
 {
 	nullpo_retr(-1, sd);
-	itemdb_reload();
+	itemdb_reload(0);
 	clif_displaymessage(fd, msg_txt(97)); // Item database reloaded.
 
 	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
 	{ "recallall",         80,     atcommand_recallall },
 	{ "reloaditemdb",      99,     atcommand_reloaditemdb },
+	{ "reloaditemdb2",      99,     atcommand_reloaditemdb2 },
 	{ "reloadmobdb",       99,     atcommand_reloadmobdb },
 	{ "reloadskilldb",     99,     atcommand_reloadskilldb },
 	{ "reloadscript",      99,     atcommand_reloadscript },

+ 12 - 19
src/map/clif.c

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

+ 1 - 1
src/map/guild.c

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

+ 17 - 22
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)

+ 1 - 1
src/map/itemdb.h

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

+ 0 - 2
src/map/storage.h

@@ -11,7 +11,6 @@ struct item;
 //#include "map.h"
 struct map_session_data;
 
-struct storage *account2storage2(int account_id);
 int storage_storageopen(struct map_session_data *sd);
 int storage_storageadd(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);
 struct storage* account2storage(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_save(int account_id, int final);
 int storage_storage_saved(int account_id); //Ack from char server that guild store was saved.