From 805299e4d653440c582f6c576bcd7de2e1b2c3d4 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 5 Feb 2015 12:00:20 +0300 Subject: eathena: add packet CMSG_BUYINGSTORE_CREATE 0x0815. --- src/net/buyingstorehandler.h | 8 ++++++++ src/net/eathena/buyingstorehandler.cpp | 25 ++++++++++++++++++++++++- src/net/eathena/buyingstorehandler.h | 5 +++++ src/net/eathena/packets.h | 2 +- src/net/eathena/protocol.h | 2 ++ src/net/tmwa/buyingstorehandler.cpp | 7 +++++++ src/net/tmwa/buyingstorehandler.h | 5 +++++ 7 files changed, 52 insertions(+), 2 deletions(-) diff --git a/src/net/buyingstorehandler.h b/src/net/buyingstorehandler.h index 8f78cab9a..bc7f6177c 100644 --- a/src/net/buyingstorehandler.h +++ b/src/net/buyingstorehandler.h @@ -22,9 +22,12 @@ #define NET_BUYINGSTOREHANDLER_H #include +#include #include "localconsts.h" +class ShopItem; + namespace Net { @@ -33,6 +36,11 @@ class BuyingStoreHandler notfinal public: virtual ~BuyingStoreHandler() { } + + virtual void create(const std::string &name, + const int maxMoney, + const bool flag, + std::vector &items) const = 0; }; } // namespace Net diff --git a/src/net/eathena/buyingstorehandler.cpp b/src/net/eathena/buyingstorehandler.cpp index 0067fa78b..166512eca 100644 --- a/src/net/eathena/buyingstorehandler.cpp +++ b/src/net/eathena/buyingstorehandler.cpp @@ -20,7 +20,12 @@ #include "net/eathena/buyingstorehandler.h" -#include "net/eathena/protocol.h" +#include "shopitem.h" + +#include "net/ea/eaprotocol.h" + +#include "net/eathena/messageout.h" +#include "net/eathena/protocol.h" #include "debug.h" @@ -60,4 +65,22 @@ void BuyingStoreHandler::processBuyingStoreOpen(Net::MessageIn &msg) msg.readUInt8("slots"); } +void BuyingStoreHandler::create(const std::string &name, + const int maxMoney, + const bool flag, + std::vector &items) const +{ + createOutPacket(CMSG_BUYINGSTORE_CREATE); + outMsg.writeInt32(maxMoney, "limit money"); + outMsg.writeInt8(flag, "flag"); + outMsg.writeString(name, 80, "store name"); + FOR_EACH (std::vector::const_iterator, it, items) + { + const ShopItem *const item = *it; + outMsg.writeInt16(static_cast(item->getId()), "item id"); + outMsg.writeInt16(static_cast(item->getQuantity()), "amount"); + outMsg.writeInt32(item->getPrice(), "price"); + } +} + } // namespace EAthena diff --git a/src/net/eathena/buyingstorehandler.h b/src/net/eathena/buyingstorehandler.h index a5e0a85b5..edafbc170 100644 --- a/src/net/eathena/buyingstorehandler.h +++ b/src/net/eathena/buyingstorehandler.h @@ -37,6 +37,11 @@ class BuyingStoreHandler final : public MessageHandler, void handleMessage(Net::MessageIn &msg) override final; + void create(const std::string &name, + const int maxMoney, + const bool flag, + std::vector &items) const override final; + protected: static void processBuyingStoreOpen(Net::MessageIn &msg); }; diff --git a/src/net/eathena/packets.h b/src/net/eathena/packets.h index 1f5e6211d..3755746e7 100644 --- a/src/net/eathena/packets.h +++ b/src/net/eathena/packets.h @@ -216,7 +216,7 @@ int16_t packet_lengths[] = //0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 // #0x0800 -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 20, - 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 22, 8, 0, + 3, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 22, 8, 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, 66, 0, 0, 0, 0, 26, 0, // #0x0840 diff --git a/src/net/eathena/protocol.h b/src/net/eathena/protocol.h index b17531c9d..b79baf82b 100644 --- a/src/net/eathena/protocol.h +++ b/src/net/eathena/protocol.h @@ -547,4 +547,6 @@ #define CMSG_VENDING_BUY2 0x0801 #define CMSG_VENDING_CREATE_SHOP 0x01b2 +#define CMSG_BUYINGSTORE_CREATE 0x0815 + #endif // NET_EATHENA_PROTOCOL_H diff --git a/src/net/tmwa/buyingstorehandler.cpp b/src/net/tmwa/buyingstorehandler.cpp index a68208796..160a6b270 100644 --- a/src/net/tmwa/buyingstorehandler.cpp +++ b/src/net/tmwa/buyingstorehandler.cpp @@ -42,4 +42,11 @@ void BuyingStoreHandler::handleMessage(Net::MessageIn &msg A_UNUSED) { } +void BuyingStoreHandler::create(const std::string &name A_UNUSED, + const int maxMoney A_UNUSED, + const bool flag A_UNUSED, + std::vector &items A_UNUSED) const +{ +} + } // namespace TmwAthena diff --git a/src/net/tmwa/buyingstorehandler.h b/src/net/tmwa/buyingstorehandler.h index 29b5d3434..821bae865 100644 --- a/src/net/tmwa/buyingstorehandler.h +++ b/src/net/tmwa/buyingstorehandler.h @@ -37,6 +37,11 @@ class BuyingStoreHandler final : public MessageHandler, A_DELETE_COPY(BuyingStoreHandler) void handleMessage(Net::MessageIn &msg) override final; + + void create(const std::string &name, + const int maxMoney, + const bool flag, + std::vector &items) const; }; } // namespace TmwAthena -- cgit v1.2.3-70-g09d2