From 2aef4c43560203a41ee2866245732fbfa2639a6d Mon Sep 17 00:00:00 2001
From: Andrei Karas <akaras@inbox.ru>
Date: Mon, 9 Feb 2015 16:14:00 +0300
Subject: eathena: add partial support for packet SMSG_SEARCHSTORE_SEARCH_ACK
 0x0836.

---
 src/net/eathena/packets.h              |  2 +-
 src/net/eathena/protocol.h             |  2 ++
 src/net/eathena/searchstorehandler.cpp | 26 ++++++++++++++++++++++++++
 src/net/eathena/searchstorehandler.h   |  3 +++
 4 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/src/net/eathena/packets.h b/src/net/eathena/packets.h
index 75fae8ae9..2f0a79cb9 100644
--- a/src/net/eathena/packets.h
+++ b/src/net/eathena/packets.h
@@ -217,7 +217,7 @@ int16_t packet_lengths[] =
 // #0x0800
  -1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  14,  20,
   3,   0,   8,  -1,  86,  -1,   0,   0,  -1,   0,   4,  10,  10,  22,   8,   0,
-  0,   0,   0,   0,   6,   0,   0,   0,   0,   0,   0,   0,   0,  -1,   0,   0,
+  0,   0,   0,   0,   6,   0,  -1,   0,   0,   0,   0,   0,   0,  -1,   0,   0,
   0,   0,   0,   0,   0,   0,   0,   0,   0,  66,   0,   0,   0,   0,  26,   0,
 // #0x0840
  -1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  19,   0,   0,   0,   0,
diff --git a/src/net/eathena/protocol.h b/src/net/eathena/protocol.h
index a214674ed..cdff5a705 100644
--- a/src/net/eathena/protocol.h
+++ b/src/net/eathena/protocol.h
@@ -343,6 +343,8 @@
 #define SMSG_CART_INFO               0x0121
 #define SMSG_CART_REMOVE             0x012b
 
+#define SMSG_SEARCHSTORE_SEARCH_ACK  0x0836
+
 /**********************************
  *  Packets from client to server *
  **********************************/
diff --git a/src/net/eathena/searchstorehandler.cpp b/src/net/eathena/searchstorehandler.cpp
index 4ddad3148..22f892a8a 100644
--- a/src/net/eathena/searchstorehandler.cpp
+++ b/src/net/eathena/searchstorehandler.cpp
@@ -35,6 +35,7 @@ SearchStoreHandler::SearchStoreHandler() :
 {
     static const uint16_t _messages[] =
     {
+        SMSG_SEARCHSTORE_SEARCH_ACK,
         0
     };
     handledMessages = _messages;
@@ -45,6 +46,10 @@ void SearchStoreHandler::handleMessage(Net::MessageIn &msg)
 {
     switch (msg.getId())
     {
+        case SMSG_SEARCHSTORE_SEARCH_ACK:
+            processSearchAck(msg);
+            break;
+
         default:
             break;
     }
@@ -65,4 +70,25 @@ void SearchStoreHandler::search(const StoreSearchType::Type type,
     outMsg.writeInt16(itemId, "item id");
 }
 
+void SearchStoreHandler::processSearchAck(Net::MessageIn &msg)
+{
+    const int count = (msg.readInt16("len") - 7) / 106;
+    msg.readUInt8("is first page");
+    msg.readUInt8("is next page");
+    msg.readUInt8("remain uses");
+    for (int f = 0; f < count; f ++)
+    {
+        msg.readInt32("store id");
+        msg.readInt32("aoount id");
+        msg.readString(80, "store name");
+        msg.readInt16("item id");
+        msg.readUInt8("item type");
+        msg.readInt32("price");
+        msg.readInt16("amount");
+        msg.readUInt8("refine");
+        for (int f = 0; f < 4; f++)
+            msg.readInt16("card");
+    }
+}
+
 }  // namespace EAthena
diff --git a/src/net/eathena/searchstorehandler.h b/src/net/eathena/searchstorehandler.h
index 56e44dd8b..bd2cf80c7 100644
--- a/src/net/eathena/searchstorehandler.h
+++ b/src/net/eathena/searchstorehandler.h
@@ -41,6 +41,9 @@ class SearchStoreHandler final : public MessageHandler,
                     const int minPrice,
                     const int maxPrice,
                     const int itemId) const override final;
+
+    protected:
+        static void processSearchAck(Net::MessageIn &msg);
 };
 
 }  // namespace EAthena
-- 
cgit v1.2.3-70-g09d2