diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-08-27 19:41:58 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-08-27 19:41:58 +0300 |
commit | a23b30e3a3051393c8abd309be7376daf699a527 (patch) | |
tree | 44a5ce6c04839de3178390b7984b5db80a75959b /src/net/eathena/markethandler.cpp | |
parent | d3044d1572e42a28d21590aff4499896cd2e2b92 (diff) | |
download | plus-a23b30e3a3051393c8abd309be7376daf699a527.tar.gz plus-a23b30e3a3051393c8abd309be7376daf699a527.tar.bz2 plus-a23b30e3a3051393c8abd309be7376daf699a527.tar.xz plus-a23b30e3a3051393c8abd309be7376daf699a527.zip |
Move receive code from markethandler into separate file.
Diffstat (limited to 'src/net/eathena/markethandler.cpp')
-rw-r--r-- | src/net/eathena/markethandler.cpp | 45 |
1 files changed, 4 insertions, 41 deletions
diff --git a/src/net/eathena/markethandler.cpp b/src/net/eathena/markethandler.cpp index d0e8ff6ce..4e304b4ba 100644 --- a/src/net/eathena/markethandler.cpp +++ b/src/net/eathena/markethandler.cpp @@ -30,6 +30,7 @@ #include "gui/widgets/createwidget.h" +#include "net/eathena/marketrecv.h" #include "net/eathena/messageout.h" #include "net/eathena/protocol.h" @@ -40,8 +41,6 @@ extern Net::MarketHandler *marketHandler; namespace EAthena { -BuyDialog *MarketHandler::mBuyDialog = nullptr; - MarketHandler::MarketHandler() : MessageHandler() { @@ -53,7 +52,7 @@ MarketHandler::MarketHandler() : }; handledMessages = _messages; marketHandler = this; - mBuyDialog = nullptr; + MarketRecv::mBuyDialog = nullptr; } void MarketHandler::handleMessage(Net::MessageIn &msg) @@ -61,11 +60,11 @@ void MarketHandler::handleMessage(Net::MessageIn &msg) switch (msg.getId()) { case SMSG_NPC_MARKET_OPEN: - processMarketOpen(msg); + MarketRecv::processMarketOpen(msg); break; case SMSG_NPC_MARKET_BUY_ACK: - processMarketBuyAck(msg); + MarketRecv::processMarketBuyAck(msg); break; default: @@ -73,42 +72,6 @@ void MarketHandler::handleMessage(Net::MessageIn &msg) } } -void MarketHandler::processMarketOpen(Net::MessageIn &msg) -{ - const int len = (msg.readInt16("len") - 4) / 13; - - CREATEWIDGETV(mBuyDialog, BuyDialog, fromInt(BuyDialog::Market, BeingId)); - mBuyDialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY)); - - for (int f = 0; f < len; f ++) - { - const int itemId = msg.readInt16("item id"); - const int type = msg.readUInt8("type"); - const int value = msg.readInt32("price"); - const int amount = msg.readInt32("amount"); - msg.readInt16("view"); - const ItemColor color = ItemColor_one; - mBuyDialog->addItem(itemId, type, color, amount, value); - } - mBuyDialog->sort(); -} - -void MarketHandler::processMarketBuyAck(Net::MessageIn &msg) -{ - const int len = (msg.readInt16("len") - 5) / 8; - const int res = msg.readUInt8("result"); - for (int f = 0; f < len; f ++) - { - msg.readInt16("item id"); - msg.readInt16("amount"); - msg.readInt32("price"); - } - if (res) - NotifyManager::notify(NotifyTypes::BUY_DONE); - else - NotifyManager::notify(NotifyTypes::BUY_FAILED); -} - void MarketHandler::close() { createOutPacket(CMSG_NPC_MARKET_CLOSE); |