summaryrefslogtreecommitdiff
path: root/src/net/eathena/vendinghandler.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-02-01 18:07:14 +0300
committerAndrei Karas <akaras@inbox.ru>2015-02-02 00:13:44 +0300
commitc8c51d7550adf9c952a4be54398df7e7a6f341a8 (patch)
tree4404d6d2a86c820661cb29f8c67abefeefd54810 /src/net/eathena/vendinghandler.cpp
parent30f142d6a147885afef203cdc83326cccdb4bb75 (diff)
downloadplus-c8c51d7550adf9c952a4be54398df7e7a6f341a8.tar.gz
plus-c8c51d7550adf9c952a4be54398df7e7a6f341a8.tar.bz2
plus-c8c51d7550adf9c952a4be54398df7e7a6f341a8.tar.xz
plus-c8c51d7550adf9c952a4be54398df7e7a6f341a8.zip
add buy dialog for vending shop.
Diffstat (limited to 'src/net/eathena/vendinghandler.cpp')
-rw-r--r--src/net/eathena/vendinghandler.cpp28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/net/eathena/vendinghandler.cpp b/src/net/eathena/vendinghandler.cpp
index ec765d559..25bec7c68 100644
--- a/src/net/eathena/vendinghandler.cpp
+++ b/src/net/eathena/vendinghandler.cpp
@@ -23,7 +23,12 @@
#include "actormanager.h"
#include "shopitem.h"
+#include "enums/being/attributes.h"
+
#include "being/being.h"
+#include "being/playerinfo.h"
+
+#include "gui/windows/buydialog.h"
#include "listeners/vendingslotslistener.h"
@@ -39,6 +44,8 @@ extern Net::VendingHandler *vendingHandler;
namespace EAthena
{
+BuyDialog *VendingHandler::mBuyDialog = nullptr;
+
VendingHandler::VendingHandler() :
MessageHandler()
{
@@ -54,6 +61,7 @@ VendingHandler::VendingHandler() :
};
handledMessages = _messages;
vendingHandler = this;
+ mBuyDialog = nullptr;
}
void VendingHandler::handleMessage(Net::MessageIn &msg)
@@ -117,22 +125,32 @@ void VendingHandler::processHideBoard(Net::MessageIn &msg)
void VendingHandler::processItemsList(Net::MessageIn &msg)
{
+
const int count = (msg.readInt16("len") - 12) / 22;
- msg.readInt32("id");
+ const int id = msg.readInt32("id");
+ Being *const being = actorManager->findBeing(id);
+ if (!being)
+ return;
+ mBuyDialog = new BuyDialog(being->getName());
+ mBuyDialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY));
msg.readInt32("vender id");
for (int f = 0; f < count; f ++)
{
- msg.readInt32("price");
- msg.readInt16("amount");
+ const int value = msg.readInt32("price");
+ const int amount = msg.readInt16("amount");
msg.readInt16("inv index");
- msg.readUInt8("item type");
- msg.readInt16("item id");
+ const int type = msg.readUInt8("item type");
+ const int itemId = msg.readInt16("item id");
msg.readUInt8("identify");
msg.readUInt8("attribute");
msg.readUInt8("refine");
for (int d = 0; d < 4; d ++)
msg.readInt16("card");
+
+ const unsigned char color = 1;
+ mBuyDialog->addItem(itemId, type, color, amount, value);
}
+ mBuyDialog->sort();
}
void VendingHandler::processBuyAck(Net::MessageIn &msg)