diff options
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/base/game.cc | 8 | ||||
-rw-r--r-- | src/game/base/ship.cc | 74 | ||||
-rw-r--r-- | src/game/base/ship.h | 3 | ||||
-rw-r--r-- | src/game/base/shipmodel.cc | 2 |
4 files changed, 22 insertions, 65 deletions
diff --git a/src/game/base/game.cc b/src/game/base/game.cc index f542676..8c82968 100644 --- a/src/game/base/game.cc +++ b/src/game/base/game.cc @@ -90,7 +90,9 @@ void Game::func_join(core::Player *player, std::string const &args) ship->set_dock(dock); player->set_view(dock); } - + + ship->reset(); + player->send("^BYou received " + aux::article(Default::shipmodel->name())); player->sound("game/buy-ship"); } @@ -344,10 +346,12 @@ void Game::func_give(core::Player *player, const std::string &args) // FIME move this into a method in the Ship class ship->set_zone(player->control()->zone()); ship->get_location().assign(player->control()->location()); - ship->set_state(player->control()->state()); + ship->set_dock(oldship->dock()); ship->get_axis().assign(player->control()->axis()); ship->set_thrust(player->control()->thrust()); + + ship->set_state(player->control()->state()); ship->reset(); //target_thrust is protected //ship->target_thrust = player->control()->target_thrust()); 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(); } diff --git a/src/game/base/ship.h b/src/game/base/ship.h index f705231..230d406 100644 --- a/src/game/base/ship.h +++ b/src/game/base/ship.h @@ -115,7 +115,7 @@ public: /// Initiate jump, departing from a jump point void initiate_jump(JumpPoint *depart); - /// void reset drive controls + /// reset physics state and ship controls virtual void reset(); /// explode the ship @@ -127,7 +127,6 @@ public: /// toggle jump drive activation void func_jump(std::string const & args); - virtual void set_state(int state); /** * @brief dock the ship at a station, planet or another player's ship_dock * This will set the ship's state to Entity::Docked and reset spawn if required diff --git a/src/game/base/shipmodel.cc b/src/game/base/shipmodel.cc index b7fa7b0..6e21d91 100644 --- a/src/game/base/shipmodel.cc +++ b/src/game/base/shipmodel.cc @@ -330,7 +330,7 @@ void ShipModel::buy(core::EntityControlable *buyer, core::Entity *seller) ship->get_axis().assign(seller->axis()); ship->get_axis().change_direction(180.0f); ship->set_dock(seller); - ship->reset(); + //ship->reset(); // reset() is done by set_dock() // transfer inventory for (core::Inventory::Items::iterator it = player->control()->inventory()->items().begin(); |