From d8da9ebe28dc38fa9c7e5bd859913faa4460a25d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 15 Feb 2015 16:25:30 +0300 Subject: eathena: impliment packet SMSG_BUYINGSTORE_ITEMS_LIST. --- src/net/eathena/buyingstorehandler.cpp | 35 ++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'src/net/eathena') diff --git a/src/net/eathena/buyingstorehandler.cpp b/src/net/eathena/buyingstorehandler.cpp index 33fd8a4ee..7f2627a29 100644 --- a/src/net/eathena/buyingstorehandler.cpp +++ b/src/net/eathena/buyingstorehandler.cpp @@ -21,6 +21,7 @@ #include "net/eathena/buyingstorehandler.h" #include "actormanager.h" +#include "inventory.h" #include "notifymanager.h" #include "shopitem.h" @@ -28,6 +29,10 @@ #include "being/localplayer.h" #include "being/playerinfo.h" +#include "enums/being/attributes.h" + +#include "gui/windows/buyingstoreselldialog.h" + #include "listeners/buyingstoremodelistener.h" #include "listeners/buyingstoreslotslistener.h" @@ -182,15 +187,33 @@ void BuyingStoreHandler::processBuyingStoreHideBoard(Net::MessageIn &msg) void BuyingStoreHandler::processBuyingStoreItemsList(Net::MessageIn &msg) { const int count = (msg.readInt16("len") - 16) / 9; - msg.readInt32("account id"); - msg.readInt32("store id"); + const int id = msg.readInt32("account id"); + const int storeId = msg.readInt32("store id"); + // +++ in future need use it too msg.readInt32("money limit"); + + Being *const dstBeing = actorManager->findBeing(id); + if (!dstBeing) + return; + + SellDialog *const dialog = new BuyingStoreSellDialog( + dstBeing->getId(), + storeId); + dialog->postInit(); + dialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY)); + Inventory *const inv = PlayerInfo::getInventory(); for (int f = 0; f < count; f ++) { - msg.readInt32("price"); - msg.readInt16("amount"); - msg.readUInt8("item type"); - msg.readInt16("item id"); + const int price = msg.readInt32("price"); + const int amount = msg.readInt16("amount"); + const int itemType = msg.readUInt8("item type"); + const int itemId = msg.readInt16("item id"); + + const Item *const item = inv->findItem(itemId, 1); + if (!item) + continue; + // +++ need add colors support + dialog->addItem(itemId, itemType, 1, amount, price); } } -- cgit v1.2.3-70-g09d2