diff options
author | Stijn Buys <ingar@osirion.org> | 2010-10-26 21:08:12 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2010-10-26 21:08:12 +0000 |
commit | 75c6db097b990e58b4b2585580a89561c838d923 (patch) | |
tree | 8c913bdc531ea9a76dcaa9e10a65763f95fa55e4 /src/game/base/station.cc | |
parent | 23c7d2c11170ee8736673e82a88e87a3d2e538f7 (diff) |
updated network protocol version to 20, implemented invemtory depletion, unified depletion with keepalive
Diffstat (limited to 'src/game/base/station.cc')
-rw-r--r-- | src/game/base/station.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/game/base/station.cc b/src/game/base/station.cc index 0d992bd..6493348 100644 --- a/src/game/base/station.cc +++ b/src/game/base/station.cc @@ -20,6 +20,30 @@ Station::Station() : Entity() Station::~Station() { + +} + +void Station::upkeep(const unsigned long timestamp) +{ + if (!inventory()) + return; + + const unsigned long deplete = (Game::g_deplete ? 1000 * (unsigned long) Game::g_deplete->value() : 0); + + if (deplete > 0) { + bool dirty = false; + for (core::Inventory::Items::iterator it = inventory()->items().begin(); it != inventory()->items().end(); it++) { + core::Item *item = (*it); + if ((item->amount() > 0) && (item->timestamp() + deplete < timestamp)) { + item->dec_amount(1); + dirty = true; + } + } + + if (dirty) { + inventory()->set_dirty(); + } + } } } |