diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-09-12 19:27:29 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-09-13 17:41:29 +0300 |
commit | cb23bcec8f8a1d8863ab25adc39a58415e5be88c (patch) | |
tree | ef02b4c3e9028eac10118101aa090f4ad8a9d96e /src/net/eathena | |
parent | ba54aed00801d29e4b5b6c77e1aed23a038ba7e6 (diff) | |
download | plus-cb23bcec8f8a1d8863ab25adc39a58415e5be88c.tar.gz plus-cb23bcec8f8a1d8863ab25adc39a58415e5be88c.tar.bz2 plus-cb23bcec8f8a1d8863ab25adc39a58415e5be88c.tar.xz plus-cb23bcec8f8a1d8863ab25adc39a58415e5be88c.zip |
In inventoryhandler use for each packet own function.
Diffstat (limited to 'src/net/eathena')
-rw-r--r-- | src/net/eathena/inventoryhandler.cpp | 87 | ||||
-rw-r--r-- | src/net/eathena/inventoryhandler.h | 2 |
2 files changed, 54 insertions, 35 deletions
diff --git a/src/net/eathena/inventoryhandler.cpp b/src/net/eathena/inventoryhandler.cpp index 6b4a54abe..646ecef97 100644 --- a/src/net/eathena/inventoryhandler.cpp +++ b/src/net/eathena/inventoryhandler.cpp @@ -82,10 +82,13 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg) switch (msg.getId()) { case SMSG_PLAYER_INVENTORY: - case SMSG_PLAYER_STORAGE_ITEMS: processPlayerInventory(msg); break; + case SMSG_PLAYER_STORAGE_ITEMS: + processPlayerStorage(msg); + break; + case SMSG_PLAYER_STORAGE_EQUIP: processPlayerStorageEquip(msg); break; @@ -377,38 +380,26 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg) void InventoryHandler::processPlayerInventory(Net::MessageIn &msg) { BLOCK_START("InventoryHandler::processPlayerInventory") - const bool playerInvintory = msg.getId() == SMSG_PLAYER_INVENTORY; Inventory *const inventory = localPlayer ? PlayerInfo::getInventory() : nullptr; - if (playerInvintory) + if (PlayerInfo::getEquipment()) { - if (PlayerInfo::getEquipment()) - { - // Clear inventory - this will be a complete refresh - mEquips.clear(); - PlayerInfo::getEquipment()->setBackend(&mEquips); - } - - if (inventory) - inventory->clear(); - } - else - { - mInventoryItems.clear(); + // Clear inventory - this will be a complete refresh + mEquips.clear(); + PlayerInfo::getEquipment()->setBackend(&mEquips); } - msg.readInt16("len"); + if (inventory) + inventory->clear(); - if (!playerInvintory) - msg.readString(24, "storage name"); + msg.readInt16("len"); const int number = (msg.getLength() - 4) / 23; const uint8_t identified = 1; for (int loop = 0; loop < number; loop++) { - const int index = msg.readInt16("item index") - (playerInvintory - ? INVENTORY_OFFSET : STORAGE_OFFSET); + const int index = msg.readInt16("item index") - INVENTORY_OFFSET; const int itemId = msg.readInt16("item id"); msg.readUInt8("item type"); const int amount = msg.readInt16("count"); @@ -421,26 +412,52 @@ void InventoryHandler::processPlayerInventory(Net::MessageIn &msg) msg.readInt8("flags"); // need get actual identify flag - if (playerInvintory) - { - // Trick because arrows are not considered equipment -// const bool isEquipment = arrow & 0x8000; - - if (inventory) - { - inventory->setItem(index, itemId, amount, - 0, identified, false); - } - } - else + // Trick because arrows are not considered equipment +// const bool isEquipment = arrow & 0x8000; + + if (inventory) { - mInventoryItems.push_back(Ea::InventoryItem(index, itemId, - amount, 0, identified, false)); + inventory->setItem(index, itemId, amount, + 0, identified, false); } } BLOCK_END("InventoryHandler::processPlayerInventory") } +void InventoryHandler::processPlayerStorage(Net::MessageIn &msg) +{ + BLOCK_START("InventoryHandler::processPlayerInventory") + Inventory *const inventory = localPlayer + ? PlayerInfo::getInventory() : nullptr; + mInventoryItems.clear(); + + msg.readInt16("len"); + msg.readString(24, "storage name"); + + const int number = (msg.getLength() - 4) / 23; + const uint8_t identified = 1; + + for (int loop = 0; loop < number; loop++) + { + const int index = msg.readInt16("item index") - STORAGE_OFFSET; + const int itemId = msg.readInt16("item id"); + msg.readUInt8("item type"); + const int amount = msg.readInt16("count"); + msg.readInt32("wear state / equip"); + msg.readInt16("card0"); + msg.readInt16("card1"); + msg.readInt16("card2"); + msg.readInt16("card3"); + msg.readInt32("hire expire date (?)"); + msg.readInt8("flags"); + + // need get actual identify flag + mInventoryItems.push_back(Ea::InventoryItem(index, itemId, + amount, 0, identified, false)); + } + BLOCK_END("InventoryHandler::processPlayerInventory") +} + void InventoryHandler::processPlayerEquip(Net::MessageIn &msg) { BLOCK_START("InventoryHandler::processPlayerEquip") diff --git a/src/net/eathena/inventoryhandler.h b/src/net/eathena/inventoryhandler.h index a35293aa4..ae4f864d6 100644 --- a/src/net/eathena/inventoryhandler.h +++ b/src/net/eathena/inventoryhandler.h @@ -70,6 +70,8 @@ class InventoryHandler final : public MessageHandler, void processPlayerInventory(Net::MessageIn &msg); + void processPlayerStorage(Net::MessageIn &msg); + void processPlayerEquip(Net::MessageIn &msg); void processPlayerUnEquip(Net::MessageIn &msg); |