From: James Turner Date: Wed, 19 Jan 2011 23:58:00 +0000 (+0000) Subject: Fix bug 259 - don't override existing airport/runway in initPos X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=54ef43878f50eb99d3773ceef099383886d95bf1;p=flightgear.git Fix bug 259 - don't override existing airport/runway in initPos --- diff --git a/src/Autopilot/route_mgr.cxx b/src/Autopilot/route_mgr.cxx index 127e2c397..bcb5895ac 100644 --- a/src/Autopilot/route_mgr.cxx +++ b/src/Autopilot/route_mgr.cxx @@ -924,11 +924,20 @@ void FGRouteMgr::initAtPosition() } // on the ground - SGGeod pos = SGGeod::fromDegFt(lon->getDoubleValue(), lat->getDoubleValue(), alt->getDoubleValue()); - _departure = FGAirport::findClosest(pos, 20.0); + SGGeod pos = SGGeod::fromDegFt(lon->getDoubleValue(), + lat->getDoubleValue(), alt->getDoubleValue()); if (!_departure) { - SG_LOG(SG_AUTOPILOT, SG_INFO, "initAtPosition: couldn't find an airport within 20nm"); - departure->setStringValue("runway", ""); + _departure = FGAirport::findClosest(pos, 20.0); + if (!_departure) { + SG_LOG(SG_AUTOPILOT, SG_INFO, "initAtPosition: couldn't find an airport within 20nm"); + departure->setStringValue("runway", ""); + return; + } + } + + std::string rwy = departure->getStringValue("runway"); + if (!rwy.empty()) { + // runway already set, fine return; }