From e7fd7f2559a44b78f542310ca5708dd02f623a3c Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 15 Feb 2015 18:19:34 +0300 Subject: eathena: impliment packet SMSG_BUYINGSTORE_DELETE_ITEM. --- src/net/eathena/buyingstorehandler.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/net/eathena/buyingstorehandler.cpp') diff --git a/src/net/eathena/buyingstorehandler.cpp b/src/net/eathena/buyingstorehandler.cpp index cca75ce78..a3da66527 100644 --- a/src/net/eathena/buyingstorehandler.cpp +++ b/src/net/eathena/buyingstorehandler.cpp @@ -33,6 +33,7 @@ #include "gui/windows/buyingstoreselldialog.h" +#include "listeners/arrowslistener.h" #include "listeners/buyingstoremodelistener.h" #include "listeners/buyingstoreslotslistener.h" @@ -270,9 +271,23 @@ void BuyingStoreHandler::processBuyingStoreReport(Net::MessageIn &msg) void BuyingStoreHandler::processBuyingStoreDeleteItem(Net::MessageIn &msg) { - msg.readInt16("item index"); - msg.readInt16("amount"); + Inventory *const inventory = localPlayer + ? PlayerInfo::getInventory() : nullptr; + + const int index = msg.readInt16("index") - INVENTORY_OFFSET; + const int amount = msg.readInt16("amount"); msg.readInt32("price"); + + if (inventory) + { + if (Item *const item = inventory->getItem(index)) + { + item->increaseQuantity(-amount); + if (item->getQuantity() == 0) + inventory->removeItemAt(index); + ArrowsListener::distributeEvent(); + } + } } void BuyingStoreHandler::create(const std::string &name, -- cgit v1.2.3-60-g2f50