]> git.mxchange.org Git - flightgear.git/commitdiff
Support helipad names in the --runway startup option
authorChristian Schmitt <chris@ilovelinux.de>
Fri, 14 Feb 2014 18:25:37 +0000 (19:25 +0100)
committerChristian Schmitt <chris@ilovelinux.de>
Fri, 14 Feb 2014 19:05:11 +0000 (20:05 +0100)
also give better user feedback if runway/helipad ID is unknown

src/Main/positioninit.cxx

index cd5130db6abbd10f10c8d9a80275c13fa5dcb1b8..ed60183a12fca99deb8b79033870c99276647c1e 100644 (file)
@@ -35,6 +35,8 @@
 #include <Airports/airport.hxx>
 #include <Airports/dynamics.hxx>
 #include <AIModel/AIManager.hxx>
+#include <GUI/MessageBox.hxx>
+
 
 using std::endl;
 using std::string;
@@ -269,19 +271,29 @@ static bool fgSetPosFromAirportIDandRwy( const string& id, const string& rwy, bo
     SG_LOG( SG_GENERAL, SG_ALERT, "Failed to find airport:" << id);
     return false;
   }
-  
-  if (!apt->hasRunwayWithIdent(rwy)) {
-    SG_LOG( SG_GENERAL, rwy_req ? SG_ALERT : SG_INFO,
-           "Failed to find runway " << rwy <<
+
+  if (apt->hasRunwayWithIdent(rwy)) {
+      FGRunway* r(apt->getRunwayByIdent(rwy));
+      fgSetString("/sim/atc/runway", r->ident().c_str());
+      SGGeod startPos = r->pointOnCenterline( fgGetDouble("/sim/airport/runways/start-offset-m", 5.0));
+      fgApplyStartOffset(startPos, r->headingDeg());
+      return true;
+  } else if (apt->hasHelipadWithIdent(rwy)) {
+      FGHelipad* h(apt->getHelipadByIdent(rwy));
+      fgApplyStartOffset(h->geod(), h->headingDeg());
+      return true;
+  }
+
+  if (rwy_req) {
+      flightgear::modalMessageBox("Runway not available", "Runway/helipad "
+                                   + rwy + " not found at airport " + apt->getId()
+                                   + " - " + apt->getName() );
+  } else {
+    SG_LOG( SG_GENERAL, SG_INFO,
+           "Failed to find runway/helipad " << rwy <<
            " at airport " << id << ". Using default runway." );
-    return false;
   }
-  
-  FGRunway* r(apt->getRunwayByIdent(rwy));
-  fgSetString("/sim/atc/runway", r->ident().c_str());
-  SGGeod startPos = r->pointOnCenterline( fgGetDouble("/sim/airport/runways/start-offset-m", 5.0));
-  fgApplyStartOffset(startPos, r->headingDeg());
-  return true;
+  return false;
 }