diff options
author | Haru <haru@dotalux.com> | 2018-03-11 15:38:44 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-11 15:38:44 +0100 |
commit | f7ca209c044d4c08e932beac8580ddc2c2d7a924 (patch) | |
tree | ba45501645cde4e56a20ca0674232d58f132c189 /src/map | |
parent | c46b6d59644675c7c037238afb609f42230a9977 (diff) | |
parent | 442162e0baf6d085ffde26fb7fafd9877338f868 (diff) | |
download | hercules-f7ca209c044d4c08e932beac8580ddc2c2d7a924.tar.gz hercules-f7ca209c044d4c08e932beac8580ddc2c2d7a924.tar.bz2 hercules-f7ca209c044d4c08e932beac8580ddc2c2d7a924.tar.xz hercules-f7ca209c044d4c08e932beac8580ddc2c2d7a924.zip |
Merge pull request #1987 from guilherme-gm/rodexfixes
Some rodex fixes
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/clif.c | 20 | ||||
-rw-r--r-- | src/map/clif.h | 2 | ||||
-rw-r--r-- | src/map/intif.c | 14 | ||||
-rw-r--r-- | src/map/rodex.c | 27 |
4 files changed, 46 insertions, 17 deletions
diff --git a/src/map/clif.c b/src/map/clif.c index d2dc12377..546247c3c 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -19831,7 +19831,7 @@ void clif_rodex_send_maillist(int fd, struct map_session_data *sd, int8 open_typ continue; inner->MailID = msg->id; - inner->Isread = msg->is_read == true ? 1 : 0; + inner->Isread = (msg->is_read == true || msg->sender_read == true) ? 1 : 0; inner->type = msg->type; #if PACKETVER >= 20170419 inner->openType = msg->opentype; @@ -19863,7 +19863,7 @@ void clif_rodex_send_maillist(int fd, struct map_session_data *sd, int8 open_typ #endif } -void clif_rodex_send_mails_all(int fd, struct map_session_data *sd) +void clif_rodex_send_mails_all(int fd, struct map_session_data *sd, int64 mail_id) { #if PACKETVER >= 20170419 struct PACKET_ZC_MAIL_LIST *packet; @@ -19871,18 +19871,24 @@ void clif_rodex_send_mails_all(int fd, struct map_session_data *sd) int16 size = sizeof(*packet); int packetMailCount = 0; int mailListCount = 0; - int mailsSize = VECTOR_LENGTH(sd->rodex.messages); - int i; + int mailsSize, i; + int j = -1; nullpo_retv(sd); + mailsSize = VECTOR_LENGTH(sd->rodex.messages); + + if (mail_id > 0) + ARR_FIND(0, VECTOR_LENGTH(sd->rodex.messages), j, (VECTOR_INDEX(sd->rodex.messages, j)).id == mail_id); + WFIFOHEAD(fd, sizeof(*packet) + (sizeof(*inner) + RODEX_TITLE_LENGTH) * RODEX_MAIL_PER_PAGE); packet = WFIFOP(fd, 0); packet->PacketType = rodexmailList; inner = WFIFOP(fd, size); i = mailsSize - 1; - while (i >= 0) { + mailsSize -= (j + 1); + while (i > j) { struct rodex_message *msg = &VECTOR_INDEX(sd->rodex.messages, i); --i; @@ -19890,7 +19896,7 @@ void clif_rodex_send_mails_all(int fd, struct map_session_data *sd) continue; inner->MailID = msg->id; - inner->Isread = msg->is_read == true ? 1 : 0; + inner->Isread = (msg->is_read == true || msg->sender_read == true) ? 1 : 0; inner->type = msg->type; inner->openType = msg->opentype; inner->expireDateTime = msg->expire_date - (int)time(NULL); @@ -19957,7 +19963,7 @@ void clif_rodex_send_refresh(int fd, struct map_session_data *sd, int8 open_type continue; inner->MailID = msg->id; - inner->Isread = msg->is_read == true ? 1 : 0; + inner->Isread = (msg->is_read == true || msg->sender_read == true) ? 1 : 0; inner->type = msg->type; #if PACKETVER >= 20170419 inner->openType = msg->opentype; diff --git a/src/map/clif.h b/src/map/clif.h index 0711546df..acf79c373 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -1389,7 +1389,7 @@ struct clif_interface { void (*rodex_send_mail_result) (int fd, struct map_session_data *sd, int8 result); void (*rodex_send_maillist) (int fd, struct map_session_data *sd, int8 open_type, int64 page_start); void (*rodex_send_refresh) (int fd, struct map_session_data *sd, int8 open_type, int count); - void (*rodex_send_mails_all) (int fd, struct map_session_data *sd); + void (*rodex_send_mails_all) (int fd, struct map_session_data *sd, int64 mail_id); void (*pRodexReadMail) (int fd, struct map_session_data *sd); void (*rodex_read_mail) (struct map_session_data *sd, int8 opentype, struct rodex_message *msg); void (*pRodexNextMaillist) (int fd, struct map_session_data *sd); diff --git a/src/map/intif.c b/src/map/intif.c index 0e5cd3db2..f656a0df9 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -2516,6 +2516,9 @@ void intif_parse_RequestRodexOpenInbox(int fd) int8 is_end = RFIFOB(fd, 10); int is_first = RFIFOB(fd, 11); int count = RFIFOL(fd, 12); +#if PACKETVER >= 20170419 + int64 mail_id = RFIFOQ(fd, 16); +#endif int i, j; sd = map->charid2sd(RFIFOL(fd, 4)); @@ -2533,15 +2536,15 @@ void intif_parse_RequestRodexOpenInbox(int fd) else sd->rodex.total += count; - if (RFIFOW(fd, 2) - 16 != count * sizeof(struct rodex_message)) { - ShowError("intif_parse_RodexInboxOpenReceived: data size mismatch %d != %"PRIuS"\n", RFIFOW(fd, 2) - 16, count * sizeof(struct rodex_message)); + if (RFIFOW(fd, 2) - 24 != count * sizeof(struct rodex_message)) { + ShowError("intif_parse_RodexInboxOpenReceived: data size mismatch %d != %"PRIuS"\n", RFIFOW(fd, 2) - 24, count * sizeof(struct rodex_message)); return; } if (flag == 0 && is_first) VECTOR_CLEAR(sd->rodex.messages); - for (i = 0, j = 16; i < count; ++i, j += sizeof(struct rodex_message)) { + for (i = 0, j = 24; i < count; ++i, j += sizeof(struct rodex_message)) { struct rodex_message msg = { 0 }; VECTOR_ENSURE(sd->rodex.messages, 1, 1); memcpy(&msg, RFIFOP(fd, j), sizeof(struct rodex_message)); @@ -2550,7 +2553,7 @@ void intif_parse_RequestRodexOpenInbox(int fd) if (is_end == true) { #if PACKETVER >= 20170419 - clif->rodex_send_mails_all(sd->fd, sd); + clif->rodex_send_mails_all(sd->fd, sd, mail_id); #else if (flag == 0) clif->rodex_send_maillist(sd->fd, sd, opentype, VECTOR_LENGTH(sd->rodex.messages) - 1); @@ -2599,10 +2602,11 @@ void intif_parse_RodexNotifications(int fd) /// Updates a mail /// flag: -/// 0 - user Read +/// 0 - receiver Read /// 1 - user got Zeny /// 2 - user got Items /// 3 - delete +/// 4 - sender Read (returned mail) int intif_rodex_updatemail(int64 mail_id, int8 flag) { if (intif->CheckForCharServer()) diff --git a/src/map/rodex.c b/src/map/rodex.c index d5a6064cf..8626f76e1 100644 --- a/src/map/rodex.c +++ b/src/map/rodex.c @@ -364,15 +364,24 @@ struct rodex_message *rodex_get_mail(struct map_session_data *sd, int64 mail_id) { int i; struct rodex_message *msg; + int char_id; nullpo_retr(NULL, sd); - ARR_FIND(0, VECTOR_LENGTH(sd->rodex.messages), i, VECTOR_INDEX(sd->rodex.messages, i).id == mail_id && VECTOR_INDEX(sd->rodex.messages, i).is_deleted != true); + ARR_FIND(0, VECTOR_LENGTH(sd->rodex.messages), i, VECTOR_INDEX(sd->rodex.messages, i).id == mail_id); if (i == VECTOR_LENGTH(sd->rodex.messages)) return NULL; msg = &VECTOR_INDEX(sd->rodex.messages, i); + char_id = sd->status.char_id; + + if ((msg->is_deleted == true) + || (msg->expire_date < time(NULL) && ((msg->receiver_accountid > 0) || (msg->receiver_id == char_id && msg->sender_id != char_id))) + || ((msg->send_date + 2 * RODEX_EXPIRE) < time(NULL)) + ) + return NULL; + return msg; } @@ -388,9 +397,16 @@ void rodex_read_mail(struct map_session_data *sd, int64 mail_id) msg = rodex->get_mail(sd, mail_id); nullpo_retv(msg); - if (msg->is_read == false) { - intif->rodex_updatemail(msg->id, 0); - msg->is_read = true; + if (msg->opentype == RODEX_OPENTYPE_RETURN) { + if (msg->sender_read == false) { + intif->rodex_updatemail(msg->id, 4); + msg->sender_read = true; + } + } else { + if (msg->is_read == false) { + intif->rodex_updatemail(msg->id, 0); + msg->is_read = true; + } } clif->rodex_read_mail(sd, msg->opentype, msg); @@ -440,6 +456,7 @@ void rodex_get_zeny(struct map_session_data *sd, int8 opentype, int64 mail_id) return; } + msg->type &= ~MAIL_TYPE_ZENY; msg->zeny = 0; intif->rodex_updatemail(mail_id, 1); @@ -523,6 +540,8 @@ void rodex_get_items(struct map_session_data *sd, int8 opentype, int64 mail_id) } } + msg->type &= ~MAIL_TYPE_ITEM; + msg->items_count = 0; intif->rodex_updatemail(mail_id, 2); clif->rodex_request_items(sd, opentype, mail_id, RODEX_GET_ITEMS_SUCCESS); |