diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-09-09 17:40:06 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-09-09 17:40:06 +0300 |
commit | 8d519af0d6a5a7c3477e684269172b8163495a85 (patch) | |
tree | 027e57ee17fc5a663467358d0408b30c662c416e /src/net/tmwa/inventoryrecv.cpp | |
parent | 1da80a3312ae865ed5d84271fc0cf53b82d87f15 (diff) | |
download | manaverse-8d519af0d6a5a7c3477e684269172b8163495a85.tar.gz manaverse-8d519af0d6a5a7c3477e684269172b8163495a85.tar.bz2 manaverse-8d519af0d6a5a7c3477e684269172b8163495a85.tar.xz manaverse-8d519af0d6a5a7c3477e684269172b8163495a85.zip |
Move processPlayerInventoryRemove from ea namespace into eathena and tmwa.
Diffstat (limited to 'src/net/tmwa/inventoryrecv.cpp')
-rw-r--r-- | src/net/tmwa/inventoryrecv.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/net/tmwa/inventoryrecv.cpp b/src/net/tmwa/inventoryrecv.cpp index 02dd36978..815e4333c 100644 --- a/src/net/tmwa/inventoryrecv.cpp +++ b/src/net/tmwa/inventoryrecv.cpp @@ -458,4 +458,25 @@ void InventoryRecv::processPlayerStorageRemove(Net::MessageIn &msg) BLOCK_END("InventoryRecv::processPlayerStorageRemove") } +void InventoryRecv::processPlayerInventoryRemove(Net::MessageIn &msg) +{ + BLOCK_START("InventoryRecv::processPlayerInventoryRemove") + Inventory *const inventory = localPlayer + ? PlayerInfo::getInventory() : nullptr; + + const int index = msg.readInt16("index") - INVENTORY_OFFSET; + const int amount = msg.readInt16("amount"); + if (inventory) + { + if (Item *const item = inventory->getItem(index)) + { + item->increaseQuantity(-amount); + if (item->getQuantity() == 0) + inventory->removeItemAt(index); + ArrowsListener::distributeEvent(); + } + } + BLOCK_END("InventoryRecv::processPlayerInventoryRemove") +} + } // namespace TmwAthena |