diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-12-24 17:06:53 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-12-24 17:06:53 +0300 |
commit | 81020303571b9421b3ef1c8d2ec5f5d36599540d (patch) | |
tree | 78c0b3400ebca0d370aba332ec95d8da027de618 | |
parent | 2f91a45e4c0c59a962059890ed5ab708a059788f (diff) | |
download | manaplus-81020303571b9421b3ef1c8d2ec5f5d36599540d.tar.gz manaplus-81020303571b9421b3ef1c8d2ec5f5d36599540d.tar.bz2 manaplus-81020303571b9421b3ef1c8d2ec5f5d36599540d.tar.xz manaplus-81020303571b9421b3ef1c8d2ec5f5d36599540d.zip |
eathena: impliment packet SMSG_NPC_CASH_SHOP_OPEN 0x0287.
-rw-r--r-- | src/gui/windows/buydialog.h | 3 | ||||
-rw-r--r-- | src/net/eathena/cashshophandler.cpp | 21 | ||||
-rw-r--r-- | src/net/eathena/cashshophandler.h | 4 | ||||
-rw-r--r-- | src/net/eathena/markethandler.cpp | 1 |
4 files changed, 25 insertions, 4 deletions
diff --git a/src/gui/windows/buydialog.h b/src/gui/windows/buydialog.h index 088e9c2ba..514eee4d0 100644 --- a/src/gui/windows/buydialog.h +++ b/src/gui/windows/buydialog.h @@ -80,7 +80,8 @@ class BuyDialog final : public Window, { Nick = -1, Items = -2, - Market = -3 + Market = -3, + Cash = -4 }; void init(); diff --git a/src/net/eathena/cashshophandler.cpp b/src/net/eathena/cashshophandler.cpp index 2ae0c67be..63cd03a04 100644 --- a/src/net/eathena/cashshophandler.cpp +++ b/src/net/eathena/cashshophandler.cpp @@ -20,6 +20,11 @@ #include "net/eathena/cashshophandler.h" +#include "being/attributes.h" +#include "being/playerinfo.h" + +#include "gui/windows/buydialog.h" + #include "net/eathena/messageout.h" #include "net/eathena/protocol.h" @@ -30,6 +35,8 @@ extern Net::CashShopHandler *cashShopHandler; namespace EAthena { +BuyDialog *CashShopHandler::mBuyDialog = nullptr; + CashShopHandler::CashShopHandler() : MessageHandler() { @@ -41,6 +48,7 @@ CashShopHandler::CashShopHandler() : }; handledMessages = _messages; cashShopHandler = this; + mBuyDialog = nullptr; } void CashShopHandler::handleMessage(Net::MessageIn &msg) @@ -63,15 +71,22 @@ void CashShopHandler::handleMessage(Net::MessageIn &msg) void CashShopHandler::processCashShopOpen(Net::MessageIn &msg) { const int count = (msg.readInt16("len") - 12) / 11; + + mBuyDialog = new BuyDialog(BuyDialog::Cash); + mBuyDialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY)); + msg.readInt32("cash points"); msg.readInt32("kafra points"); for (int f = 0; f < count; f ++) { msg.readInt32("price"); - msg.readInt32("discount price"); - msg.readUInt8("item type"); - msg.readInt16("item id"); + const int value = msg.readInt32("discount price"); + const int type = msg.readUInt8("item type"); + const int itemId = msg.readInt16("item id"); + const int color = 1; + mBuyDialog->addItem(itemId, type, color, 0, value); } + mBuyDialog->sort(); } void CashShopHandler::processCashShopBuyAck(Net::MessageIn &msg) diff --git a/src/net/eathena/cashshophandler.h b/src/net/eathena/cashshophandler.h index 00f272d69..ae99d8e9e 100644 --- a/src/net/eathena/cashshophandler.h +++ b/src/net/eathena/cashshophandler.h @@ -25,6 +25,8 @@ #include "net/eathena/messagehandler.h" +class BuyDialog; + namespace EAthena { class CashShopHandler final : public MessageHandler, @@ -46,6 +48,8 @@ class CashShopHandler final : public MessageHandler, static void processCashShopOpen(Net::MessageIn &msg); static void processCashShopBuyAck(Net::MessageIn &msg); + + static BuyDialog *mBuyDialog; }; } // namespace EAthena diff --git a/src/net/eathena/markethandler.cpp b/src/net/eathena/markethandler.cpp index 3c5c873ce..4e2dfc5cf 100644 --- a/src/net/eathena/markethandler.cpp +++ b/src/net/eathena/markethandler.cpp @@ -89,6 +89,7 @@ void MarketHandler::processMarketOpen(Net::MessageIn &msg) const unsigned char color = 1; mBuyDialog->addItem(itemId, type, color, amount, value); } + mBuyDialog->sort(); } void MarketHandler::processMarketBuyAck(Net::MessageIn &msg) |