diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-03-27 23:25:43 +0100 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-03-27 23:28:19 +0100 |
commit | 4f02ad59df9ee3314fb0d429a031ecbfa3206e3a (patch) | |
tree | 90b7afc312b7385061d25db753e8d1e500c83e69 /src/net/ea/equipmenthandler.cpp | |
parent | f67237cb69599753192c301f0f2eb38b88f7b57a (diff) | |
download | mana-4f02ad59df9ee3314fb0d429a031ecbfa3206e3a.tar.gz mana-4f02ad59df9ee3314fb0d429a031ecbfa3206e3a.tar.bz2 mana-4f02ad59df9ee3314fb0d429a031ecbfa3206e3a.tar.xz mana-4f02ad59df9ee3314fb0d429a031ecbfa3206e3a.zip |
Moved the inventory and storage offset handling into netcode
No need to complicate the item containers and inventory classes with a
silly offset used by the eAthena server.
Also fixed the logToStandardOut option by reading it from the config
after the configuration has been initialized.
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) { |