From b8176c75b6501146ebf610509e2d3218bf764e46 Mon Sep 17 00:00:00 2001
From: Andrei Karas <akaras@inbox.ru>
Date: Thu, 12 Mar 2015 16:08:08 +0300
Subject: eathena: add partial support for packet SMSG_MAIL_MAILS_LIST 0x0240.

---
 src/net/eathena/mailhandler.cpp | 23 +++++++++++++++++++++++
 src/net/eathena/mailhandler.h   |  2 ++
 src/net/eathena/packets.h       |  2 +-
 src/net/eathena/protocol.h      |  1 +
 4 files changed, 27 insertions(+), 1 deletion(-)

(limited to 'src/net')

diff --git a/src/net/eathena/mailhandler.cpp b/src/net/eathena/mailhandler.cpp
index cf4fb90d4..95c729c9b 100644
--- a/src/net/eathena/mailhandler.cpp
+++ b/src/net/eathena/mailhandler.cpp
@@ -40,6 +40,7 @@ MailHandler::MailHandler() :
     static const uint16_t _messages[] =
     {
         SMSG_MAIL_OPEN_WINDOW,
+        SMSG_MAIL_MAILS_LIST,
         0
     };
     handledMessages = _messages;
@@ -54,6 +55,10 @@ void MailHandler::handleMessage(Net::MessageIn &msg)
             processMailOpen(msg);
             break;
 
+        case SMSG_MAIL_MAILS_LIST:
+            processMailList(msg);
+            break;
+
         default:
             break;
     }
@@ -77,6 +82,24 @@ void MailHandler::processMailOpen(Net::MessageIn &msg)
     }
 }
 
+void MailHandler::processMailList(Net::MessageIn &msg)
+{
+    UNIMPLIMENTEDPACKET;
+
+    const int count = (msg.readInt16("len") - 8) / 73;
+    const int amount = msg.readInt32("amount");
+    if (count != amount)
+        logger->log("error: wrong mails count");
+    for (int f = 0; f < count; f ++)
+    {
+        msg.readInt32("message id");
+        msg.readString(40, "title");
+        msg.readUInt8("unread flag");
+        msg.readString(24, "sender name");
+        msg.readInt32("time stamp");
+    }
+}
+
 void MailHandler::refresh()
 {
     createOutPacket(CMSG_MAIL_REFRESH_INBOX);
diff --git a/src/net/eathena/mailhandler.h b/src/net/eathena/mailhandler.h
index 7c178d57f..9aecc0705 100644
--- a/src/net/eathena/mailhandler.h
+++ b/src/net/eathena/mailhandler.h
@@ -58,6 +58,8 @@ class MailHandler final : public MessageHandler, public Net::MailHandler
 
     protected:
         static void processMailOpen(Net::MessageIn &msg);
+
+        static void processMailList(Net::MessageIn &msg);
 };
 
 }  // namespace EAthena
diff --git a/src/net/eathena/packets.h b/src/net/eathena/packets.h
index 56115cd04..7b91f5567 100644
--- a/src/net/eathena/packets.h
+++ b/src/net/eathena/packets.h
@@ -88,7 +88,7 @@ int16_t packet_lengths[] =
  -1,  -1,   0,   8,  10,   0, 282,   0,   0,  15,   0,   0,   0,  19,  71,   5,
  12,   0,   0,   0,   0,  -1,   0,   0, 282,   0,   4,   0,   6,   0,   0,   0,
 // #0x0240
-  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
+ -1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
   3,   0,  -1,   0,   0,   0,   5,   0,   0,   0,   0,   0,   0,   4,   0,   6,
   6,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
diff --git a/src/net/eathena/protocol.h b/src/net/eathena/protocol.h
index f7ca7f7da..b2daa3dbf 100644
--- a/src/net/eathena/protocol.h
+++ b/src/net/eathena/protocol.h
@@ -305,6 +305,7 @@
 #define SMSG_CHAT_JOIN_CHANNEL       0x0b08
 #define SMSG_CHAT_TALKIE_BOX         0x0191
 
+#define SMSG_MAIL_MAILS_LIST         0x0240
 #define SMSG_MAIL_OPEN_WINDOW        0x0260
 
 #define SMSG_FAMILY_ASK_FOR_CHILD    0x01f6
-- 
cgit v1.2.3-70-g09d2