Ver código fonte

Storagelist fix

Follow up hash:0f2dd7f (adding support to map<=>client to allow longer
storagelist)
Fix most of : [Error]: WFIFOSET: Maximum write buffer size for client
connection 7 exceeded, most likely caused by packet 0x0996 (len=11932,
ip=127.0.140733193388032.1). Still remain some if you openup the list
like 5time/s, see tid:90541
lighta 11 anos atrás
pai
commit
4212080bd9
7 arquivos alterados com 48 adições e 71 exclusões
  1. 2 2
      conf/msg_conf/map_msg.conf
  2. 3 2
      src/char/char.c
  3. 2 29
      src/common/mmo.h
  4. 5 2
      src/config/core.h
  5. 5 4
      src/map/atcommand.c
  6. 5 3
      src/map/chrif.c
  7. 26 29
      src/map/clif.c

+ 2 - 2
conf/msg_conf/map_msg.conf

@@ -1528,8 +1528,8 @@
 
 // @dropall
 1492: Usage: @dropall {<type>}
-1493: Type List: (default) all = -1, healing = 0, usable = 2, etc = 3, armor = 4, weapon = 5, card = 6, petegg = 7, petarmor = 8, ammo = 10
-1494: %d items are dropped!
+1493: Type List: (default) all = -1, healing = 0, usable = 2, etc = 3, weapon = 4, armor = 5, card = 6, petegg = 7, petarmor = 8, ammo = 10
+1494: %d items are dropped (%d skipped)!
 
 //Banking
 1495: You can't withdraw that much money

+ 3 - 2
src/char/char.c

@@ -3811,11 +3811,12 @@ int parse_frommap(int fd)
 				node->sex == sex /*&&
 				node->ip == ip*/ )
 			{// auth ok
+				uint32 mmo_charstatus_len = sizeof(struct mmo_charstatus) + 25;
 				cd->sex = sex;
 
-				WFIFOHEAD(fd,25 + sizeof(struct mmo_charstatus));
+				WFIFOHEAD(fd,mmo_charstatus_len);
 				WFIFOW(fd,0) = 0x2afd;
-				WFIFOW(fd,2) = 25 + sizeof(struct mmo_charstatus);
+				WFIFOW(fd,2) = mmo_charstatus_len;
 				WFIFOL(fd,4) = account_id;
 				WFIFOL(fd,8) = node->login_id1;
 				WFIFOL(fd,12) = node->login_id2;

+ 2 - 29
src/common/mmo.h

@@ -17,34 +17,7 @@
 //        5 - 2003-12-18aSakexe+   - 0x1ee, 0x1ef, 0x1f0, ?0x1c4, 0x1c5?
 //        6 - 2004-03-02aSakexe+   - 0x1f4, 0x1f5
 //        7 - 2005-04-11aSakexe+   - 0x229, 0x22a, 0x22b, 0x22c
-// 20061023 - 2006-10-23aSakexe+   - 0x6b, 0x6d
-// 20070521 - 2007-05-21aSakexe+   - 0x283
-// 20070821 - 2007-08-21aSakexe+   - 0x2c5
-// 20070918 - 2007-09-18aSakexe+   - 0x2d7, 0x2d9, 0x2da
-// 20071106 - 2007-11-06aSakexe+   - 0x78, 0x7c, 0x22c
-// 20080102 - 2008-01-02aSakexe+   - 0x2ec, 0x2ed , 0x2ee
-// 20081126 - 2008-11-26aSakexe+   - 0x1a2
-// 20090408 - 2009-04-08aSakexe+   - 0x44a (dont use as it overlaps with RE client packets)
-// 20080827 - 2008-08-27aRagexeRE+ - First RE Client
-// 20081217 - 2008-12-17aRagexeRE+ - 0x6d (Note: This one still use old Char Info Packet Structure)
-// 20081218 - 2008-12-17bRagexeRE+ - 0x6d (Note: From this one client use new Char Info Packet Structure)
-// 20090603 - 2009-06-03aRagexeRE+ - 0x7d7, 0x7d8, 0x7d9, 0x7da
-// 20090617 - 2009-06-17aRagexeRE+ - 0x7d9
-// 20090922 - 2009-09-22aRagexeRE+ - 0x7e5, 0x7e7, 0x7e8, 0x7e9
-// 20091103 - 2009-11-03aRagexeRE+ - 0x7f7, 0x7f8, 0x7f9
-// 20100105 - 2010-01-05aRagexeRE+ - 0x133, 0x800, 0x801
-// 20100126 - 2010-01-26aRagexeRE+ - 0x80e
-// 20100223 - 2010-02-23aRagexeRE+ - 0x80f
-// 20100413 - 2010-04-13aRagexeRE+ - 0x6b
-// 20100629 - 2010-06-29aRagexeRE+ - 0x2d0, 0xaa, 0x2d1, 0x2d2
-// 20100721 - 2010-07-21aRagexeRE+ - 0x6b, 0x6d
-// 20100727 - 2010-07-27aRagexeRE+ - 0x6b, 0x6d
-// 20100803 - 2010-08-03aRagexeRE+ - 0x6b, 0x6d, 0x827, 0x828, 0x829, 0x82a, 0x82b, 0x82c, 0x842, 0x843
-// 20101124 - 2010-11-24aRagexeRE+ - 0x856, 0x857, 0x858
-// 20110111 - 2011-01-11aRagexeRE+ - 0x6b, 0x6d
-// 20110928 - 2011-09-28aRagexeRE+ - 0x6b, 0x6d
-// 20111025 - 2011-10-25aRagexeRE+ - 0x6b, 0x6d
-// 20120307 - 2012-03-07aRagexeRE+ - 0x970
+// see conf/battle/client.conf for other version
 
 #ifndef PACKETVER
 	#define PACKETVER 20130807
@@ -91,7 +64,7 @@
 #define DEFAULT_WALK_SPEED 150
 #define MIN_WALK_SPEED 0
 #define MAX_WALK_SPEED 1000
-#define MAX_STORAGE 600 /// Max number of storage slots the client can support. Used as a cap for the VIP System.
+#define MAX_STORAGE 600 /// Max number of storage slots a player can have, (up to ~850 tested)
 #define MAX_GUILD_STORAGE 600
 #define MAX_PARTY 12
 #define MAX_GUILD 16+10*6	// increased max guild members +6 per 1 extension levels [Lupus]

+ 5 - 2
src/config/core.h

@@ -87,14 +87,17 @@
 	#define MAX_CHAR_VIP 6 // This must be less than MAX_CHARS
 	#define MAX_CHAR_BILLING 0 // This must be less than MAX_CHARS
 #else
-	#define MIN_STORAGE 600 // If the VIP system is disabled the min = max.
-	#define MIN_CHARS 9 // Default number of characters per account.
+	#define MIN_STORAGE MAX_STORAGE // If the VIP system is disabled the min = max.
+	#define MIN_CHARS MAX_CHARS // Default number of characters per account.
 	#define MAX_CHAR_BILLING 0
 	#define MAX_CHAR_VIP 0
 #endif
 #if (MIN_CHARS + MAX_CHAR_VIP + MAX_CHAR_BILLING) > MAX_CHARS
 	#error "Config of MAX_CHARS is invalid"
 #endif
+#if MIN_STORAGE > MAX_STORAGE
+	#error "Config of MIN_STORAGE is invalid"
+#endif
 
 /**
  * No settings past this point

+ 5 - 4
src/map/atcommand.c

@@ -5185,7 +5185,7 @@ ACMD_FUNC(follow)
 ACMD_FUNC(dropall)
 {
 	int8 type = -1;
-	uint16 i, count = 0;
+	uint16 i, count = 0, count2 = 0;
 	struct item_data *item_data = NULL;
 
 	nullpo_retr(-1, sd);
@@ -5213,12 +5213,13 @@ ACMD_FUNC(dropall)
 			if( type == -1 || type == (uint8)item_data->type ) {
 				if( sd->status.inventory[i].equip != 0 )
 					pc_unequipitem(sd, i, 3);
-				count += sd->status.inventory[i].amount;
-				pc_dropitem(sd, i, sd->status.inventory[i].amount);
+				if(pc_dropitem(sd, i, sd->status.inventory[i].amount))
+					count += sd->status.inventory[i].amount;
+				else count2 += sd->status.inventory[i].amount;
 			}
 		}
 	}
-	sprintf(atcmd_output, msg_txt(sd,1494), count); // %d items are dropped!
+	sprintf(atcmd_output, msg_txt(sd,1494), count,count2); // %d items are dropped (%d skipped)!
 	clif_displaymessage(fd, atcmd_output); 
 	return 0;
 }

+ 5 - 3
src/map/chrif.c

@@ -279,6 +279,7 @@ int chrif_isconnected(void) {
  * Flag = 2: Character is changing map-servers
  *------------------------------------------*/
 int chrif_save(struct map_session_data *sd, int flag) {
+	uint32 mmo_charstatus_len = 0;
 	nullpo_retr(-1, sd);
 
 	pc_makesavestatus(sd);
@@ -312,9 +313,10 @@ int chrif_save(struct map_session_data *sd, int flag) {
 	if (sd->state.reg_dirty&1)
 		intif_saveregistry(sd, 1); //Save account2 regs
 
-	WFIFOHEAD(char_fd, sizeof(sd->status) + 13);
+	mmo_charstatus_len = sizeof(sd->status) + 13;
+	WFIFOHEAD(char_fd, mmo_charstatus_len);
 	WFIFOW(char_fd,0) = 0x2b01;
-	WFIFOW(char_fd,2) = sizeof(sd->status) + 13;
+	WFIFOW(char_fd,2) = mmo_charstatus_len;
 	WFIFOL(char_fd,4) = sd->status.account_id;
 	WFIFOL(char_fd,8) = sd->status.char_id;
 	WFIFOB(char_fd,12) = (flag==1)?1:0; //Flag to tell char-server this character is quitting.
@@ -1903,7 +1905,7 @@ int do_final_chrif(void) {
  *------------------------------------------*/
 int do_init_chrif(void) {
 	if(sizeof(struct mmo_charstatus) > 0xFFFF){
-		ShowError("mmo_charstatus size = %d is too big to be transmitted.\n",
+		ShowError("mmo_charstatus size = %d is too big to be transmitted. (must be below 0xFFFF) \n",
 			sizeof(struct mmo_charstatus));
 		exit(EXIT_FAILURE);
 	}

+ 26 - 29
src/map/clif.c

@@ -2519,32 +2519,39 @@ void clif_storagelist(struct map_session_data* sd, struct item* items, int items
 	int i,n,ne,nn;
 	unsigned char *buf;
 	unsigned char *bufe;
-	unsigned char *bufn;
 #if PACKETVER < 5
 	const int s = 10; //Entry size.normal item
 	const int sidx=4; //start itemlist idx
+	const int cmd = 0xa5;
 #elif PACKETVER < 20080102
 	const int s = 18;
 	const int sidx=4;
+	const int cmd = 0x1f0;
 #elif PACKETVER < 20120925
 	const int s = 22;
 	const int sidx=4;
+	const int cmd = 0x2ea;
 #else
 	const int s = 24;
 	const int sidx = 4+24;
+	const int cmd = 0x995;
 #endif
 #if PACKETVER < 20071002
 	const int se = 20; //entry size equip
 	const int sidxe = 4; //start itemlist idx
+	const int cmde = 0xa6;
 #elif PACKETVER < 20100629
 	const int se = 26;
 	const int sidxe = 4;
+	const int cmde = 0xa6;
 #elif PACKETVER < 20120925
 	const int se = 28;
 	const int sidxe = 4;
+	const int cmde = 0x2d1;
 #else
 	const int se = 31;
 	const int sidxe = 4+24;
+	const int cmde = 0x996;
 #endif
 
 	buf = (unsigned char*)aMalloc(items_length * s + sidx);
@@ -2564,39 +2571,29 @@ void clif_storagelist(struct map_session_data* sd, struct item* items, int items
 			n++;
 		}
 	}
-	for (i = 0; i < n;) // Loop through non-equipable items
+	for (i = 0; i < n; i += nn) // Loop through non-equipable items
 	{
-		nn = n - i < (client_buf - 4)/s ? n - i : (client_buf - 4)/s; // Split up non-equipable items
-		bufn = buf + i*s; // Update buffer to new index range
-		i += nn;
-#if PACKETVER < 5
-		WBUFW(bufn,0)=0xa5;
-#elif PACKETVER < 20080102
-		WBUFW(bufn,0)=0x1f0;
-#elif PACKETVER < 20120925
-		WBUFW(bufn,0)=0x2ea;
-#else
-		WBUFW(bufn,0)=0x995;
-		memset((char*)WBUFP(buf,4),0,24); //storename
+		nn = n - i < (client_buf - sidx)/s ? n - i : (client_buf - sidx)/s; // Split up non-equipable items
+		WFIFOHEAD(sd->fd,sidx+nn*s);
+		WFIFOW(sd->fd,0)=cmd;
+		WFIFOW(sd->fd,2)=sidx+nn*s;
+#if PACKETVER >= 20120925
+		memset((char*)WFIFOP(sd->fd,4),0,24); //storename
 #endif
-		WBUFW(bufn,2)=sidx+nn*s;
-		clif_send(bufn, WBUFW(bufn,2), &sd->bl, SELF);
+		memcpy(WFIFOP(sd->fd,sidx),buf + sidx + i*s,nn*s);
+		WFIFOSET(sd->fd,WFIFOW(sd->fd,2));
 	}
-	for (i = 0; i < ne;) // Loop through equipable items
+	for (i = 0; i < ne; i += nn) // Loop through equipable items
 	{
-		nn = ne - i < (client_buf - 4)/se ? ne - i : (client_buf - 4)/se; // Split up equipable items
-		bufn = bufe + i*se; // Update buffer to new index range
-		i += nn;
-#if PACKETVER < 20071002
-		WBUFW(bufn,0)=0xa6;
-#elif PACKETVER < 20120925
-		WBUFW(bufn,0)=0x2d1;
-#else
-		WBUFW(bufn,0)=0x996;
-		memset((char*)WBUFP(bufn,4),0,24); //storename
+		nn = ne - i < (client_buf - sidxe)/se ? ne - i : (client_buf - sidxe)/se; // Split up equipable items
+		WFIFOHEAD(sd->fd,sidxe+nn*se);
+		WFIFOW(sd->fd,0)=cmde;
+		WFIFOW(sd->fd,2)=sidxe+nn*se;
+#if PACKETVER >= 20120925
+		memset((char*)WFIFOP(sd->fd,4),0,24); //storename
 #endif
-		WBUFW(bufn,2)=sidxe+nn*se;
-		clif_send(bufn, WBUFW(bufn,2), &sd->bl, SELF);
+		memcpy(WFIFOP(sd->fd,sidxe),bufe + sidxe + i*se,nn*se);
+		WFIFOSET(sd->fd,WFIFOW(sd->fd,2));
 	}
 
 	if( buf ) aFree(buf);