]> git.mxchange.org Git - flightgear.git/commitdiff
Fix bug 259 - don't override existing airport/runway in initPos
authorJames Turner <zakalawe@mac.com>
Wed, 19 Jan 2011 23:58:00 +0000 (23:58 +0000)
committerJames Turner <zakalawe@mac.com>
Wed, 19 Jan 2011 23:58:00 +0000 (23:58 +0000)
src/Autopilot/route_mgr.cxx

index 127e2c39792c7fbae347536850608eb8c3f9c7f7..bcb5895acc227b2e9f4bd1a8a3efd43ba34cad18 100644 (file)
@@ -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;
   }