diff options
author | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-08-18 02:24:44 +0200 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-08-18 02:24:44 +0200 |
commit | f8551d9ef4a745327bccb9e4cb54a22f6a28cf80 (patch) | |
tree | 9af300838e58e2e2c7aeaca5765e7dbbb30d8b6d /src/net/manaserv/inventoryhandler.h | |
parent | 3b7740f133e195b0a0b11090ea8c2b8a7b64411c (diff) | |
download | mana-f8551d9ef4a745327bccb9e4cb54a22f6a28cf80.tar.gz mana-f8551d9ef4a745327bccb9e4cb54a22f6a28cf80.tar.bz2 mana-f8551d9ef4a745327bccb9e4cb54a22f6a28cf80.tar.xz mana-f8551d9ef4a745327bccb9e4cb54a22f6a28cf80.zip |
Made the client able to successfully equip/unequip!
Diffstat (limited to 'src/net/manaserv/inventoryhandler.h')
-rw-r--r-- | src/net/manaserv/inventoryhandler.h | 53 |
1 files changed, 43 insertions, 10 deletions
diff --git a/src/net/manaserv/inventoryhandler.h b/src/net/manaserv/inventoryhandler.h index a57b493a..aed41d6c 100644 --- a/src/net/manaserv/inventoryhandler.h +++ b/src/net/manaserv/inventoryhandler.h @@ -38,26 +38,59 @@ 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(); } + + void triggerUnequip(int slotIndex) const; + private: void readEquipFile(); - struct SlotType { + struct Slot { + Slot(): + item(0), + slotTypeId(0), + subId(0), + itemInstance(0) + {} + + // 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; + }; + + // slot client index, slot info + typedef std::map<unsigned int, Slot> Slots; + Slots mSlots; }; class InventoryHandler : public MessageHandler, Net::InventoryHandler, |