diff options
Diffstat (limited to 'src/net/ea/equipmenthandler.cpp')
-rw-r--r-- | src/net/ea/equipmenthandler.cpp | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/src/net/ea/equipmenthandler.cpp b/src/net/ea/equipmenthandler.cpp index f81bf7ed..d30b2681 100644 --- a/src/net/ea/equipmenthandler.cpp +++ b/src/net/ea/equipmenthandler.cpp @@ -35,6 +35,8 @@ #include "utils/gettext.h" +enum { debugEquipment = 1 }; + EquipmentHandler::EquipmentHandler() { static const Uint16 _messages[] = { @@ -65,7 +67,7 @@ void EquipmentHandler::handleMessage(MessageIn &msg) for (int loop = 0; loop < itemCount; loop++) { - index = msg.readInt16(); + index = msg.readInt16() - INVENTORY_OFFSET; itemId = msg.readInt16(); msg.readInt8(); // type msg.readInt8(); // identify flag @@ -75,6 +77,11 @@ void EquipmentHandler::handleMessage(MessageIn &msg) msg.readInt8(); // refine msg.skip(8); // card + if (debugEquipment) + { + logger->log("Index: %d, ID: %d", index, itemId); + } + inventory->setItem(index, itemId, 1, true); if (equipPoint) @@ -93,21 +100,19 @@ void EquipmentHandler::handleMessage(MessageIn &msg) break; case SMSG_PLAYER_EQUIP: - index = msg.readInt16(); + index = msg.readInt16() - INVENTORY_OFFSET; equipPoint = msg.readInt16(); type = msg.readInt8(); - logger->log("Equipping: %i %i %i", index, equipPoint, type); - - if (!type) { + if (!type) + { localChatTab->chatLog(_("Unable to equip."), BY_SERVER); break; } - if (!equipPoint) { - // No point given, no point in searching + // No point in searching when no point given + if (!equipPoint) break; - } /* * An item may occupy more than 1 slot. If so, it's @@ -119,21 +124,25 @@ void EquipmentHandler::handleMessage(MessageIn &msg) mask <<= 1; position++; } - logger->log("Position %i", position); - item = player_node->getInventory()->getItem(player_node->mEquipment->getEquipment(position)); + if (debugEquipment) + { + logger->log("Equipping: %i %i %i at position %i", + index, equipPoint, type, position); + } + + item = inventory->getItem(player_node->mEquipment->getEquipment(position)); // Unequip any existing equipped item in this position - if (item) { + if (item) item->setEquipped(false); - } item = inventory->getItem(index); player_node->mEquipment->setEquipment(position, index); break; case SMSG_PLAYER_UNEQUIP: - index = msg.readInt16(); + index = msg.readInt16() - INVENTORY_OFFSET; equipPoint = msg.readInt16(); type = msg.readInt8(); @@ -166,8 +175,12 @@ void EquipmentHandler::handleMessage(MessageIn &msg) else { player_node->mEquipment->removeEquipment(position); } - logger->log("Unequipping: %i %i(%i) %i", - index, equipPoint, type, position); + + if (debugEquipment) + { + logger->log("Unequipping: %i %i(%i) %i", + index, equipPoint, type, position); + } break; case SMSG_PLAYER_ATTACK_RANGE: @@ -180,6 +193,8 @@ void EquipmentHandler::handleMessage(MessageIn &msg) if (index <= 1) break; + index -= INVENTORY_OFFSET; + item = inventory->getItem(index); if (item) { |