diff options
author | Philipp Sehmisch <crush@themanaworld.org> | 2009-03-29 18:33:44 +0200 |
---|---|---|
committer | Philipp Sehmisch <crush@themanaworld.org> | 2009-03-29 18:33:44 +0200 |
commit | 9587fb9b86ee4081ba14d23c1133bf1a09ee4578 (patch) | |
tree | 7682df3ec17534be553caae85ffa9e5a68c9a815 /src/net/ea/equipmenthandler.cpp | |
parent | 63b41440a0555c6b39141eab94ef4627f712b476 (diff) | |
parent | 8748f26234bba1e71bbe059147fb02256f8cec2a (diff) | |
download | mana-client-9587fb9b86ee4081ba14d23c1133bf1a09ee4578.tar.gz mana-client-9587fb9b86ee4081ba14d23c1133bf1a09ee4578.tar.bz2 mana-client-9587fb9b86ee4081ba14d23c1133bf1a09ee4578.tar.xz mana-client-9587fb9b86ee4081ba14d23c1133bf1a09ee4578.zip |
Merge branch 'master' of git@gitorious.org:tmw/mainline
Diffstat (limited to 'src/net/ea/equipmenthandler.cpp')
-rw-r--r-- | src/net/ea/equipmenthandler.cpp | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/src/net/ea/equipmenthandler.cpp b/src/net/ea/equipmenthandler.cpp index 7a287bea..d30b2681 100644 --- a/src/net/ea/equipmenthandler.cpp +++ b/src/net/ea/equipmenthandler.cpp @@ -31,10 +31,12 @@ #include "localplayer.h" #include "log.h" -#include "gui/chat.h" +#include "gui/widgets/chattab.h" #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) { |