Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2012-10-20 16:35:26 +0000
committerStijn Buys <ingar@osirion.org>2012-10-20 16:35:26 +0000
commit75274ebd6ba90784f5aa837b7e5ea97fc6bfb720 (patch)
treea5d51a87bf3f20833df18bc40a3254b946716afb /src/core/inventory.h
parentf01629dc14b1ee05b44d2e38b3dffbc1441fd85f (diff)
Item id based inventory, support for weapon dealers.
Diffstat (limited to 'src/core/inventory.h')
-rw-r--r--src/core/inventory.h29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/core/inventory.h b/src/core/inventory.h
index 80dbde1..3c3adfa 100644
--- a/src/core/inventory.h
+++ b/src/core/inventory.h
@@ -23,7 +23,7 @@ public:
/**
* @brief type definition for items in the inventory
*/
- typedef std::vector<Item *> Items;
+ typedef std::list<Item *> Items;
/**
* @brief default constructor
@@ -45,14 +45,21 @@ public:
};
/**
- * @brief return the timestamp of the last server update
- * This is a client-side property and shoul not be used server-side
+ * @brief return the timestamp of the last client-side update
+ * This is a client-side property
*/
inline const unsigned long timestamp() const {
return inventory_timestamp;
}
/**
+ * @brief return the timestamp of the last item erase
+ * */
+ inline const unsigned long timestamp_erase() const {
+ return inventory_timestamp_erase;
+ }
+
+ /**
* @brief return the maximal inventory capacity, in cubic meters
*/
inline const float capacity() const {
@@ -89,6 +96,11 @@ public:
* @brief search the inventory for a specific item type
*/
Item *find(const Info *info) const;
+
+ /**
+ * @brief search the inventory for a specific item id
+ */
+ Item *find(const unsigned int id) const;
/* ---- mutators --------------------------------------------------- */
@@ -98,9 +110,12 @@ public:
void add(Item *item);
/**
- * @brief remove an item from the inventory and delete it
+ * @brief erase an item from the inventory
+ * This will call the Item's destructor
*/
- void remove(Item *item);
+ void erase(Item *item);
+
+ void erase(const unsigned int id);
/**
* @brief removes all items from the inventory and delete them
@@ -135,8 +150,10 @@ private:
// items in the inventory
Items inventory_items;
- // timestamp when inventory was last updated
+ // timestamp, last time the inventory was updated
unsigned long inventory_timestamp;
+ // timestamp, last time there was an item deleted from the inventory
+ unsigned long inventory_timestamp_erase;
// maximum inventory capacity, in cubic meters
float inventory_capacity;