From 75274ebd6ba90784f5aa837b7e5ea97fc6bfb720 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 20 Oct 2012 16:35:26 +0000 Subject: Item id based inventory, support for weapon dealers. --- src/core/inventory.h | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'src/core/inventory.h') 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 Items; + typedef std::list Items; /** * @brief default constructor @@ -45,13 +45,20 @@ 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 */ @@ -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; -- cgit v1.2.3