diff options
author | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-08-25 23:42:21 +0200 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-08-25 23:42:21 +0200 |
commit | 19f6ce87e69b42fb69a4739ce363e1346cd569ea (patch) | |
tree | 48a04a477ede925fd946ac62d36ccc92cf3df4e1 /src/net/manaserv/inventoryhandler.h | |
parent | 88e7a96bffe9758bb4f0916f6841b98f2cfccbfb (diff) | |
parent | 011135415f7f9c5cfeb220540621dfd1c46e6db9 (diff) | |
download | mana-client-19f6ce87e69b42fb69a4739ce363e1346cd569ea.tar.gz mana-client-19f6ce87e69b42fb69a4739ce363e1346cd569ea.tar.bz2 mana-client-19f6ce87e69b42fb69a4739ce363e1346cd569ea.tar.xz mana-client-19f6ce87e69b42fb69a4739ce363e1346cd569ea.zip |
Merge branch 'equipment-fix' of github.com:Bertram25/mana
Diffstat (limited to 'src/net/manaserv/inventoryhandler.h')
-rw-r--r-- | src/net/manaserv/inventoryhandler.h | 78 |
1 files changed, 68 insertions, 10 deletions
diff --git a/src/net/manaserv/inventoryhandler.h b/src/net/manaserv/inventoryhandler.h index 255f601c..bf3022ab 100644 --- a/src/net/manaserv/inventoryhandler.h +++ b/src/net/manaserv/inventoryhandler.h @@ -38,26 +38,75 @@ class EquipBackend : public Equipment::Backend, public EventListener public: EquipBackend(); - Item *getEquipment(int index) const; + Item *getEquipment(int slotIndex) const; + std::string getSlotName(int slotIndex) const; void clear(); - void equip(int inventorySlot, int equipSlot, int amountUsed = 1); - void unequip(int inventorySlot); + void equip(int itemId, int slotTypeId, int amountUsed = 1, + int itemInstance = 0); + void unequip(int slotTypeId); void event(Event::Channel channel, const Event &event); + int getSlotNumber() const + { return mSlots.size(); } + + unsigned int getVisibleSlotsNumber() const + { return mVisibleSlots; } + + void triggerUnequip(int slotIndex) const; + + bool isWeaponSlot(int slotTypeId) const; + bool isAmmoSlot(int slotTypeId) const; + private: void readEquipFile(); - struct SlotType { + struct Slot { + Slot(): + item(0), + slotTypeId(0), + subId(0), + itemInstance(0), + weaponSlot(false), + ammoSlot(false) + {} + + // Generic info std::string name; - int count; - bool visible; - int firstIndex; - }; - std::vector<Item*> mSlots; - std::vector<SlotType> mSlotTypes; + // The Item reference, used for graphical representation + // and info. + Item *item; + + // Manaserv specific info + + // Used to know which (server-side) slot id it is. + unsigned int slotTypeId; + // Static part + // The sub id is used to know in which order the slots are + // when the slotType has more than one slot capacity: + // I.e.: capacity = 6, subId will be between 1 and 6 + // for each slots in the map. + // This is used to sort the multimap along with the slot id. + unsigned int subId; + + // This is the (per character) unique item Id, used especially when + // equipping the same item multiple times on the same slot type. + unsigned int itemInstance; + + // Tell whether the slot is a weapon slot + bool weaponSlot; + + // Tell whether the slot is an ammo slot + bool ammoSlot; + }; + + unsigned int mVisibleSlots; + + // slot client index, slot info + typedef std::map<unsigned int, Slot> Slots; + Slots mSlots; }; class InventoryHandler : public MessageHandler, Net::InventoryHandler, @@ -74,6 +123,15 @@ class InventoryHandler : public MessageHandler, Net::InventoryHandler, size_t getSize(int type) const; + bool isWeaponSlot(unsigned int slotTypeId) const + { return mEquipBackend.isWeaponSlot(slotTypeId); } + + bool isAmmoSlot(unsigned int slotTypeId) const + { return mEquipBackend.isAmmoSlot(slotTypeId); } + + unsigned int getVisibleSlotsNumber() const + { return mEquipBackend.getVisibleSlotsNumber(); } + private: EquipBackend mEquipBackend; }; |