summaryrefslogtreecommitdiff
path: root/src/net/eathena/inventoryhandler.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-09-06 11:23:36 +0300
committerAndrei Karas <akaras@inbox.ru>2014-09-06 11:23:36 +0300
commite0370f84531ba564224963f579921b126e620add (patch)
treebcfc7eec4df22792ee6416e37e0983b83118a6b1 /src/net/eathena/inventoryhandler.cpp
parent7092b86c5b9bcfc1b377d090f65ce35427cecc4c (diff)
downloadplus-e0370f84531ba564224963f579921b126e620add.tar.gz
plus-e0370f84531ba564224963f579921b126e620add.tar.bz2
plus-e0370f84531ba564224963f579921b126e620add.tar.xz
plus-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.cpp31
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