summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
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: