summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-12-07 14:16:26 -0700
committerJared Adams <jaxad0127@gmail.com>2009-12-07 14:16:26 -0700
commit4d9bbc8d2eea82fb4e60634b611d0058f74ebb82 (patch)
tree42ecc3776564cca78e99a9e562ab0b1009190fbe /src
parent2f310b3040dcb56bd9ed1868dfa4f74b3fd00136 (diff)
downloadmana-client-4d9bbc8d2eea82fb4e60634b611d0058f74ebb82.tar.gz
mana-client-4d9bbc8d2eea82fb4e60634b611d0058f74ebb82.tar.bz2
mana-client-4d9bbc8d2eea82fb4e60634b611d0058f74ebb82.tar.xz
mana-client-4d9bbc8d2eea82fb4e60634b611d0058f74ebb82.zip
Fix bugs in eAthena's equipment handling
Do a bit of cleanup too.
Diffstat (limited to 'src')
-rw-r--r--src/inventory.cpp1
-rw-r--r--src/net/ea/inventoryhandler.cpp14
-rw-r--r--src/net/ea/inventoryhandler.h17
3 files changed, 23 insertions, 9 deletions
diff --git a/src/inventory.cpp b/src/inventory.cpp
index 202c3e52..0e5108ac 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -83,7 +83,6 @@ void Inventory::setItem(int index, int id, int quantity, bool equipment)
Item *item = new Item(id, quantity, equipment);
item->setInvIndex(index);
mItems[index] = item;
- mItems[index]->setEquipment(equipment);
}
else if (id > 0)
{
diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp
index d7758321..faf0183a 100644
--- a/src/net/ea/inventoryhandler.cpp
+++ b/src/net/ea/inventoryhandler.cpp
@@ -341,7 +341,10 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg)
inventory->setItem(index, itemId, 1, true);
- mEquips.setEquipment(getSlot(equipType), index);
+ if (equipType)
+ {
+ mEquips.setEquipment(getSlot(equipType), index);
+ }
}
break;
@@ -370,7 +373,7 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg)
}
else
{
- mEquips.setEquipment(getSlot(equipType), 0);
+ mEquips.setEquipment(getSlot(equipType), -1);
}
break;
@@ -404,11 +407,8 @@ void InventoryHandler::equipItem(const Item *item)
void InventoryHandler::unequipItem(const Item *item)
{
- /*const Item *real_item = item->isInEquipment() ? getRealEquipedItem(item)
- : item;
-
- if (!real_item)
- return;*/
+ if (!item)
+ return;
MessageOut outMsg(CMSG_PLAYER_UNEQUIP);
outMsg.writeInt16(item->getInvIndex() + INVENTORY_OFFSET);
diff --git a/src/net/ea/inventoryhandler.h b/src/net/ea/inventoryhandler.h
index 82c2a36e..709d6b53 100644
--- a/src/net/ea/inventoryhandler.h
+++ b/src/net/ea/inventoryhandler.h
@@ -35,6 +35,11 @@ namespace EAthena {
class EquipBackend : public Equipment::Backend {
public:
+ EquipBackend()
+ {
+ memset(mEquipment, -1, sizeof(mEquipment));
+ }
+
Item *getEquipment(int index) const
{
int invyIndex = mEquipment[index];
@@ -64,10 +69,20 @@ class EquipBackend : public Equipment::Backend {
void setEquipment(int index, int inventoryIndex)
{
+ // Unequip existing item
+ Item* item = player_node->getInventory()->getItem(mEquipment[index]);
+ if (item)
+ {
+ item->setEquipped(false);
+ }
+
mEquipment[index] = inventoryIndex;
- Item* item = player_node->getInventory()->getItem(inventoryIndex);
+
+ item = player_node->getInventory()->getItem(inventoryIndex);
if (item)
+ {
item->setEquipped(true);
+ }
}
private: