Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/base')
-rw-r--r--src/game/base/cargopod.cc7
-rw-r--r--src/game/base/cargopod.h2
-rw-r--r--src/game/base/game.cc12
-rw-r--r--src/game/base/game.h10
-rw-r--r--src/game/base/station.cc24
-rw-r--r--src/game/base/station.h2
6 files changed, 45 insertions, 12 deletions
diff --git a/src/game/base/cargopod.cc b/src/game/base/cargopod.cc
index 5ea4105..7406d3a 100644
--- a/src/game/base/cargopod.cc
+++ b/src/game/base/cargopod.cc
@@ -17,7 +17,6 @@ CargoPod::CargoPod() : EntityDynamic()
set_label("cargopod");
set_flag(core::Entity::KeepAlive);
- set_keepalive_timeout(Game::g_keepalive ? Game::g_keepalive->value() : 0);
if (Default::podmodel)
set_modelname(Default::podmodel->name());
@@ -35,5 +34,11 @@ CargoPod::~CargoPod()
}
+void CargoPod::upkeep(const unsigned long timestamp)
+{
+ // cargo pods dissapear on upkeep
+ die();
+}
+
} // namespace game
diff --git a/src/game/base/cargopod.h b/src/game/base/cargopod.h
index daeb9bc..7bce9a4 100644
--- a/src/game/base/cargopod.h
+++ b/src/game/base/cargopod.h
@@ -17,6 +17,8 @@ class CargoPod : public core::EntityDynamic
public:
CargoPod();
virtual ~CargoPod();
+
+ virtual void upkeep(const unsigned long timestamp);
};
} // namespace game
diff --git a/src/game/base/game.cc b/src/game/base/game.cc
index 7aa1081..40c7c28 100644
--- a/src/game/base/game.cc
+++ b/src/game/base/game.cc
@@ -54,7 +54,7 @@ core::Cvar *Game::g_impulsespeed = 0;
core::Cvar *Game::g_jumppointrange = 0;
core::Cvar *Game::g_devel = 0;
core::Cvar *Game::g_damping = 0;
-core::Cvar *Game::g_keepalive;
+core::Cvar *Game::g_deplete = 0;
core::Module *factory()
{
@@ -905,8 +905,8 @@ Game::Game() : core::Module("Project::OSiRiON", true)
g_damping = core::Cvar::get("g_damping", "0.1", core::Cvar::Archive);
g_damping->set_info("[float] physics damping factor (0-1)");
- g_keepalive = core::Cvar::get("g_keepalive", "300", core::Cvar::Archive);
- g_keepalive->set_info("[float] amount of time dynamic objects are kept alive, in seconds");
+ g_deplete = core::Cvar::get("g_deplete", "60", core::Cvar::Archive);
+ g_deplete->set_info("[int] number of seconds to deplete 1 unit of cargo from inventories");
}
Game::~Game()
@@ -915,7 +915,6 @@ Game::~Game()
g_jumppointrange = 0;
g_devel = 0;
g_damping = 0;
- g_keepalive = 0;
// game functions are automaticly removed
// FIXME move cleanup sequence to core::
@@ -1025,7 +1024,7 @@ bool Game::load_zone(core::Zone *zone)
bool b;
long l;
-
+
std::string strval;
while (zoneini.getline()) {
@@ -1307,7 +1306,7 @@ bool Game::validate_zone(core::Zone *zone)
JumpGate *jumpgate = static_cast<JumpGate *>(entity);
jumpgate->validate();
} else {
- if ((entity->flags() & core::Entity::Dockable) == core::Entity::Dockable) {
+ if (entity->flag_is_set(core::Entity::Dockable)) {
generate_entity_menus(entity);
}
}
@@ -1351,6 +1350,7 @@ bool Game::generate_entity_menus(core::Entity *entity)
// add trade menus
if (entity->inventory()) {
+ entity->set_flag(core::Entity::KeepAlive);
size_t nbcargo = 0;
size_t nbships = 0;
diff --git a/src/game/base/game.h b/src/game/base/game.h
index d879a30..dd47cef 100644
--- a/src/game/base/game.h
+++ b/src/game/base/game.h
@@ -36,7 +36,7 @@ const unsigned int station_enttype = 262;
const unsigned int cargopod_enttype = 263;
// planet docking distance
-const float planet_safe_distance = 150.0f;
+const float planet_safe_distance = 50.0f;
const float jump_timer_delay = 5.0f;
const float impulse_timer_delay = 3.0f;
@@ -85,12 +85,12 @@ public:
/// game variable: enable or disable development mode (cheat mode)
static core::Cvar *g_devel;
+ /// game variable: number of seconds it takes for 1 unit of cargo to deplete from station inventories
+ static core::Cvar *g_deplete;
+
/// physics variable: default damping factor of space
- static core::Cvar *g_damping;
+ static core::Cvar *g_damping;
- /// game variable: amount of time dynamic objects are kept alive when there are no players
- static core::Cvar *g_keepalive;
-
private:
bool load_world();
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();
+ }
+ }
}
}
diff --git a/src/game/base/station.h b/src/game/base/station.h
index 2aa8a95..5f833c4 100644
--- a/src/game/base/station.h
+++ b/src/game/base/station.h
@@ -15,6 +15,8 @@ class Station : public core::Entity
public:
Station();
virtual ~Station();
+
+ virtual void upkeep(const unsigned long timestamp);
};
}