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>2010-09-19 19:44:13 +0000
committerStijn Buys <ingar@osirion.org>2010-09-19 19:44:13 +0000
commitcc18095cded14f5e7e3f049e47fca2224134b647 (patch)
tree2a057f4836925083a19988d571dc0664925c9e48 /src/core/inventory.cc
parentbadfb31888a6bd62e0a019b3f3dec517df4121ec (diff)
text rendering cleanups, inventory capacity & cargo volume
Diffstat (limited to 'src/core/inventory.cc')
-rw-r--r--src/core/inventory.cc22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/core/inventory.cc b/src/core/inventory.cc
index c659178..8f8c41a 100644
--- a/src/core/inventory.cc
+++ b/src/core/inventory.cc
@@ -13,15 +13,24 @@ namespace core
/* ---- class Inventory -------------------------------------------- */
-Inventory::Inventory()
+Inventory::Inventory(const float capacity)
{
inventory_timestamp = 0;
+ inventory_capacity = capacity;
+ inventory_capacity_used = 0;
}
Inventory::~Inventory()
{
clear();
inventory_timestamp = 0;
+ inventory_capacity = 0;
+ inventory_capacity_used = 0;
+}
+
+void Inventory::set_capacity(const float capacity)
+{
+ inventory_capacity = capacity;
}
void Inventory::set_timestamp(const unsigned long timestamp)
@@ -31,6 +40,7 @@ void Inventory::set_timestamp(const unsigned long timestamp)
void Inventory::set_dirty()
{
+ recalculate();
inventory_timestamp = core::game()->timestamp();
}
@@ -75,6 +85,16 @@ void Inventory::clear()
delete item;
}
inventory_items.clear();
+ inventory_capacity_used = 0;
+}
+
+void Inventory::recalculate()
+{
+ inventory_capacity_used = 0;
+ for (Items::const_iterator it = inventory_items.begin(); it != inventory_items.end(); it++) {
+ const Item *item = (*it);
+ inventory_capacity_used += item->amount() * item->info()->volume();
+ }
}
} // namespace core