From e0370f84531ba564224963f579921b126e620add Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 6 Sep 2014 11:23:36 +0300 Subject: eathena: add packet SMSG_PLAYER_INVENTORY_REMOVE2 0x07fa. --- src/net/eathena/inventoryhandler.cpp | 31 ++++++++++++++++++++++++++++++- src/net/eathena/inventoryhandler.h | 2 ++ src/net/eathena/packets.h | 2 +- src/net/eathena/protocol.h | 1 + 4 files changed, 34 insertions(+), 2 deletions(-) (limited to 'src/net/eathena') diff --git a/src/net/eathena/inventoryhandler.cpp b/src/net/eathena/inventoryhandler.cpp index 1ee1f8f9d..fa6379caa 100644 --- a/src/net/eathena/inventoryhandler.cpp +++ b/src/net/eathena/inventoryhandler.cpp @@ -53,6 +53,7 @@ InventoryHandler::InventoryHandler() : SMSG_PLAYER_INVENTORY, SMSG_PLAYER_INVENTORY_ADD, SMSG_PLAYER_INVENTORY_REMOVE, + SMSG_PLAYER_INVENTORY_REMOVE2, SMSG_PLAYER_INVENTORY_USE, SMSG_ITEM_USE_RESPONSE, SMSG_PLAYER_STORAGE_ITEMS, @@ -97,6 +98,10 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg) processPlayerInventoryRemove(msg); break; + case SMSG_PLAYER_INVENTORY_REMOVE2: + processPlayerInventoryRemove2(msg); + break; + case SMSG_PLAYER_INVENTORY_USE: processPlayerInventoryUse(msg); break; @@ -418,7 +423,7 @@ void InventoryHandler::processPlayerUnEquip(Net::MessageIn &msg) const int equipType = msg.readInt32("wear location"); const uint8_t flag = msg.readUInt8("result"); - // need use UNEQUIP_FAILED event + // +++ need use UNEQUIP_FAILED event if (flag) NotifyManager::notify(NotifyTypes::EQUIP_FAILED); else @@ -428,4 +433,28 @@ void InventoryHandler::processPlayerUnEquip(Net::MessageIn &msg) BLOCK_END("InventoryHandler::processPlayerUnEquip") } +void InventoryHandler::processPlayerInventoryRemove2(Net::MessageIn &msg) +{ + BLOCK_START("InventoryHandler::processPlayerInventoryRemove2") + Inventory *const inventory = localPlayer + ? PlayerInfo::getInventory() : nullptr; + + // +++ here possible use particle or text/sound effects + // for different reasons + const int reason = msg.readInt16("reason"); + 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("InventoryHandler::processPlayerInventoryRemove2") +} + } // namespace EAthena diff --git a/src/net/eathena/inventoryhandler.h b/src/net/eathena/inventoryhandler.h index 78f35acbb..652a864de 100644 --- a/src/net/eathena/inventoryhandler.h +++ b/src/net/eathena/inventoryhandler.h @@ -68,6 +68,8 @@ class InventoryHandler final : public MessageHandler, void processPlayerEquip(Net::MessageIn &msg); void processPlayerUnEquip(Net::MessageIn &msg); + + void processPlayerInventoryRemove2(Net::MessageIn &msg); }; } // namespace EAthena diff --git a/src/net/eathena/packets.h b/src/net/eathena/packets.h index 5483cf138..b9bd143f3 100644 --- a/src/net/eathena/packets.h +++ b/src/net/eathena/packets.h @@ -211,7 +211,7 @@ int16_t packet_lengths[] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 268, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 14, 0, 0, 0, 0, 25, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 14, 0, 0, 0, 8, 25, 0, 0, 0, 0, //0 1 2 3 4 5 6 7 8 9 a b c d e f //0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 // #0x0800 diff --git a/src/net/eathena/protocol.h b/src/net/eathena/protocol.h index 12e307846..ba435aa10 100644 --- a/src/net/eathena/protocol.h +++ b/src/net/eathena/protocol.h @@ -71,6 +71,7 @@ #define SMSG_PLAYER_INVENTORY 0x0991 #define SMSG_PLAYER_INVENTORY_ADD 0x0990 #define SMSG_PLAYER_INVENTORY_REMOVE 0x00af +#define SMSG_PLAYER_INVENTORY_REMOVE2 0x07fa #define SMSG_PLAYER_INVENTORY_USE 0x01c8 #define SMSG_PLAYER_EQUIPMENT 0x0992 #define SMSG_PLAYER_EQUIP 0x0999 -- cgit v1.2.3-70-g09d2