diff options
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/inventorydata.h | 38 | ||||
-rw-r--r-- | src/common/manaserv_protocol.h | 8 |
2 files changed, 17 insertions, 29 deletions
diff --git a/src/common/inventorydata.h b/src/common/inventorydata.h index b410b3fb..5d1d9388 100644 --- a/src/common/inventorydata.h +++ b/src/common/inventorydata.h @@ -23,6 +23,7 @@ #include <vector> #include <map> +#include <set> /** * Numbers of inventory slots @@ -36,38 +37,23 @@ struct InventoryItem { InventoryItem(): - itemId(0), amount(0) + slot(0), + itemId(0), + amount(0), + equipmentSlot(0) {} + unsigned slot; unsigned itemId; unsigned amount; -}; - -struct EquipmentItem -{ - EquipmentItem(): - itemId(0), itemInstance(0) - {} - - EquipmentItem(unsigned itemId, unsigned itemInstance) - { - this->itemId = itemId; - this->itemInstance = itemInstance; - } - - // The item id taken from the item db. - unsigned itemId; - // A unique instance number used to separate items when equipping the same - // item id multiple times on possible multiple slots. - unsigned itemInstance; + unsigned equipmentSlot; /** 0 if not equipped */ }; // inventory slot id -> { item } typedef std::map< unsigned, InventoryItem > InventoryData; -// equip slot id -> { item id, item instance } -// Equipment taking up multiple equip slot ids will be referenced multiple times -typedef std::multimap< unsigned, EquipmentItem > EquipData; +// the slots which are equipped +typedef std::set<int> EquipData; /** * Structure storing the equipment and inventory of a Player. @@ -77,7 +63,7 @@ struct Possessions friend class Inventory; public: const EquipData &getEquipment() const - { return equipSlots; } + { return equipment; } const InventoryData &getInventory() const { return inventory; } @@ -86,13 +72,13 @@ public: * Should be done only at character serialization and storage load time. */ void setEquipment(EquipData &equipData) - { equipSlots.swap(equipData); } + { equipment.swap(equipData); } void setInventory(InventoryData &inventoryData) { inventory.swap(inventoryData); } private: InventoryData inventory; - EquipData equipSlots; + EquipData equipment; }; #endif diff --git a/src/common/manaserv_protocol.h b/src/common/manaserv_protocol.h index 50bfdd84..1d5c7e56 100644 --- a/src/common/manaserv_protocol.h +++ b/src/common/manaserv_protocol.h @@ -113,10 +113,12 @@ enum { PGMSG_DROP = 0x0111, // W slot, W amount PGMSG_EQUIP = 0x0112, // W inventory slot PGMSG_UNEQUIP = 0x0113, // W item Instance id - PGMSG_MOVE_ITEM = 0x0114, // W slot1, W slot2, W amount GPMSG_INVENTORY = 0x0120, // { W slot, W item id [, W amount] (if item id is nonzero) }* - GPMSG_INVENTORY_FULL = 0x0121, // W inventory slot count { W slot, W itemId, W amount }, { W equip slot, W item Id, W item Instance}* - GPMSG_EQUIP = 0x0122, // W item Id, W equip slot type count //{ W equip slot, W capacity used}*//<- When equipping, //{ W item instance, W 0}*//<- When unequipping + GPMSG_INVENTORY_FULL = 0x0121, // W inventory slot count { W slot, W itemId, W amount, W equipmentSlot } + GPMSG_EQUIP = 0x0122, // W equipped inventory slot, W slot equipmentSlot + GPMSG_EQUIP_RESPONSE = 0x0123, // B error, W slot + GPMSG_UNEQUIP = 0x0124, // W equipped inventory slot + GPMSG_UNEQUIP_RESPONE = 0x0125, // B error, W slot GPMSG_PLAYER_ATTRIBUTE_CHANGE = 0x0130, // { W attribute, D base value (in 1/256ths), D modified value (in 1/256ths)}* GPMSG_ATTRIBUTE_POINTS_STATUS = 0x0140, // W character points, W correction points PGMSG_RAISE_ATTRIBUTE = 0x0160, // W attribute |