diff options
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/equipmenthandler.cpp | 59 | ||||
-rw-r--r-- | src/net/inventoryhandler.cpp | 10 |
2 files changed, 25 insertions, 44 deletions
diff --git a/src/net/equipmenthandler.cpp b/src/net/equipmenthandler.cpp index 7b15ee8b..cc5d016c 100644 --- a/src/net/equipmenthandler.cpp +++ b/src/net/equipmenthandler.cpp @@ -109,7 +109,10 @@ void EquipmentHandler::handleMessage(MessageIn *msg) break; } - // Unequip any existing equipped item in this position + /* + * An item may occupy more than 1 slot. If so, it's + * only shown as equipped on the *first* slot. + */ mask = 1; position = 0; while (!(equipPoint & mask)) { @@ -118,6 +121,8 @@ void EquipmentHandler::handleMessage(MessageIn *msg) } logger->log("Position %i", position); item = player_node->mEquipment->getEquipment(position); + + // Unequip any existing equipped item in this position if (item) { item->setEquipped(false); } @@ -141,37 +146,17 @@ void EquipmentHandler::handleMessage(MessageIn *msg) break; } - mask = 1; - position = 0; - while (!(equipPoint & mask)) { - mask <<= 1; - position++; - } - - item = inventory->getItem(index); - if (!item) - break; - - item->setEquipped(false); - - switch (item->getId()) { - case 529: - case 1199: - player_node->mEquipment->setArrows(NULL); - break; - case 521: - case 522: - case 530: - case 536: - case 1200: - case 1201: - player_node->setSprite(Being::WEAPON_SPRITE, 0); - // TODO: Why this break? Shouldn't a weapon be - // unequipped in inventory too? - break; - default: - player_node->mEquipment->removeEquipment(position); - break; + if (equipPoint & 0x8000) { // Arrows + player_node->mEquipment->setArrows(NULL); + position = 11; + } else { + mask = 1; + position = 0; + while (!(equipPoint & mask)) { + mask <<= 1; + position++; + } + player_node->mEquipment->removeEquipment(position); } logger->log("Unequipping: %i %i(%i) %i", index, equipPoint, type, position); @@ -188,12 +173,10 @@ void EquipmentHandler::handleMessage(MessageIn *msg) break; item = inventory->getItem(index); - if (!item) - break; - - item->setEquipped(true); - player_node->mEquipment->setArrows(item); - logger->log("Arrows equipped: %i", index); + if (item) { + player_node->mEquipment->setArrows(item); + logger->log("Arrows equipped: %i", index); + } break; } } diff --git a/src/net/inventoryhandler.cpp b/src/net/inventoryhandler.cpp index c0661710..37ae5fb9 100644 --- a/src/net/inventoryhandler.cpp +++ b/src/net/inventoryhandler.cpp @@ -55,7 +55,7 @@ InventoryHandler::InventoryHandler() void InventoryHandler::handleMessage(MessageIn *msg) { Sint32 number; - Sint16 index, amount, itemId, equipType; + Sint16 index, amount, itemId, equipType, arrow; Inventory *inventory = player_node->getInventory(); switch (msg->getId()) @@ -67,21 +67,19 @@ void InventoryHandler::handleMessage(MessageIn *msg) msg->readInt16(); // length number = (msg->getLength() - 4) / 18; - for (int loop = 0; loop < number; loop++) - { + for (int loop = 0; loop < number; loop++) { index = msg->readInt16(); itemId = msg->readInt16(); msg->readInt8(); // type msg->readInt8(); // identify flag amount = msg->readInt16(); - msg->skip(2); // unknown + arrow = msg->readInt16(); msg->skip(8); // card (4 shorts) inventory->setItem(index, itemId, amount, false); // Trick because arrows are not considered equipment - if (itemId == 1199 || itemId == 529) - { + if (arrow & 0x8000) { if (Item *item = inventory->getItem(index)) item->setEquipment(true); } |