Browse Source

* Removed some of the duplicate, storage-related packet code.
- Removed clif_guildstoragelist and adjusted clif_storagelist to be able to handle any kind of storage.
- Removed clif_guildstorageitemadded in favor of clif_storageitemadded.
- This also fixes clif_guildstorageitemadded sending old update packet for clients prior 20090603, although packet 0x1c4 (ZC_ADD_ITEM_TO_STORE2) was added before PACKETVER 5 (before 2003-11-03aSakexe, exact addition date unknown) (since r14286).

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@14571 54d463be-8e91-2dee-dedb-b68131a5f0ec

ai4rei 14 years ago
parent
commit
522a51bb10
5 changed files with 23 additions and 136 deletions
  1. 5 0
      Changelog-Trunk.txt
  2. 12 128
      src/map/clif.c
  3. 1 3
      src/map/clif.h
  4. 1 1
      src/map/intif.c
  5. 4 4
      src/map/storage.c

+ 5 - 0
Changelog-Trunk.txt

@@ -1,5 +1,10 @@
 Date	Added
 Date	Added
 
 
+2010/12/09
+	* Removed some of the duplicate, storage-related packet code. [Ai4rei]
+	- Removed clif_guildstoragelist and adjusted clif_storagelist to be able to handle any kind of storage.
+	- Removed clif_guildstorageitemadded in favor of clif_storageitemadded.
+	- This also fixes clif_guildstorageitemadded sending old update packet for clients prior 20090603, although packet 0x1c4 (ZC_ADD_ITEM_TO_STORE2) was added before PACKETVER 5 (before 2003-11-03aSakexe, exact addition date unknown) (since r14286).
 2010/12/08
 2010/12/08
 	* Applied some script command documentation updates and fixes as already done inside the wiki. [Ai4rei]
 	* Applied some script command documentation updates and fixes as already done inside the wiki. [Ai4rei]
 	- Updated description for 'next', 'return', 'attachrid', 'detachrid', 'itemskill', 'openstorage', 'skilleffect', 'donpcevent', 'day', 'night', 'atoi' and 'axtoi' to resolve inaccuracies, missing information or unverified behavior.
 	- Updated description for 'next', 'return', 'attachrid', 'detachrid', 'itemskill', 'openstorage', 'skilleffect', 'donpcevent', 'day', 'night', 'atoi' and 'axtoi' to resolve inaccuracies, missing information or unverified behavior.

+ 12 - 128
src/map/clif.c

@@ -2154,7 +2154,7 @@ void clif_equiplist(struct map_session_data *sd)
 	}
 	}
 }
 }
 
 
-void clif_storagelist(struct map_session_data* sd, struct storage_data* stor)
+void clif_storagelist(struct map_session_data* sd, struct item* items, int items_length)
 {
 {
 	struct item_data *id;
 	struct item_data *id;
 	int i,n,ne;
 	int i,n,ne;
@@ -2175,21 +2175,21 @@ void clif_storagelist(struct map_session_data* sd, struct storage_data* stor)
 	const int cmd = 28;
 	const int cmd = 28;
 #endif
 #endif
 
 
-	buf = (unsigned char*)aMallocA(MAX_STORAGE * s + 4);
-	bufe = (unsigned char*)aMallocA(MAX_STORAGE * cmd + 4);
+	buf = (unsigned char*)aMallocA(items_length * s + 4);
+	bufe = (unsigned char*)aMallocA(items_length * cmd + 4);
 
 
-	for( i = 0, n = 0, ne = 0; i < MAX_STORAGE; i++ )
+	for( i = 0, n = 0, ne = 0; i < items_length; i++ )
 	{
 	{
-		if( stor->items[i].nameid <= 0 )
+		if( items[i].nameid <= 0 )
 			continue;
 			continue;
-		id = itemdb_search(stor->items[i].nameid);
+		id = itemdb_search(items[i].nameid);
 		if( !itemdb_isstackable2(id) )
 		if( !itemdb_isstackable2(id) )
 		{ //Equippable
 		{ //Equippable
 			WBUFW(bufe,ne*cmd+4)=i+1;
 			WBUFW(bufe,ne*cmd+4)=i+1;
-			clif_item_sub(bufe, ne*cmd+6, &stor->items[i], id, id->equip);
-			clif_addcards(WBUFP(bufe, ne*cmd+16), &stor->items[i]);
+			clif_item_sub(bufe, ne*cmd+6, &items[i], id, id->equip);
+			clif_addcards(WBUFP(bufe, ne*cmd+16), &items[i]);
 #if PACKETVER >= 20071002
 #if PACKETVER >= 20071002
-			WBUFL(bufe,ne*cmd+24)=stor->items[i].expire_time;
+			WBUFL(bufe,ne*cmd+24)=items[i].expire_time;
 			WBUFW(bufe,ne*cmd+28)=0; //Unknown
 			WBUFW(bufe,ne*cmd+28)=0; //Unknown
 #endif
 #endif
 			ne++;
 			ne++;
@@ -2197,93 +2197,12 @@ void clif_storagelist(struct map_session_data* sd, struct storage_data* stor)
 		else
 		else
 		{ //Stackable
 		{ //Stackable
 			WBUFW(buf,n*s+4)=i+1;
 			WBUFW(buf,n*s+4)=i+1;
-			clif_item_sub(buf, n*s+6, &stor->items[i], id,-1);
+			clif_item_sub(buf, n*s+6, &items[i], id,-1);
 #if PACKETVER >= 5
 #if PACKETVER >= 5
-			clif_addcards(WBUFP(buf,n*s+14), &stor->items[i]);
+			clif_addcards(WBUFP(buf,n*s+14), &items[i]);
 #endif
 #endif
 #if PACKETVER >= 20080102
 #if PACKETVER >= 20080102
-			WBUFL(buf,n*s+22)=stor->items[i].expire_time;
-#endif
-			n++;
-		}
-	}
-	if( n )
-	{
-#if PACKETVER < 5
-		WBUFW(buf,0)=0xa5;
-#elif PACKETVER < 20080102
-		WBUFW(buf,0)=0x1f0;
-#else
-		WBUFW(buf,0)=0x2ea;
-#endif
-		WBUFW(buf,2)=4+n*s;
-		clif_send(buf, WBUFW(buf,2), &sd->bl, SELF);
-	}
-	if( ne )
-	{
-#if PACKETVER < 20071002
-		WBUFW(bufe,0)=0xa6;
-#else
-		WBUFW(bufe,0)=0x2d1;
-#endif
-		WBUFW(bufe,2)=4+ne*cmd;
-		clif_send(bufe, WBUFW(bufe,2), &sd->bl, SELF);
-	}
-
-	if( buf ) aFree(buf);
-	if( bufe ) aFree(bufe);
-}
-
-//Unified storage function which sends all of the storage (requires two packets, one for equipable items and one for stackable ones. [Skotlex]
-void clif_guildstoragelist(struct map_session_data *sd,struct guild_storage *stor)
-{
-	struct item_data *id;
-	int i,n,ne;
-	unsigned char *buf;
-	unsigned char *bufe;
-#if PACKETVER < 5
-	const int s = 10; //Entry size.
-#elif PACKETVER < 20080102
-	const int s = 18;
-#else
-	const int s = 22;
-#endif
-#if PACKETVER < 20071002
-	const int cmd = 20;
-#elif PACKETVER < 20100629
-	const int cmd = 26;
-#else
-	const int cmd = 28;
-#endif
-
-	buf = (unsigned char*)aMallocA(MAX_GUILD_STORAGE * s + 4);
-	bufe = (unsigned char*)aMallocA(MAX_GUILD_STORAGE * cmd + 4);
-
-	for( i = 0, n = 0, ne = 0; i < MAX_GUILD_STORAGE; i++ )
-	{
-		if( stor->storage_[i].nameid <= 0 )
-			continue;
-		id = itemdb_search(stor->storage_[i].nameid);
-		if( !itemdb_isstackable2(id) )
-		{ //Equippable
-			WBUFW(bufe,ne*cmd+4)=i+1;
-			clif_item_sub(bufe, ne*cmd+6, &stor->storage_[i], id, id->equip);
-			clif_addcards(WBUFP(bufe, ne*cmd+16), &stor->storage_[i]);
-#if PACKETVER >= 20071002
-			WBUFL(bufe,ne*cmd+24)=stor->storage_[i].expire_time;
-			WBUFW(bufe,ne*cmd+28)=0; //Unknown
-#endif
-			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]);
-#endif
-#if PACKETVER >= 20080102
-			WBUFL(buf,n*s+22)=stor->storage_[i].expire_time;
+			WBUFL(buf,n*s+22)=items[i].expire_time;
 #endif
 #endif
 			n++;
 			n++;
 		}
 		}
@@ -3673,41 +3592,6 @@ void clif_updateguildstorageamount(struct map_session_data* sd, int amount)
 	WFIFOSET(fd,packet_len(0xf2));
 	WFIFOSET(fd,packet_len(0xf2));
 }
 }
 
 
-/*==========================================
- *
- *------------------------------------------*/
-void clif_guildstorageitemadded(struct map_session_data* sd, struct item* i, int index, int amount)
-{
-	int view,fd;
-	unsigned char *buf;
-#if PACKETVER < 20090603
-	const int cmd = 0xf4;
-#else
-	const int cmd = 0x1c4;
-#endif
-
-	nullpo_retv(sd);
-	nullpo_retv(i);
-	fd=sd->fd;
-	view = itemdb_viewid(i->nameid);
-	buf = WFIFOP(fd,0);
-
-	WFIFOHEAD(fd,packet_len(cmd));
-	WBUFW(buf, 0) = cmd; // Storage item added
-	WBUFW(buf, 2) = index+1; // index
-	WBUFL(buf, 4) = amount; // amount
-	WBUFW(buf, 8) = ( view > 0 ) ? view : i->nameid; // id
-#if PACKETVER >= 20090603
-	WBUFB(buf,10) = itemdb_type(i->nameid); //type
-	buf = WBUFP(buf,1); //Advance 1B
-#endif
-	WBUFB(buf,10) = i->identify; //identify flag
-	WBUFB(buf,11) = i->attribute; // attribute
-	WBUFB(buf,12) = i->refine; //refine
-	clif_addcards(WBUFP(buf,13), i);
-	WFIFOSET(fd,packet_len(cmd));
-}
-
 /*==========================================
 /*==========================================
  * カプラ倉庫からアイテムを取り去る
  * カプラ倉庫からアイテムを取り去る
  *------------------------------------------*/
  *------------------------------------------*/

+ 1 - 3
src/map/clif.h

@@ -270,14 +270,12 @@ void clif_tradecompleted(struct map_session_data* sd, int fail);
 
 
 // storage
 // storage
 #include "storage.h"
 #include "storage.h"
-void clif_storagelist(struct map_session_data* sd, struct storage_data* stor);
+void clif_storagelist(struct map_session_data* sd, struct item* items, int items_length);
 void clif_updatestorageamount(struct map_session_data* sd, int amount);
 void clif_updatestorageamount(struct map_session_data* sd, int amount);
 void clif_storageitemadded(struct map_session_data* sd, struct item* i, int index, int amount);
 void clif_storageitemadded(struct map_session_data* sd, struct item* i, int index, int amount);
 void clif_storageitemremoved(struct map_session_data* sd, int index, int amount);
 void clif_storageitemremoved(struct map_session_data* sd, int index, int amount);
 void clif_storageclose(struct map_session_data* sd);
 void clif_storageclose(struct map_session_data* sd);
-void clif_guildstoragelist(struct map_session_data* sd, struct guild_storage* stor);
 void clif_updateguildstorageamount(struct map_session_data* sd, int amount);
 void clif_updateguildstorageamount(struct map_session_data* sd, int amount);
-void clif_guildstorageitemadded(struct map_session_data* sd, struct item* i, int index, int amount);
 
 
 int clif_insight(struct block_list *,va_list);	// map_forallinmovearea callback
 int clif_insight(struct block_list *,va_list);	// map_forallinmovearea callback
 int clif_outsight(struct block_list *,va_list);	// map_forallinmovearea callback
 int clif_outsight(struct block_list *,va_list);	// map_forallinmovearea callback

+ 1 - 1
src/map/intif.c

@@ -986,7 +986,7 @@ int intif_parse_LoadGuildStorage(int fd)
 	memcpy(gstor,RFIFOP(fd,12),sizeof(struct guild_storage));
 	memcpy(gstor,RFIFOP(fd,12),sizeof(struct guild_storage));
 	gstor->storage_status = 1;
 	gstor->storage_status = 1;
 	sd->state.storage_flag = 2;
 	sd->state.storage_flag = 2;
-	clif_guildstoragelist(sd,gstor);
+	clif_storagelist(sd, gstor->storage_, ARRAYLENGTH(gstor->storage_));
 	clif_updateguildstorageamount(sd,gstor->storage_amount);
 	clif_updateguildstorageamount(sd,gstor->storage_amount);
 	return 0;
 	return 0;
 }
 }

+ 4 - 4
src/map/storage.c

@@ -104,7 +104,7 @@ int storage_storageopen(struct map_session_data *sd)
 	}
 	}
 	
 	
 	sd->state.storage_flag = 1;
 	sd->state.storage_flag = 1;
-	clif_storagelist(sd,&sd->status.storage);
+	clif_storagelist(sd, sd->status.storage.items, ARRAYLENGTH(sd->status.storage.items));
 	clif_updatestorageamount(sd,sd->status.storage.storage_amount);
 	clif_updatestorageamount(sd,sd->status.storage.storage_amount);
 	return 0;
 	return 0;
 }
 }
@@ -380,7 +380,7 @@ int storage_guild_storageopen(struct map_session_data* sd)
 	
 	
 	gstor->storage_status = 1;
 	gstor->storage_status = 1;
 	sd->state.storage_flag = 2;
 	sd->state.storage_flag = 2;
-	clif_guildstoragelist(sd,gstor);
+	clif_storagelist(sd, gstor->storage_, ARRAYLENGTH(gstor->storage_));
 	clif_updateguildstorageamount(sd,gstor->storage_amount);
 	clif_updateguildstorageamount(sd,gstor->storage_amount);
 	return 0;
 	return 0;
 }
 }
@@ -410,7 +410,7 @@ int guild_storage_additem(struct map_session_data* sd, struct guild_storage* sto
 				if(stor->storage_[i].amount+amount > MAX_AMOUNT)
 				if(stor->storage_[i].amount+amount > MAX_AMOUNT)
 					return 1;
 					return 1;
 				stor->storage_[i].amount+=amount;
 				stor->storage_[i].amount+=amount;
-				clif_guildstorageitemadded(sd,&stor->storage_[i],i,amount);
+				clif_storageitemadded(sd,&stor->storage_[i],i,amount);
 				stor->dirty = 1;
 				stor->dirty = 1;
 				if(log_config.enable_logs&0x1000)
 				if(log_config.enable_logs&0x1000)
 					log_pick_pc(sd, "G", item_data->nameid, -amount, item_data);
 					log_pick_pc(sd, "G", item_data->nameid, -amount, item_data);
@@ -427,7 +427,7 @@ int guild_storage_additem(struct map_session_data* sd, struct guild_storage* sto
 	memcpy(&stor->storage_[i],item_data,sizeof(stor->storage_[0]));
 	memcpy(&stor->storage_[i],item_data,sizeof(stor->storage_[0]));
 	stor->storage_[i].amount=amount;
 	stor->storage_[i].amount=amount;
 	stor->storage_amount++;
 	stor->storage_amount++;
-	clif_guildstorageitemadded(sd,&stor->storage_[i],i,amount);
+	clif_storageitemadded(sd,&stor->storage_[i],i,amount);
 	clif_updateguildstorageamount(sd,stor->storage_amount);
 	clif_updateguildstorageamount(sd,stor->storage_amount);
 	stor->dirty = 1;
 	stor->dirty = 1;
 	if(log_config.enable_logs&0x1000)
 	if(log_config.enable_logs&0x1000)