From 8d519af0d6a5a7c3477e684269172b8163495a85 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 9 Sep 2015 17:40:06 +0300 Subject: Move processPlayerInventoryRemove from ea namespace into eathena and tmwa. --- src/net/tmwa/inventoryrecv.cpp | 21 +++++++++++++++++++++ src/net/tmwa/inventoryrecv.h | 1 + src/net/tmwa/packetsin.inc | 2 +- 3 files changed, 23 insertions(+), 1 deletion(-) (limited to 'src/net/tmwa') 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 diff --git a/src/net/tmwa/inventoryrecv.h b/src/net/tmwa/inventoryrecv.h index 091d18ab5..1bbf4db38 100644 --- a/src/net/tmwa/inventoryrecv.h +++ b/src/net/tmwa/inventoryrecv.h @@ -41,6 +41,7 @@ namespace TmwAthena void processPlayerStorageEquip(Net::MessageIn &msg); void processPlayerStorageAdd(Net::MessageIn &msg); void processPlayerStorageRemove(Net::MessageIn &msg); + void processPlayerInventoryRemove(Net::MessageIn &msg); } // namespace InventoryRecv } // namespace TmwAthena diff --git a/src/net/tmwa/packetsin.inc b/src/net/tmwa/packetsin.inc index afbf4550a..d82c65f8e 100644 --- a/src/net/tmwa/packetsin.inc +++ b/src/net/tmwa/packetsin.inc @@ -119,7 +119,7 @@ packet(SMSG_PLAYER_EQUIPMENT, 0x00a4, -1, &InventoryRecv::processP packet(SMSG_PLAYER_GUILD_PARTY_INFO, 0x0195, 102, &BeingRecv::processPlayerGuilPartyInfo); packet(SMSG_PLAYER_INVENTORY, 0x01ee, -1, &InventoryRecv::processPlayerInventory); packet(SMSG_PLAYER_INVENTORY_ADD, 0x00a0, 23, &InventoryRecv::processPlayerInventoryAdd); -packet(SMSG_PLAYER_INVENTORY_REMOVE, 0x00af, 6, &Ea::InventoryRecv::processPlayerInventoryRemove); +packet(SMSG_PLAYER_INVENTORY_REMOVE, 0x00af, 6, &InventoryRecv::processPlayerInventoryRemove); packet(SMSG_PLAYER_INVENTORY_USE, 0x01c8, 13, &Ea::InventoryRecv::processPlayerInventoryUse); packet(SMSG_PLAYER_MOVE, 0x01da, 60, &BeingRecv::processPlayerMove); packet(SMSG_PLAYER_MOVE_TO_ATTACK, 0x0139, 16, &Ea::BeingRecv::processPlayerMoveToAttack); -- cgit v1.2.3-60-g2f50