summaryrefslogtreecommitdiff
path: root/src/net/ea/inventoryhandler.h
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/net/ea/inventoryhandler.h
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/net/ea/inventoryhandler.h')
-rw-r--r--src/net/ea/inventoryhandler.h17
1 files changed, 16 insertions, 1 deletions
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: