summaryrefslogtreecommitdiff
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
parent7092b86c5b9bcfc1b377d090f65ce35427cecc4c (diff)
downloadmanaplus-e0370f84531ba564224963f579921b126e620add.tar.gz
manaplus-e0370f84531ba564224963f579921b126e620add.tar.bz2
manaplus-e0370f84531ba564224963f579921b126e620add.tar.xz
manaplus-e0370f84531ba564224963f579921b126e620add.zip
eathena: add packet SMSG_PLAYER_INVENTORY_REMOVE2 0x07fa.
-rw-r--r--src/net/eathena/inventoryhandler.cpp31
-rw-r--r--src/net/eathena/inventoryhandler.h2
-rw-r--r--src/net/eathena/packets.h2
-rw-r--r--src/net/eathena/protocol.h1
4 files changed, 34 insertions, 2 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
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