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>2012-10-20 16:35:26 +0000
committerStijn Buys <ingar@osirion.org>2012-10-20 16:35:26 +0000
commit75274ebd6ba90784f5aa837b7e5ea97fc6bfb720 (patch)
treea5d51a87bf3f20833df18bc40a3254b946716afb /src/game/base/planet.cc
parentf01629dc14b1ee05b44d2e38b3dffbc1441fd85f (diff)
Item id based inventory, support for weapon dealers.
Diffstat (limited to 'src/game/base/planet.cc')
-rw-r--r--src/game/base/planet.cc34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/game/base/planet.cc b/src/game/base/planet.cc
index 2adb1fb..06a8219 100644
--- a/src/game/base/planet.cc
+++ b/src/game/base/planet.cc
@@ -6,7 +6,7 @@
#include "base/game.h"
#include "base/planet.h"
-
+#include "base/weapon.h"
namespace game
{
@@ -27,4 +27,36 @@ Planet::~Planet()
}
+void Planet::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(); ) {
+ core::Item *item = (*it);
+ if ((item->amount() > 0) && (item->timestamp() + deplete < timestamp)) {
+ item->dec_amount(1);
+ dirty = true;
+ }
+
+ if ((item->info()->type() == Weapon::infotype()) && (item->amount() == 0)) {
+ delete (item);
+ (*it) = 0;
+ inventory()->items().erase(it++);
+ dirty = true;
+ } else {
+ ++it;
+ }
+ }
+
+ if (dirty) {
+ inventory()->set_dirty();
+ }
+ }
+}
+
} // namespace game