From e8f7c4a06fce9e41fb23ffc42a566501a78210cb Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 19 Sep 2010 22:49:55 +0000 Subject: player can only sell cargo on bases that allow it, trademenu layout updates --- src/core/inventory.cc | 4 ++-- src/core/inventory.h | 12 ++++++------ src/core/item.cc | 6 +++--- src/core/item.h | 10 +++++----- 4 files changed, 16 insertions(+), 16 deletions(-) (limited to 'src/core') diff --git a/src/core/inventory.cc b/src/core/inventory.cc index 8f8c41a..03cd21e 100644 --- a/src/core/inventory.cc +++ b/src/core/inventory.cc @@ -65,10 +65,10 @@ void Inventory::remove(Item *item) } } -Item *Inventory::find(const Info *info) +Item *Inventory::find(const Info *info) const { // sarch the inventory for a specified item type - for (Items::iterator it = inventory_items.begin(); it != inventory_items.end(); it++) { + for (Items::const_iterator it = inventory_items.begin(); it != inventory_items.end(); it++) { Item *item = (*it); if (item->info() == info) { return item; diff --git a/src/core/inventory.h b/src/core/inventory.h index aff9790..805d943 100644 --- a/src/core/inventory.h +++ b/src/core/inventory.h @@ -72,6 +72,11 @@ public: return inventory_capacity - inventory_capacity_used; } + /** + * @brief search the inventory for a specific item type + */ + Item *find(const Info *info) const; + /* ---- mutators --------------------------------------------------- */ /** @@ -88,12 +93,7 @@ public: * @brief removes all items from the inventory and delete them */ void clear(); - - /** - * @brief search the inventory for a specific item type - */ - Item *find(const Info *info); - + /** * @brief set the timestamp */ diff --git a/src/core/item.cc b/src/core/item.cc index ca51775..77b0f9c 100644 --- a/src/core/item.cc +++ b/src/core/item.cc @@ -25,17 +25,17 @@ Item::~Item() item_amount = 0; } -void Item::set_amount(const int amount) +void Item::set_amount(const long amount) { item_amount = amount; } -void Item::inc_amount(const int amount) +void Item::inc_amount(const long amount) { item_amount += amount; } -void Item::dec_amount(const int amount) +void Item::dec_amount(const long amount) { item_amount -= amount; } diff --git a/src/core/item.h b/src/core/item.h index cc81249..9c17dc9 100644 --- a/src/core/item.h +++ b/src/core/item.h @@ -28,7 +28,7 @@ public: /** * @brief associated amount */ - inline int amount() const { return item_amount; } + inline long amount() const { return item_amount; } /** * @brief information card @@ -45,18 +45,18 @@ public: /** * @brief set associated amount */ - void set_amount(const int amount); + void set_amount(const long amount); - void inc_amount(const int amount); + void inc_amount(const long amount); - void dec_amount(const int amount); + void dec_amount(const long amount); void set_price(const long price); private: const Info *item_info; long item_price; - int item_amount; + long item_amount; }; } // namespace core -- cgit v1.2.3