diff options
Diffstat (limited to 'src/core/inventory.cc')
-rw-r--r-- | src/core/inventory.cc | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/core/inventory.cc b/src/core/inventory.cc index 4b9a2e5..7957294 100644 --- a/src/core/inventory.cc +++ b/src/core/inventory.cc @@ -18,6 +18,7 @@ Inventory::Inventory(const float capacity) inventory_timestamp = 0; inventory_capacity = capacity; inventory_capacity_used = 0; + inventory_dirty = false; } Inventory::~Inventory() @@ -38,10 +39,11 @@ void Inventory::set_timestamp(const unsigned long timestamp) inventory_timestamp = timestamp; } -void Inventory::set_dirty() +void Inventory::set_dirty(const bool dirty) { - recalculate(); - inventory_timestamp = core::game()->timestamp(); + inventory_dirty = dirty; + if (dirty) + recalculate(); } void Inventory::add(Item *item) @@ -52,6 +54,7 @@ void Inventory::add(Item *item) return; } inventory_items.push_back(item); + inventory_dirty = true; } void Inventory::remove(Item *item) @@ -63,6 +66,7 @@ void Inventory::remove(Item *item) return; } } + // FIXME remove doesn't work over network } Item *Inventory::find(const Info *info) const @@ -97,6 +101,16 @@ void Inventory::recalculate() } } +void Inventory::serialize_server_update(std::ostream & os) const +{ + os << capacity() << " "; +} + +void Inventory::receive_server_update(std::istream &is) +{ + is >> inventory_capacity; +} + const long Inventory::max_amount(const long credits, const long price, const float volume) const { if ((price * volume) == 0) { |