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/ship.cc')
-rw-r--r--src/game/base/ship.cc74
1 files changed, 14 insertions, 60 deletions
diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc
index ba30d67..4efba27 100644
--- a/src/game/base/ship.cc
+++ b/src/game/base/ship.cc
@@ -101,9 +101,9 @@ Ship::Ship(core::Player *owner, const ShipModel *shipmodel) : core::EntityContro
}
// initialize physics
- reset();
-
- body()->setDamping(ship_shipmodel->linear_damping(), ship_shipmodel->angular_damping());
+ // FIXME probably should not be called here
+ //reset();
+ //body()->setDamping(ship_shipmodel->linear_damping(), ship_shipmodel->angular_damping());
}
Ship::~Ship()
@@ -287,8 +287,9 @@ void Ship::reset()
current_target_vstrafe = 0.0f;
current_target_afterburner = 0.0f;
- if (state() != core::Entity::Docked) {
- EntityControlable::reset();
+ EntityControlable::reset();
+
+ if (body()) {
body()->setDamping(ship_shipmodel->linear_damping(), ship_shipmodel->angular_damping());
}
}
@@ -301,67 +302,21 @@ void Ship::set_zone(core::Zone *zone)
owner()->set_zone(zone);
}
-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;
- 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)
{
- if (!dock)
+ if (!dock) {
+ ship_dock = 0;
return;
+ }
get_location().assign(dock->location());
get_axis().assign(dock->axis());
ship_dock = dock;
-
- // if the dock is not owned by a player. set it as spawn
+
set_state(core::Entity::Docked);
+ reset();
+
+ // 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);
@@ -380,10 +335,9 @@ void Ship::launch()
else
get_location().assign(ship_dock->location() + (ship_dock->axis().forward() * (this->radius() + ship_dock->radius())));
- set_state(core::Entity::Normal);
-
ship_dock = 0;
+ set_state(core::Entity::Normal);
reset();
}