From 6c758fe1739fe10a1409f959b459ea556ae8164b Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Wed, 13 Jul 2011 17:35:56 +0000 Subject: Forcefully removed docked ships from the bullet simulation. --- src/game/base/ship.cc | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'src/game/base') diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc index 51d111b..d148f19 100644 --- a/src/game/base/ship.cc +++ b/src/game/base/ship.cc @@ -115,6 +115,8 @@ void Ship::reset() current_target_afterburner = 0.0f; EntityControlable::reset(); + + body()->setDamping(ship_shipmodel->linear_damping(), ship_shipmodel->angular_damping()); } void Ship::func_impulse() { @@ -296,8 +298,48 @@ void Ship::set_state(int state) { EntityControlable::set_state(state); - if (state != core::Entity::Docked) + 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 + + if (entity_motionstate) { + delete entity_motionstate; + entity_motionstate = 0; + } + + if (zone() && zone()->physics()) { + if (entity_actioninterface) { + entity_zone->physics()->removeAction(entity_actioninterface); + delete entity_actioninterface; + entity_actioninterface = 0; + } + entity_zone->physics()->removeRigidBody(body()); + } + + if (entity_collision_shape) { + delete entity_collision_shape; + entity_collision_shape = 0; + } + + for (CollisionShapes::iterator sit = entity_collision_child_shapes.begin(); sit != entity_collision_child_shapes.end(); sit++) { + delete (*sit); + (*sit) = 0; + } + entity_collision_child_shapes.clear(); + + if (entity_body) { + delete entity_body; + entity_body = 0; + } + + if (entity_body_info) { + delete entity_body_info; + entity_body_info = 0; + } + } } void Ship::set_dock(core::Entity *dock) -- cgit v1.2.3