Bladeren bron

Moved the 'changed' mailbox flag from shared mmo.h to mapserver-only.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@13433 54d463be-8e91-2dee-dedb-b68131a5f0ec
ultramage 16 jaren geleden
bovenliggende
commit
578532f577
5 gewijzigde bestanden met toevoegingen van 12 en 7 verwijderingen
  1. 0 1
      src/char_sql/int_mail.c
  2. 1 1
      src/common/mmo.h
  3. 1 1
      src/map/clif.c
  4. 9 4
      src/map/intif.c
  5. 1 0
      src/map/pc.h

+ 0 - 1
src/char_sql/int_mail.c

@@ -73,7 +73,6 @@ static int mail_fromsql(int char_id, struct mail_data* md)
 	md->full = ( Sql_NumRows(sql_handle) > MAIL_MAX_INBOX );
 
 	md->amount = i;
-	md->changed = false;
 	Sql_FreeResult(sql_handle);
 
 	md->unchecked = 0;

+ 1 - 1
src/common/mmo.h

@@ -332,7 +332,7 @@ struct mail_message {
 
 struct mail_data {
 	short amount;
-	bool changed, full;
+	bool full;
 	short unchecked, unread;
 	struct mail_message msg[MAIL_MAX_INBOX];
 };

+ 1 - 1
src/map/clif.c

@@ -11613,7 +11613,7 @@ void clif_parse_Mail_refreshinbox(int fd, struct map_session_data *sd)
 {
 	struct mail_data* md = &sd->mail.inbox;
 
-	if( md->amount < MAIL_MAX_INBOX && (md->full || md->changed) )
+	if( md->amount < MAIL_MAX_INBOX && (md->full || sd->mail.changed) )
 		intif_Mail_requestinbox(sd->status.char_id, 1);
 	else
 		clif_Mail_refreshinbox(sd);

+ 9 - 4
src/map/intif.c

@@ -1438,6 +1438,7 @@ int intif_parse_Mail_inboxreceived(int fd)
 
 	//FIXME: this operation is not safe [ultramage]
 	memcpy(&sd->mail.inbox, RFIFOP(fd,9), sizeof(struct mail_data));
+	sd->mail.changed = false; // cache is now in sync
 
 	if (flag)
 		clif_Mail_refreshinbox(sd);
@@ -1634,7 +1635,9 @@ static void intif_parse_Mail_send(int fd)
 	memcpy(&msg, RFIFOP(fd,4), sizeof(struct mail_message));
 	fail = (msg.id == 0);
 
-	if( (sd = map_charid2sd(msg.send_id)) )
+	// notify sender
+	sd = map_charid2sd(msg.send_id);
+	if( sd != NULL )
 	{
 		if( fail )
 			mail_deliveryfail(sd, &msg);
@@ -1649,9 +1652,11 @@ static void intif_parse_Mail_send(int fd)
 	if( fail )
 		return;
 
-	if( (sd = map_charid2sd(msg.dest_id)) )
+	// notify recipient (if online)
+	sd = map_charid2sd(msg.dest_id);
+	if( sd != NULL )
 	{
-		sd->mail.inbox.changed = true;
+		sd->mail.changed = true;
 		clif_Mail_new(sd->fd, msg.id, msg.send_name, msg.title);
 	}
 }
@@ -1666,7 +1671,7 @@ static void intif_parse_Mail_new(int fd)
 	if( sd == NULL )
 		return;
 
-	sd->mail.inbox.changed = true;
+	sd->mail.changed = true;
 	clif_Mail_new(sd->fd, mail_id, sender_name, title);
 }
 

+ 1 - 0
src/map/pc.h

@@ -352,6 +352,7 @@ struct map_session_data {
 		short nameid;
 		int index, amount, zeny;
 		struct mail_data inbox;
+		bool changed; // if true, should sync with charserver on next mailbox request
 	} mail;
 
 	//Quest log system [Kevin]