Prechádzať zdrojové kódy

- Some fixes to mail system.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@12199 54d463be-8e91-2dee-dedb-b68131a5f0ec
zephyrus 17 rokov pred
rodič
commit
8b151df5c7
4 zmenil súbory, kde vykonal 30 pridanie a 13 odobranie
  1. 3 0
      Changelog-Trunk.txt
  2. 21 4
      src/map/clif.c
  3. 1 1
      src/map/clif.h
  4. 5 8
      src/map/mail.c

+ 3 - 0
Changelog-Trunk.txt

@@ -6,6 +6,9 @@ IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 2008/02/13
 	* Merged memory manager updates from old jA revisions (bugreport:663)
 	- less overhead and better overflow detection (caution, experimental!)
+	* Added some security checks in mail system [Zephyrus]
+	- This supose to fix a bug reported in 622 to limit to MAX_ZENY.
+	- Also add more checks to free space in your inventory to receive items.
 2008/02/11
 	* 'Forget me Not' no longer blocks ASPD bonuses from working or prevents
 	  their re-casting, they are simply dispelled when the effect takes place.

+ 21 - 4
src/map/clif.c

@@ -11295,13 +11295,14 @@ void clif_Mail_new(int fd, int mail_id, const char *sender, const char *title)
 }
 
 /*------------------------------------------
- * Opens Mail Window on Client
+ * Handles Mail Window on Client
+ * flag : 0 open | 1 close
  *------------------------------------------*/
-void clif_Mail_openmail(int fd)
+void clif_Mail_window(int fd, int flag)
 {
 	WFIFOHEAD(fd,packet_len(0x260));
 	WFIFOW(fd,0) = 0x260;
-	WFIFOL(fd,2) = 0;
+	WFIFOL(fd,2) = flag;
 	WFIFOSET(fd,packet_len(0x260));
 }
 
@@ -11429,6 +11430,7 @@ void clif_parse_Mail_read(int fd, struct map_session_data *sd)
 void clif_parse_Mail_getattach(int fd, struct map_session_data *sd)
 {
 	int i, mail_id = RFIFOL(fd,2);
+	bool fail = false;
 
 	ARR_FIND(0, MAIL_MAX_INBOX, i, sd->mail.inbox.msg[i].id == mail_id);
 	if( i == MAIL_MAX_INBOX )
@@ -11445,8 +11447,23 @@ void clif_parse_Mail_getattach(int fd, struct map_session_data *sd)
 		if ((data = itemdb_search(sd->mail.inbox.msg[i].item.nameid)) == NULL)
 			return;
 
+		switch( pc_checkadditem(sd, data->nameid, sd->mail.inbox.msg[i].item.amount) )
+		{
+			case ADDITEM_NEW:
+				fail = ( pc_inventoryblank(sd) == 0 );
+				break;
+			case ADDITEM_OVERAMOUNT:
+				fail = true;
+		}
+
+		if( fail )
+		{
+			clif_Mail_getattachment(fd, 1);
+			return;
+		}
+
 		weight = data->weight * sd->mail.inbox.msg[i].item.amount;
-		if (weight > sd->max_weight - sd->weight)
+		if( weight > sd->max_weight - sd->weight )
 		{
 			clif_Mail_getattachment(fd, 2);
 			return;

+ 1 - 1
src/map/clif.h

@@ -394,7 +394,7 @@ int do_init_clif(void);
 
 #ifndef TXT_ONLY
 // MAIL SYSTEM
-void clif_Mail_openmail(int fd);
+void clif_Mail_window(int fd, int flag);
 void clif_Mail_read(struct map_session_data *sd, int mail_id);
 void clif_Mail_delete(int fd, int mail_id, short fail);
 void clif_Mail_return(int fd, int mail_id, short fail);

+ 5 - 8
src/map/mail.c

@@ -135,12 +135,6 @@ bool mail_setattachment(struct map_session_data *sd, struct mail_message *msg)
 
 void mail_getattachment(struct map_session_data* sd, int zeny, struct item* item)
 {
-	if( zeny > 0 )
-	{
-		sd->status.zeny += zeny;
-		clif_updatestatus(sd, SP_ZENY);
-	}
-
 	if( item->nameid > 0 && item->amount > 0 )
 	{
 		pc_additem(sd, item, item->amount);
@@ -150,6 +144,9 @@ void mail_getattachment(struct map_session_data* sd, int zeny, struct item* item
 
 		clif_Mail_getattachment(sd->fd, 0);
 	}
+
+	if( zeny > 0 )
+		pc_getzeny(sd, zeny);
 }
 
 int mail_openmail(struct map_session_data *sd)
@@ -159,9 +156,9 @@ int mail_openmail(struct map_session_data *sd)
 	if( sd->state.finalsave == 1 || sd->state.storage_flag || sd->vender_id || sd->state.trading )
 		return 0;
 
-	clif_Mail_openmail(sd->fd);	
+	clif_Mail_window(sd->fd, 0);
 
-	return 0;
+	return 1;
 }
 
 void mail_deliveryfail(struct map_session_data *sd, struct mail_message *msg)