summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-02-15 18:19:34 +0300
committerAndrei Karas <akaras@inbox.ru>2015-02-15 18:28:30 +0300
commite7fd7f2559a44b78f542310ca5708dd02f623a3c (patch)
tree0a21e811aab39658ee7517f462a208ddb51c88d2 /src/net
parentada1a2756824d80ee004d1c1dcbcaba3ce34d2af (diff)
downloadmanaplus-e7fd7f2559a44b78f542310ca5708dd02f623a3c.tar.gz
manaplus-e7fd7f2559a44b78f542310ca5708dd02f623a3c.tar.bz2
manaplus-e7fd7f2559a44b78f542310ca5708dd02f623a3c.tar.xz
manaplus-e7fd7f2559a44b78f542310ca5708dd02f623a3c.zip
eathena: impliment packet SMSG_BUYINGSTORE_DELETE_ITEM.
Diffstat (limited to 'src/net')
-rw-r--r--src/net/eathena/buyingstorehandler.cpp19
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,