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/station.cc
parentf01629dc14b1ee05b44d2e38b3dffbc1441fd85f (diff)
Item id based inventory, support for weapon dealers.
Diffstat (limited to 'src/game/base/station.cc')
-rw-r--r--src/game/base/station.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/game/base/station.cc b/src/game/base/station.cc
index 6493348..31e6b3e 100644
--- a/src/game/base/station.cc
+++ b/src/game/base/station.cc
@@ -6,6 +6,7 @@
#include "base/game.h"
#include "base/station.h"
+#include "base/weapon.h"
#include "sys/sys.h"
namespace game
@@ -32,12 +33,21 @@ void Station::upkeep(const unsigned long timestamp)
if (deplete > 0) {
bool dirty = false;
- for (core::Inventory::Items::iterator it = inventory()->items().begin(); it != inventory()->items().end(); it++) {
+ 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) {