Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2011-03-08 18:36:46 +0000
committerStijn Buys <ingar@osirion.org>2011-03-08 18:36:46 +0000
commitff60e4463365d274aad2c5cf8ae23a6a665b4fcd (patch)
tree265cff9d308a8d94112eff0fb3ea3c2e134ae7d7 /src
parentdf77c743df304c644bebc321fc173125528a8d67 (diff)
Replaced the func_impulse if-soup with a nice switch() block.
Diffstat (limited to 'src')
-rw-r--r--src/game/base/ship.cc58
1 files changed, 31 insertions, 27 deletions
diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc
index 84b4e0a..1298d05 100644
--- a/src/game/base/ship.cc
+++ b/src/game/base/ship.cc
@@ -1,3 +1,4 @@
+
/*
base/ship.cc
This file is part of the Osirion project and is distributed under
@@ -113,35 +114,37 @@ void Ship::reset()
EntityControlable::reset();
}
-void Ship::func_impulse()
-{
- if (entity_state == core::Entity::Impulse) {
- entity_state = core::Entity::Normal;
- target_thrust = 1.0f;
- entity_thrust = 0.0f;
- set_dirty();
- return;
- }
-
- if (entity_state == core::Entity::ImpulseInitiate) {
- entity_state = core::Entity::Normal;
- set_dirty();
- return;
- }
+void Ship::func_impulse() {
- if (entity_state == core::Entity::JumpInitiate) {
- entity_state = core::Entity::Normal;
- ship_jumpdrive_timer = 0;
- entity_timer = 0;
- set_dirty();
+ switch (entity_state) {
+ case core::Entity::Impulse:
+ entity_state = core::Entity::Normal;
+ target_thrust = 1.0f;
+ entity_thrust = 0.0f;
+ set_dirty();
+ break;
+
+ case core::Entity::ImpulseInitiate:
+ entity_state = core::Entity::Normal;
+ set_dirty();
+ break;
+
+ case core::Entity::JumpInitiate:
+ entity_state = core::Entity::Normal;
+ ship_jumpdrive_timer = 0;
+ entity_timer = 0;
+ set_dirty();
+ break;
+
+ case core::Entity::Normal:
+ entity_state = core::Entity::ImpulseInitiate;
+ entity_timer = impulse_timer_delay;
+ ship_impulsedrive_timer = core::server()->time();
+ break;
+
+ default:
+ break;
}
-
- if (entity_state != core::Entity::Normal)
- return;
-
- entity_state = core::Entity::ImpulseInitiate;
- entity_timer = impulse_timer_delay;
- ship_impulsedrive_timer = core::server()->time();
}
@@ -309,6 +312,7 @@ void Ship::action (btScalar seconds)
maxspeed = 0.0f;
engine_force = 0.0f;
break;
+
case core::Entity::Docked:
maxspeed = 0.0f;
engine_force = 0.0f;