diff options
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/base/ship.cc | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc index d148f19..1aca505 100644 --- a/src/game/base/ship.cc +++ b/src/game/base/ship.cc @@ -105,20 +105,6 @@ Ship::~Ship() { } -void Ship::reset() -{ - current_target_direction = 0.0f; - current_target_pitch = 0.0f;; - current_target_roll = 0.0f; - current_target_strafe = 0.0f; - current_target_vstrafe = 0.0f; - current_target_afterburner = 0.0f; - - EntityControlable::reset(); - - body()->setDamping(ship_shipmodel->linear_damping(), ship_shipmodel->angular_damping()); -} - void Ship::func_impulse() { switch (entity_state) { @@ -286,6 +272,22 @@ void Ship::explode() } }; + +void Ship::reset() +{ + current_target_direction = 0.0f; + current_target_pitch = 0.0f;; + current_target_roll = 0.0f; + current_target_strafe = 0.0f; + current_target_vstrafe = 0.0f; + current_target_afterburner = 0.0f; + + if (state() != core::Entity::Docked) { + EntityControlable::reset(); + body()->setDamping(ship_shipmodel->linear_damping(), ship_shipmodel->angular_damping()); + } +} + void Ship::set_zone(core::Zone *zone) { core::EntityControlable::set_zone(zone); @@ -299,11 +301,13 @@ void Ship::set_state(int state) EntityControlable::set_state(state); if (state != core::Entity::Docked) { + ship_dock = 0; } else if (body()) { // FIXME this weird hack removes docked ships from the bullet simulation // this should be moved into core:: together with the set_state() / reset() cycle // The game module should not be bothered with this + // set_state() and reset() should be merged if (entity_motionstate) { delete entity_motionstate; @@ -338,7 +342,7 @@ void Ship::set_state(int state) if (entity_body_info) { delete entity_body_info; entity_body_info = 0; - } + } } } @@ -350,14 +354,14 @@ void Ship::set_dock(core::Entity *dock) get_location().assign(dock->location()); get_axis().assign(dock->axis()); ship_dock = dock; - set_state(core::Entity::Docked); + // if the dock is not owned by a player. set it as spawn const core::Player *owner = (dock->type() == core::Entity::Controlable ? static_cast<core::EntityControlable *>(dock)->owner() : 0 ); if (!owner) set_spawn(dock); - reset(); + set_state(core::Entity::Docked); } void Ship::launch() |