From d34f7dc451b331e54d6bbea940516fed8e7b934c Mon Sep 17 00:00:00 2001 From: Julian Smith Date: Tue, 27 Oct 2020 22:34:15 +0000 Subject: [PATCH] src/Main/positioninit.cxx: open popup if we can't find taxiway to avoid starting on runway. --- src/Main/positioninit.cxx | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/Main/positioninit.cxx b/src/Main/positioninit.cxx index a07193e7c..acdad5d2d 100644 --- a/src/Main/positioninit.cxx +++ b/src/Main/positioninit.cxx @@ -191,18 +191,26 @@ std::tuple runwayStartPos(FGRunwayRef runway) runway->ident() << ", MP is enabled so computing hold short position to avoid runway incursion"); FGGroundNetwork* groundNet = runway->airport()->groundNetwork(); - // add a margin, try to keep the entire aeroplane comfortable off the - // runway. - double margin = startOffset + (runway->widthM() * 1.5); - FGTaxiNodeRef taxiNode = groundNet ? groundNet->findNearestNodeOffRunway(pos, runway, margin) : FGTaxiNodeRef{}; - if (taxiNode) { - // set this so multiplayer.nas can inform the user - fgSetBool("/sim/presets/avoided-mp-runway", true); - return std::make_tuple(taxiNode->geod(), SGGeodesy::courseDeg(taxiNode->geod(), pos)); + + if (groundNet) { + // add a margin, try to keep the entire aeroplane comfortable off the + // runway. + double margin = startOffset + (runway->widthM() * 1.5); + FGTaxiNodeRef taxiNode = groundNet->findNearestNodeOffRunway(pos, runway, margin); + if (taxiNode) { + // set this so multiplayer.nas can inform the user + fgSetBool("/sim/presets/avoided-mp-runway", true); + return std::make_tuple(taxiNode->geod(), SGGeodesy::courseDeg(taxiNode->geod(), pos)); + } + else { + // if we couldn't find a suitable taxi-node, give up. Guessing a position + // causes too much pain (starting in the water or similar bad things) + SG_LOG( SG_GENERAL, SG_POPUP, "Unable to position off runway because groundnet has no taxi node."); + } + } + else { + SG_LOG( SG_GENERAL, SG_POPUP, "Unable to position off runway because no groundnet."); } - - // if we couldn't find a suitable taxi-node, give up. Guessing a position - // causes too much pain (starting in the water or similar bad things) } return std::make_tuple(pos, runway->headingDeg());