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-10-26 21:08:12 +0000
committerStijn Buys <ingar@osirion.org>2010-10-26 21:08:12 +0000
commit75c6db097b990e58b4b2585580a89561c838d923 (patch)
tree8c913bdc531ea9a76dcaa9e10a65763f95fa55e4 /src/game/base/station.cc
parent23c7d2c11170ee8736673e82a88e87a3d2e538f7 (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.cc24
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();
+ }
+ }
}
}