From 3b5390eee9c3e031867d3acfce574f1993d46b76 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 6 Aug 2018 21:13:56 +0300 Subject: Move InventoryRecv::processPlayerInventoryUse from ea namespace into tmwa and eathena. --- src/net/tmwa/inventoryrecv.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/net/tmwa/inventoryrecv.cpp') diff --git a/src/net/tmwa/inventoryrecv.cpp b/src/net/tmwa/inventoryrecv.cpp index 1bb1ee9f2..68521bfa4 100644 --- a/src/net/tmwa/inventoryrecv.cpp +++ b/src/net/tmwa/inventoryrecv.cpp @@ -560,4 +560,29 @@ int InventoryRecv::getSlot(const int eAthenaSlot) return CAST_S32(EQUIP_POINTS[position]); } +void InventoryRecv::processPlayerInventoryUse(Net::MessageIn &msg) +{ + BLOCK_START("InventoryRecv::processPlayerInventoryUse") + Inventory *const inventory = localPlayer != nullptr + ? PlayerInfo::getInventory() : nullptr; + + const int index = msg.readInt16("index") - INVENTORY_OFFSET; + msg.readItemId("item id"); + msg.readInt32("id?"); + const int amount = msg.readInt16("amount"); + msg.readUInt8("type"); + + if (inventory != nullptr) + { + if (Item *const item = inventory->getItem(index)) + { + if (amount != 0) + item->setQuantity(amount); + else + inventory->removeItemAt(index); + } + } + BLOCK_END("InventoryRecv::processPlayerInventoryUse") +} + } // namespace TmwAthena -- cgit v1.2.3-70-g09d2