diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-09-06 11:23:36 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-09-06 11:23:36 +0300 |
commit | e0370f84531ba564224963f579921b126e620add (patch) | |
tree | bcfc7eec4df22792ee6416e37e0983b83118a6b1 /src/net/eathena/inventoryhandler.cpp | |
parent | 7092b86c5b9bcfc1b377d090f65ce35427cecc4c (diff) | |
download | ManaVerse-e0370f84531ba564224963f579921b126e620add.tar.gz ManaVerse-e0370f84531ba564224963f579921b126e620add.tar.bz2 ManaVerse-e0370f84531ba564224963f579921b126e620add.tar.xz ManaVerse-e0370f84531ba564224963f579921b126e620add.zip |
eathena: add packet SMSG_PLAYER_INVENTORY_REMOVE2 0x07fa.
Diffstat (limited to 'src/net/eathena/inventoryhandler.cpp')
-rw-r--r-- | src/net/eathena/inventoryhandler.cpp | 31 |
1 files changed, 30 insertions, 1 deletions
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 |