summaryrefslogtreecommitdiff
path: root/src/net/ea/inventoryhandler.h
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-12-07 11:34:29 -0700
committerJared Adams <jaxad0127@gmail.com>2009-12-07 11:34:29 -0700
commit2f310b3040dcb56bd9ed1868dfa4f74b3fd00136 (patch)
tree81957f3eef8130b51e3dd85578ef18f56c274139 /src/net/ea/inventoryhandler.h
parentfc48c24c6d366e165cbcfbd022d9421790089890 (diff)
downloadmana-2f310b3040dcb56bd9ed1868dfa4f74b3fd00136.tar.gz
mana-2f310b3040dcb56bd9ed1868dfa4f74b3fd00136.tar.bz2
mana-2f310b3040dcb56bd9ed1868dfa4f74b3fd00136.tar.xz
mana-2f310b3040dcb56bd9ed1868dfa4f74b3fd00136.zip
Simplify Equipment handling
Also merge eAthena's EquipmentHandler and InventoryHander. Fixes http://mantis.themanaworld.org/view.php?id=888 .
Diffstat (limited to 'src/net/ea/inventoryhandler.h')
-rw-r--r--src/net/ea/inventoryhandler.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/net/ea/inventoryhandler.h b/src/net/ea/inventoryhandler.h
index 83a2b440..82c2a36e 100644
--- a/src/net/ea/inventoryhandler.h
+++ b/src/net/ea/inventoryhandler.h
@@ -27,8 +27,53 @@
#include "net/ea/messagehandler.h"
+#include "equipment.h"
+#include "inventory.h"
+#include "localplayer.h"
+
namespace EAthena {
+class EquipBackend : public Equipment::Backend {
+ public:
+ Item *getEquipment(int index) const
+ {
+ int invyIndex = mEquipment[index];
+ if (invyIndex == 0)
+ {
+ return NULL;
+ }
+ return player_node->getInventory()->getItem(invyIndex);
+ }
+
+ void clear()
+ {
+ for (int i = 0; i < EQUIPMENT_SIZE; i++)
+ {
+ if (mEquipment[i])
+ {
+ Item* item = player_node->getInventory()->getItem(i);
+ if (item)
+ {
+ item->setEquipped(false);
+ }
+ }
+
+ mEquipment[i] = 0;
+ }
+ }
+
+ void setEquipment(int index, int inventoryIndex)
+ {
+ mEquipment[index] = inventoryIndex;
+ Item* item = player_node->getInventory()->getItem(inventoryIndex);
+ if (item)
+ item->setEquipped(true);
+ }
+
+ private:
+ int mEquipment[EQUIPMENT_SIZE];
+};
+
class InventoryHandler : public MessageHandler, public Net::InventoryHandler
{
public:
@@ -58,6 +103,9 @@ class InventoryHandler : public MessageHandler, public Net::InventoryHandler
StorageType destination);
size_t getSize(StorageType type) const;
+
+ private:
+ EquipBackend mEquips;
};
} // namespace EAthena