diff options
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/eathena/buyingstorehandler.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
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, |