diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | src/equipment.cpp | 18 | ||||
-rw-r--r-- | src/equipment.h | 4 | ||||
-rw-r--r-- | src/inventory.cpp | 8 | ||||
-rw-r--r-- | src/localplayer.cpp | 3 | ||||
-rw-r--r-- | src/net/equipmenthandler.cpp | 59 | ||||
-rw-r--r-- | src/net/inventoryhandler.cpp | 10 |
7 files changed, 50 insertions, 57 deletions
@@ -1,3 +1,8 @@ +2008-08-17 Lloyd Bryant ("Sanga") <sanga@aethyra.com> + + * Fixed issues with unequipping some arrows failing. + * Removed hard-coded item ID's from several files + 2008-08-16 Lloyd Bryant ("Sanga") <sanga@aethyra.com> * Fixed bug where client would crash if another player diff --git a/src/equipment.cpp b/src/equipment.cpp index 0a285447..08e6fad1 100644 --- a/src/equipment.cpp +++ b/src/equipment.cpp @@ -41,6 +41,13 @@ Equipment::removeEquipment(Item *item) if (i != mEquipment + EQUIPMENT_SIZE) { *i = 0; } + item->setEquipped(false); +} + +void Equipment::removeEquipment(int index) +{ + mEquipment[index]->setEquipped(false); + mEquipment[index] = 0; } void Equipment::setEquipment(int index, Item *item) @@ -48,3 +55,14 @@ void Equipment::setEquipment(int index, Item *item) mEquipment[index] = item; item->setEquipped(true); } + +void Equipment::setArrows(Item *arrows) +{ + if (mArrows) + mArrows->setEquipped(false); + + mArrows = arrows; + + if (arrows) + arrows->setEquipped(true); +} diff --git a/src/equipment.h b/src/equipment.h index 04017549..fd7a9c1e 100644 --- a/src/equipment.h +++ b/src/equipment.h @@ -52,7 +52,7 @@ class Equipment * Remove equipment from the given slot. */ void - removeEquipment(int index) { mEquipment[index] = 0; } + removeEquipment(int index); /** * Remove the given item from equipment. @@ -69,7 +69,7 @@ class Equipment * Set the item used in the arrow slot. */ void - setArrows(Item *arrows) { mArrows = arrows; } + setArrows(Item *arrows); private: Item *mEquipment[EQUIPMENT_SIZE]; diff --git a/src/inventory.cpp b/src/inventory.cpp index e6f006de..20958c44 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -80,14 +80,6 @@ void Inventory::setItem(int index, int id, int quantity, bool equipment) return; } - /* TODO: Check where to reenable this code. - // Dont stack equipment other than arrows. - if (equipment && !(id == 1199 || id == 529)) - mItems[index].setQuantity(quantity); - else - mItems[index].increaseQuantity(quantity); - */ - if (!mItems[index] && id > 0) { Item *item = new Item(id, quantity, equipment); item->setInvIndex(index); diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 571cc21b..7b0c2b8b 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -142,9 +142,6 @@ void LocalPlayer::unequipItem(Item *item) MessageOut outMsg(mNetwork); outMsg.writeInt16(CMSG_PLAYER_UNEQUIP); outMsg.writeInt16(item->getInvIndex()); - - // Tidy equipment directly to avoid weapon still shown bug, for instance - mEquipment->removeEquipment(item); } void LocalPlayer::useItem(Item *item) 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); } |