diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-12-07 11:34:29 -0700 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-12-07 11:34:29 -0700 |
commit | 2f310b3040dcb56bd9ed1868dfa4f74b3fd00136 (patch) | |
tree | 81957f3eef8130b51e3dd85578ef18f56c274139 /src/equipment.h | |
parent | fc48c24c6d366e165cbcfbd022d9421790089890 (diff) | |
download | mana-client-2f310b3040dcb56bd9ed1868dfa4f74b3fd00136.tar.gz mana-client-2f310b3040dcb56bd9ed1868dfa4f74b3fd00136.tar.bz2 mana-client-2f310b3040dcb56bd9ed1868dfa4f74b3fd00136.tar.xz mana-client-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/equipment.h')
-rw-r--r-- | src/equipment.h | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/equipment.h b/src/equipment.h index c7058269..f76c0bc6 100644 --- a/src/equipment.h +++ b/src/equipment.h @@ -32,14 +32,14 @@ class Equipment /** * Constructor. */ - Equipment(); + Equipment(): mBackend(NULL) {} /** * Destructor. */ - ~Equipment(); + ~Equipment() { mBackend = NULL; } - enum EquipmentSlots + enum Slot { EQUIP_TORSO_SLOT = 0, EQUIP_GLOVES_SLOT = 1, @@ -55,24 +55,34 @@ class Equipment EQUIP_VECTOREND }; + class Backend { + public: + virtual Item *getEquipment(int index) const = 0; + virtual void clear() = 0; + }; + /** * Get equipment at the given slot. */ - Item *getEquipment(int index) - { return mEquipment[index]; } + Item *getEquipment(int index) const + { return mBackend ? mBackend->getEquipment(index) : 0; } /** * Clears equipment. */ - void clear(); + void clear() + { if (mBackend) mBackend->clear(); } /** * Set equipment at the given slot. */ void setEquipment(int index, int id, int quantity = 0); + void setBackend(Backend *backend) + { mBackend = backend; } + private: - Item *mEquipment[EQUIPMENT_SIZE]; + Backend *mBackend; }; #endif |