From f874c178d9d7744c553ce83a9fde7ab80d110e80 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Tue, 12 Nov 2013 19:03:31 +0000 Subject: Prevent the 'goto' command from segfaulting on an unknown entity. --- src/game/base/game.cc | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/game/base/game.cc b/src/game/base/game.cc index f41b9b2..4a4441d 100644 --- a/src/game/base/game.cc +++ b/src/game/base/game.cc @@ -1564,16 +1564,17 @@ void Game::func_goto(core::Player *player, const std::string &args) core::Entity *dock = player->control()->zone()->search_entity(args); - // if target is docked,goto the dock instead - if (dock->moduletype() == ship_enttype) { - Ship *ship = static_cast(dock); - - if ((ship->state() == core::Entity::Docked) && (ship->dock())) { - player->send(ship->name() + " docked at " + ship->dock()->name()); - dock = ship->dock(); + if (dock) { + // if target is docked,goto the dock instead + if (dock->moduletype() == ship_enttype) { + Ship *othership = static_cast(dock); + + if ((othership->state() == core::Entity::Docked) && (othership->dock())) { + player->send(othership->name() + " docked at " + othership->dock()->name()); + dock = othership->dock(); + } } - } - if (dock) { + Ship *ship = static_cast(player->control()); if (dock->type() == core::Entity::Globe) { -- cgit v1.2.3