Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2011-05-11 14:48:17 +0000
committerStijn Buys <ingar@osirion.org>2011-05-11 14:48:17 +0000
commit1c63cbf204b1d2c667ce9f821ccb197d0ffb0ac3 (patch)
treec2d0ff7cc4a8a264657abd0ac99017a5b664ecd2 /src/game
parentbb0f860989f84b901f80017ae0139a3fc0446dc1 (diff)
Review of the main loop timer, converted timers from float to unsigned long,
corrected a number of timing bugs, improved client framerate stability.
Diffstat (limited to 'src/game')
-rw-r--r--src/game/base/jumppoint.cc14
-rw-r--r--src/game/base/jumppoint.h4
-rw-r--r--src/game/base/ship.cc4
-rw-r--r--src/game/base/ship.h4
-rw-r--r--src/game/example/spectator.cc15
-rw-r--r--src/game/example/spectator.h2
-rw-r--r--src/game/intro/convoy.cc6
-rw-r--r--src/game/intro/convoy.h4
8 files changed, 28 insertions, 25 deletions
diff --git a/src/game/base/jumppoint.cc b/src/game/base/jumppoint.cc
index 80c99ef..3d9fd01 100644
--- a/src/game/base/jumppoint.cc
+++ b/src/game/base/jumppoint.cc
@@ -179,19 +179,17 @@ void JumpGate::func_dock(Ship *ship)
void JumpGate::activate()
{
- jumpgate_timer = jump_timer_delay;
+ jumpgate_timer = jump_timer_delay * 1000;
set_state(core::Entity::Normal);
}
-void JumpGate::frame(float elapsed)
+void JumpGate::frame(const unsigned long elapsed)
{
- if (jumpgate_timer > 0) {
+ if (jumpgate_timer > elapsed) {
jumpgate_timer -= elapsed;
-
- if (jumpgate_timer < 0) {
- set_state(core::Entity::NoPower);
- jumpgate_timer = 0;
- }
+ } else if (state() != core::Entity::NoPower) {
+ set_state(core::Entity::NoPower);
+ jumpgate_timer = 0;
}
}
diff --git a/src/game/base/jumppoint.h b/src/game/base/jumppoint.h
index 40f9e5d..33a9f9f 100644
--- a/src/game/base/jumppoint.h
+++ b/src/game/base/jumppoint.h
@@ -75,14 +75,14 @@ public:
void activate();
- virtual void frame(float elapsed);
+ virtual void frame(const unsigned long elapsed);
static inline void set_template (const Template *entitytemplate) {
jumpgate_template = entitytemplate;
}
private:
- float jumpgate_timer;
+ unsigned long jumpgate_timer;
static const Template *jumpgate_template;
};
diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc
index 0fa44fb..7a499c3 100644
--- a/src/game/base/ship.cc
+++ b/src/game/base/ship.cc
@@ -365,7 +365,7 @@ void Ship::action (btScalar seconds)
}
}
-void Ship::frame(float seconds)
+void Ship::frame(const unsigned long elapsed)
{
//const float direction_reaction = 2.0f; // directional control reaction time
//const float thrust_reaction = 0.5f; // thrust control reaction time
@@ -646,7 +646,7 @@ void Ship::frame(float seconds)
}
*/
- EntityControlable::frame(seconds);
+ EntityControlable::frame(elapsed);
}
diff --git a/src/game/base/ship.h b/src/game/base/ship.h
index b0256aa..37dae0d 100644
--- a/src/game/base/ship.h
+++ b/src/game/base/ship.h
@@ -53,11 +53,11 @@ public:
return ship_roll_force;
}
- /// physices frame
+ /// physics frame
virtual void action (btScalar seconds);
/// game frame
- virtual void frame(float seconds);
+ virtual void frame(const unsigned long elapsed);
/// move the ship to a different zone
virtual void set_zone(core::Zone *zone);
diff --git a/src/game/example/spectator.cc b/src/game/example/spectator.cc
index 5fc7fc6..9ca9497 100644
--- a/src/game/example/spectator.cc
+++ b/src/game/example/spectator.cc
@@ -33,7 +33,7 @@ Spectator::~Spectator()
{
}
-void Spectator::frame(float elapsed)
+void Spectator::frame(const unsigned long elapsed)
{
// only update if necessary
if (!entity_speed && ! target_thrust && !target_direction && !target_pitch && !target_roll && !target_strafe && !target_afterburner)
@@ -41,9 +41,11 @@ void Spectator::frame(float elapsed)
// assign thrust value from input
entity_thrust = target_thrust;
+
+ const float seconds = (float) elapsed / 1000.0f;
// rotate according to input
- float rotation = g_spectatorrotation->value() * elapsed;
+ float rotation = g_spectatorrotation->value() * seconds;
get_axis().change_direction(target_direction * rotation);
get_axis().change_pitch(target_pitch * rotation);
get_axis().change_roll(target_roll * rotation);
@@ -54,14 +56,17 @@ void Spectator::frame(float elapsed)
// assign new location
if (entity_speed)
- get_location() += axis().forward() * entity_speed * elapsed;
+ get_location() += axis().forward() * entity_speed * seconds;
if (target_afterburner)
- get_location() += axis().forward() * maxspeed * target_afterburner * elapsed;
+ get_location() += axis().forward() * maxspeed * target_afterburner * seconds;
if (target_strafe)
- get_location() += axis().left() * maxspeed * target_strafe * elapsed;
+ get_location() += axis().left() * maxspeed * target_strafe * seconds;
+ if (target_vstrafe)
+ get_location() += axis().up() * maxspeed * target_vstrafe * seconds;
+
// set dirty flag
set_dirty();
}
diff --git a/src/game/example/spectator.h b/src/game/example/spectator.h
index 57f223b..bd141b2 100644
--- a/src/game/example/spectator.h
+++ b/src/game/example/spectator.h
@@ -21,7 +21,7 @@ public:
~Spectator();
/// update the ship state
- virtual void frame(float elapsed);
+ virtual void frame(const unsigned long elapsed);
static core::Cvar *g_spectatorspeed;
static core::Cvar *g_spectatorrotation;
diff --git a/src/game/intro/convoy.cc b/src/game/intro/convoy.cc
index 118bdee..8a436bb 100644
--- a/src/game/intro/convoy.cc
+++ b/src/game/intro/convoy.cc
@@ -30,9 +30,9 @@ Member::~Member()
{
}
-void Member::frame(float seconds)
+void Member::frame(const unsigned long elapsed)
{
- get_location() += axis().forward() * speed() * thrust() * seconds;
+ get_location() += axis().forward() * speed() * thrust() * ((float) elapsed / 1000.0f);
}
/* ---- class Convoy ----------------------------------------------- */
@@ -82,7 +82,7 @@ void Convoy::add(const std::string &modelname)
member->get_axis().assign(axis());
}
-void Convoy::frame(float seconds)
+void Convoy::frame(const unsigned long elapsed)
{
for (Members::iterator it = convoy_members.begin(); it != convoy_members.end();) {
Member *member = (*it);
diff --git a/src/game/intro/convoy.h b/src/game/intro/convoy.h
index 22e3f7c..127db5e 100644
--- a/src/game/intro/convoy.h
+++ b/src/game/intro/convoy.h
@@ -23,7 +23,7 @@ public:
Member(std::string const &modelname);
~Member();
- void frame(float seconds);
+ void frame(const unsigned long elapsed);
};
/* ---- class Convoy ----------------------------------------------- */
@@ -37,7 +37,7 @@ public:
void add(const char *modelname);
void add(const std::string &modelname);
- virtual void frame(float seconds);
+ virtual void frame(const unsigned long elapsed);
private:
typedef std::list<Member *> Members;