From 1883c2ea6cb3dd4ba5f26af31a0ad481d524dfef Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 13 Oct 2012 15:39:23 +0000 Subject: Corrected bugs in the respawn command, detect ship collisions with planets and stars. --- src/game/base/game.cc | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'src/game/base/game.cc') diff --git a/src/game/base/game.cc b/src/game/base/game.cc index a79f5cc..b19ec52 100644 --- a/src/game/base/game.cc +++ b/src/game/base/game.cc @@ -835,30 +835,30 @@ void Game::func_launch(core::Player *player, std::string const &args) // respawn void Game::func_respawn(core::Player *player, std::string const &args) { - if (!player->control()) { + Ship *ship = static_cast(player->control()); + + if (!ship) { func_join(player, args); return; } - if (!(player->view() == player->control())) - return; - - if (player->control()->state() != core::Entity::Destroyed) + if (ship->state() != core::Entity::Destroyed) { return; + } - Ship *ship = static_cast(player->control()); - core::Entity *dock = player->control()->zone()->default_view(); + core::Entity *spawn = ship->spawn(); + if (!spawn) { + spawn = player->control()->zone()->default_view(); + } - if (dock) { - ship->get_location().assign(dock->location()); - ship->get_axis().assign(dock->axis()); - ship->set_state(core::Entity::Docked); - player->set_view(dock); - player->send("^BRespawning at " + dock->name()); + if (spawn && spawn->has_flag(core::Entity::Dockable)) { + ship->set_dock(spawn); + player->set_view(spawn); + player->send("^BRespawning at " + spawn->name()); } else { ship->get_location().clear(); ship->get_axis().clear(); - ship->set_state(core::Entity::Jump); + ship->set_state(core::Entity::Normal); player->set_view(0); player->send("^BRespawning"); } @@ -1588,7 +1588,7 @@ bool Game::validate_zone(core::Zone *zone) } // initialize physics on planets and entities with a model - if ((entity->entity_moduletypeid == planet_enttype) || (entity->model())) { + if ((entity->entity_moduletypeid == star_enttype) ||(entity->entity_moduletypeid == planet_enttype) || (entity->model())) { entity->reset(); } -- cgit v1.2.3