瀏覽代碼

Follow up to f77cb8a

Added a check for required inventory slots.
Additionally fixed some checks that have been wrong for years.
Lemongrass3110 4 年之前
父節點
當前提交
55ca79961d
共有 4 個文件被更改,包括 13 次插入5 次删除
  1. 5 3
      src/map/clif.cpp
  2. 6 2
      src/map/mail.cpp
  3. 1 0
      src/map/pc.cpp
  4. 1 0
      src/map/pc.hpp

+ 5 - 3
src/map/clif.cpp

@@ -16104,7 +16104,7 @@ void clif_parse_Mail_getattach( int fd, struct map_session_data *sd ){
 	}
 
 	if( attachment&MAIL_ATT_ITEM ){
-		int new_ = 0, totalweight = 0;
+		int slots = 0, totalweight = 0;
 
 		for( i = 0; i < MAIL_MAX_ITEM; i++ ){
 			struct item* item = &msg->item[i];
@@ -16117,7 +16117,7 @@ void clif_parse_Mail_getattach( int fd, struct map_session_data *sd ){
 
 				switch( pc_checkadditem(sd, item->nameid, item->amount) ){
 					case CHKADDITEM_NEW:
-						new_++;
+						slots += data->inventorySlotNeeded( item->amount );
 						break;
 					case CHKADDITEM_OVERAMOUNT:
 						clif_mail_getattachment(sd, msg, 2, MAIL_ATT_ITEM);
@@ -16131,7 +16131,7 @@ void clif_parse_Mail_getattach( int fd, struct map_session_data *sd ){
 		if( ( totalweight + sd->weight + sd->mail.pending_weight ) > sd->max_weight ){
 			clif_mail_getattachment(sd, msg, 2, MAIL_ATT_ITEM);
 			return;
-		}else if( pc_inventoryblank(sd) < new_ ){
+		}else if( pc_inventoryblank(sd) < ( slots + sd->mail.pending_slots ) ){
 			clif_mail_getattachment(sd, msg, 2, MAIL_ATT_ITEM);
 			return;
 		}
@@ -16141,6 +16141,8 @@ void clif_parse_Mail_getattach( int fd, struct map_session_data *sd ){
 
 		// Store the pending weight (required for the "retrieve all" feature)
 		sd->mail.pending_weight += totalweight;
+		// Store the pending slots (required for the "retrieve all" feature)
+		sd->mail.pending_slots += slots;
 	}
 
 	intif_mail_getattach(sd,msg, (enum mail_attachment_type)attachment);

+ 6 - 2
src/map/mail.cpp

@@ -289,7 +289,7 @@ void mail_getattachment(struct map_session_data* sd, struct mail_message* msg, i
 	bool item_received = false;
 
 	for( i = 0; i < MAIL_MAX_ITEM; i++ ){
-		if( item->nameid > 0 && item->amount > 0 ){
+		if( item[i].nameid > 0 && item[i].amount > 0 ){
 			struct item_data* id = itemdb_search( item->nameid );
 
 			// Item does not exist (anymore?)
@@ -307,6 +307,7 @@ void mail_getattachment(struct map_session_data* sd, struct mail_message* msg, i
 			if( pet != nullptr && item[i].card[0] == 0 ){
 				// Create a new pet
 				if( pet_create_egg( sd, item[i].nameid ) ){
+					sd->mail.pending_slots--;
 					item_received = true;
 				}else{
 					// Do not send receive packet so that the mail is still displayed with item attachment
@@ -315,9 +316,12 @@ void mail_getattachment(struct map_session_data* sd, struct mail_message* msg, i
 					break;
 				}
 			}else{
+				int slots = id->inventorySlotNeeded( item[i].amount );
+
 				// Add the item normally
 				if( pc_additem( sd, &item[i], item[i].amount, LOG_TYPE_MAIL ) == ADDITEM_SUCCESS ){
 					item_received = true;
+					sd->mail.pending_slots -= slots;
 				}else{
 					// Do not send receive packet so that the mail is still displayed with item attachment
 					item_received = false;
@@ -327,7 +331,7 @@ void mail_getattachment(struct map_session_data* sd, struct mail_message* msg, i
 			}
 
 			// Make sure no requests are possible anymore
-			item->amount = 0;
+			item[i].amount = 0;
 		}	
 	}
 

+ 1 - 0
src/map/pc.cpp

@@ -1685,6 +1685,7 @@ bool pc_authok(struct map_session_data *sd, uint32 login_id2, time_t expiration_
 	sd->count_rewarp = 0;
 	sd->mail.pending_weight = 0;
 	sd->mail.pending_zeny = 0;
+	sd->mail.pending_slots = 0;
 
 	sd->regs.vars = i64db_alloc(DB_OPT_BASE);
 	sd->regs.arrays = NULL;

+ 1 - 0
src/map/pc.hpp

@@ -664,6 +664,7 @@ struct map_session_data {
 		bool changed; // if true, should sync with charserver on next mailbox request
 		uint32 pending_weight;
 		uint32 pending_zeny;
+		uint16 pending_slots;
 	} mail;
 
 	//Quest log system