diff options
Diffstat (limited to 'src/net/eathena/inventoryhandler.cpp')
-rw-r--r-- | src/net/eathena/inventoryhandler.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/net/eathena/inventoryhandler.cpp b/src/net/eathena/inventoryhandler.cpp index 7e10bc69d..3bdedcb8f 100644 --- a/src/net/eathena/inventoryhandler.cpp +++ b/src/net/eathena/inventoryhandler.cpp @@ -22,6 +22,8 @@ #include "net/eathena/inventoryhandler.h" +#include "being/localplayer.h" + #include "net/eathena/messageout.h" #include "net/eathena/protocol.h" @@ -202,4 +204,50 @@ void InventoryHandler::moveItem2(const int source, const int slot, } } +void InventoryHandler::processPlayerEquipment(Net::MessageIn &msg) +{ + BLOCK_START("InventoryHandler::processPlayerEquipment") + Inventory *const inventory = localPlayer + ? PlayerInfo::getInventory() : nullptr; + + msg.readInt16(); // length + Equipment *const equipment = PlayerInfo::getEquipment(); + if (equipment && !equipment->getBackend()) + { // look like SMSG_PLAYER_INVENTORY was not received + mEquips.clear(); + equipment->setBackend(&mEquips); + } + const int number = (msg.getLength() - 4) / 20; + + for (int loop = 0; loop < number; loop++) + { + const int index = msg.readInt16() - INVENTORY_OFFSET; + const int itemId = msg.readInt16(); + const uint8_t itemType = msg.readUInt8(); // type + uint8_t identified = msg.readUInt8(); // identify flag + + msg.readInt16(); // equip type + const int equipType = msg.readInt16(); + msg.readUInt8(); // attribute + const uint8_t refine = msg.readUInt8(); + msg.skip(8); // card + + if (mDebugInventory) + { + logger->log("Index: %d, ID: %d, Type: %d, Identified: %d", + index, itemId, itemType, identified); + } + + if (inventory) + { + inventory->setItem(index, itemId, 1, refine, + identified, true); + } + + if (equipType) + mEquips.setEquipment(getSlot(equipType), index); + } + BLOCK_END("InventoryHandler::processPlayerEquipment") +} + } // namespace EAthena |