diff options
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 a57b493a..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 itemId, int equipSlot, int amountUsed = 1); - void unequip(int equipSlot); + 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; }; |