Planeshift
psinventorycache.h
Go to the documentation of this file.
1 
19 #ifndef PS_INVENTORY_CACHE
20 #define PS_INVENTORY_CACHE
21 
22 #include "util/pscache.h"
23 
27 class psInventoryCache : public psCache
28 {
29 public:
32 
34  {
35  int slot;
37  csString name;
38  csString meshName;
39  csString materialName;
40  float weight;
41  float size;
43  csString iconImage;
45 
46  static int CompareSlot(CachedItemDescription* const &first, CachedItemDescription* const &second);
47  };
48 
57  bool GetInventory (void);
58 
74  bool SetInventoryItem(int slot,
75  int containerID,
76  csString name,
77  csString meshName,
78  csString materialName,
79  float weight,
80  float size,
81  int stackCount,
82  csString iconImage,
83  int purifyStatus);
84 
92  bool EmptyInventoryItem(int slot, int container);
93 
97  void EmptyInventory(void);
98 
106  bool MoveItem(int from_containerID, int from_slot,
107  int to_containerID, int to_slot, int stackCount);
108 
115 
118  inline uint32 GetInventoryVersion() const
119  {
120  return version;
121  }
122 
125  inline void SetInventoryVersion(uint32 ver)
126  {
127  version = ver;
128  }
129 
130 
134  csHash<CachedItemDescription*>::GlobalIterator GetHashIterator()
135  {
136  return itemhash.GetIterator();
137  }
138 
142  csArray<CachedItemDescription*>::Iterator GetSortedIterator()
143  {
144  return itemBySlot.GetIterator();
145  }
146 
147 private:
148 
149  csHash<CachedItemDescription*> itemhash; // all cached items in equip, bulk or containers
150 
151  csArray<CachedItemDescription*> itemBySlot; // all cached items sorted by slot number
152 
153  // CachedItemDescription bulkItems[INVENTORY_BULK_COUNT]; /// cached bulk items
154  // CachedItemDescription equipItems[INVENTORY_EQUIP_COUNT]; /// cached equip items
155 
156  uint32 version; // Current cache version (PS#2691)
157 };
158 
159 #endif
160 
bool GetInventory(void)
Requests inventory from server.
void EmptyInventory(void)
Empty entire inventory.
csArray< CachedItemDescription * >::Iterator GetSortedIterator()
Return iterator to all cache item sorted by slot.
CachedItemDescription * GetInventoryItem(int slot)
Get item from container slot.
uint32 GetInventoryVersion() const
inline uint32 GetInventoryVersion() const Info: Returns the cache version (PS#2691) ...
void SetInventoryVersion(uint32 ver)
inline void SetInventoryVersion(uint32 ver) Info: Sets the cache version (PS#2691) ...
psinventorycache.h
bool EmptyInventoryItem(int slot, int container)
Set empty slot.
bool SetInventoryItem(int slot, int containerID, csString name, csString meshName, csString materialName, float weight, float size, int stackCount, csString iconImage, int purifyStatus)
Store an item in the inventory.
bool MoveItem(int from_containerID, int from_slot, int to_containerID, int to_slot, int stackCount)
Move items from one slot to another.
csHash< CachedItemDescription * >::GlobalIterator GetHashIterator()
Return iterator to all cache items.
psCache
Definition: pscache.h:33
static int CompareSlot(CachedItemDescription *const &first, CachedItemDescription *const &second)