summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorGuilherme G. Menaldo <guilherme.menaldo@outlook.com>2018-02-26 17:34:24 -0300
committerGuilherme G. Menaldo <guilherme.menaldo@outlook.com>2018-03-08 23:13:33 -0300
commit5b4f79ade2152da83e3c5df610efd54714acaa1f (patch)
tree32cd3de55be344f2f279b33611980f19fc3ad035 /src/map
parent60870581e1e2dd740751c1104299536975015b9e (diff)
downloadhercules-5b4f79ade2152da83e3c5df610efd54714acaa1f.tar.gz
hercules-5b4f79ade2152da83e3c5df610efd54714acaa1f.tar.bz2
hercules-5b4f79ade2152da83e3c5df610efd54714acaa1f.tar.xz
hercules-5b4f79ade2152da83e3c5df610efd54714acaa1f.zip
Fixed RoDEX mail return not working correctly
Diffstat (limited to 'src/map')
-rw-r--r--src/map/clif.c6
-rw-r--r--src/map/intif.c3
-rw-r--r--src/map/rodex.c24
3 files changed, 25 insertions, 8 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 7c314b075..6b444553f 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -19720,7 +19720,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;
@@ -19779,7 +19779,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);
@@ -19846,7 +19846,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/intif.c b/src/map/intif.c
index 0e5cd3db2..b8a0be37c 100644
--- a/src/map/intif.c
+++ b/src/map/intif.c
@@ -2599,10 +2599,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..e6bf7d216 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);