summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gui/mailmessage.h4
-rw-r--r--src/gui/windows/mailwindow.cpp5
-rw-r--r--src/net/eathena/mail2recv.cpp7
-rw-r--r--src/utils/cast.h1
4 files changed, 14 insertions, 3 deletions
diff --git a/src/gui/mailmessage.h b/src/gui/mailmessage.h
index f28c4bf3d..fb8ec9130 100644
--- a/src/gui/mailmessage.h
+++ b/src/gui/mailmessage.h
@@ -39,7 +39,8 @@ struct MailMessage final
expireTime(0),
money(0),
type(MailMessageType::Text),
- read(false)
+ read(false),
+ expired(false)
{
}
@@ -55,5 +56,6 @@ struct MailMessage final
int64_t money;
MailMessageType::Type type;
bool read;
+ bool expired;
};
#endif // GUI_MAILMESSAGE_H
diff --git a/src/gui/windows/mailwindow.cpp b/src/gui/windows/mailwindow.cpp
index cacd9af43..6240792b4 100644
--- a/src/gui/windows/mailwindow.cpp
+++ b/src/gui/windows/mailwindow.cpp
@@ -194,6 +194,11 @@ std::string MailWindow::getMailHeader(const MailMessage *const message) const
if (mUseMail2)
{
std::string header;
+ if (message->expired)
+ {
+ // TRANSLATORS: expired mail message prefix
+ header = _("(expired)");
+ }
if (message->read)
header.append(" ");
else
diff --git a/src/net/eathena/mail2recv.cpp b/src/net/eathena/mail2recv.cpp
index 7e3ed631e..5c1db8de6 100644
--- a/src/net/eathena/mail2recv.cpp
+++ b/src/net/eathena/mail2recv.cpp
@@ -337,6 +337,7 @@ void Mail2Recv::processMailListPage(Net::MessageIn &msg)
}
msg.readInt16("len");
bool isEnd = true;
+
if (packetVersion < 20170419)
{
mailWindow->setOpenType(fromInt(msg.readUInt8("open type"),
@@ -356,7 +357,8 @@ void Mail2Recv::processMailListPage(Net::MessageIn &msg)
mail->time = CAST_S32(cur_time - msg.readInt32("reg time"));
mail->strTime = timeToStr(mail->time);
}
- mail->expireTime = msg.readInt32("expire time");
+ mail->expireTime = msg.readInt32("expire time") + cur_time;
+ mail->expired = mail->expireTime <= 0;
mail->title = msg.readString(-1, "title");
mailWindow->addMail(mail);
}
@@ -375,7 +377,8 @@ void Mail2Recv::processMailListPage(Net::MessageIn &msg)
msg.readUInt8("type"));
mail->sender = msg.readString(24, "sender name");
mail->strTime = "-";
- mail->expireTime = msg.readInt32("expire time");
+ mail->expireTime = msg.readInt32("expire time") + cur_time;
+ mail->expired = mail->expireTime <= 0;
mail->title = msg.readString(-1, "title");
mailWindow->addMail(mail);
}
diff --git a/src/utils/cast.h b/src/utils/cast.h
index b2a6200f8..60b0f3527 100644
--- a/src/utils/cast.h
+++ b/src/utils/cast.h
@@ -31,5 +31,6 @@
#define CAST_S64 static_cast<int64_t>
#define CAST_U64 static_cast<uint64_t>
#define CAST_SIZE static_cast<size_t>
+#define CAST_TIME static_cast<time_t>
#endif // UTILS_CAST_H