]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/positioninit.cxx
Remove confusing reference to SDL/GLUT
[flightgear.git] / src / Main / positioninit.cxx
index c7c63b5336f586c7079d4448672a076ff7f12675..816e997831fcaee8cf0fa37668f94c77a36450c2 100644 (file)
 
 #include <Navaids/navlist.hxx>
 #include <Airports/runways.hxx>
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 #include <Airports/dynamics.hxx>
 #include <AIModel/AIManager.hxx>
 
 using std::endl;
+using std::string;
 
 namespace flightgear
 {
@@ -151,11 +152,23 @@ static bool setPosFromAirportIDandHdg( const string& id, double tgt_hdg ) {
   
   const FGAirport* apt = fgFindAirportID(id);
   if (!apt) return false;
-  FGRunway* r = apt->findBestRunwayForHeading(tgt_hdg);
-  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(), tgt_hdg);
+  SGGeod startPos;
+  double heading = tgt_hdg;
+  if (apt->type() == FGPositioned::HELIPORT) {
+    if (apt->numHelipads() > 0) {
+      startPos = apt->getHelipadByIndex(0)->geod();
+    } else {
+      startPos = apt->geod();
+    }
+  } else {
+    FGRunway* r = apt->findBestRunwayForHeading(tgt_hdg);
+    fgSetString("/sim/atc/runway", r->ident().c_str());
+    startPos = r->pointOnCenterline(fgGetDouble("/sim/airport/runways/start-offset-m", 5.0));
+    heading = r->headingDeg();
+  }
+
+  fgApplyStartOffset(startPos, heading, tgt_hdg);
   return true;
 }
 
@@ -316,7 +329,7 @@ static bool fgSetPosFromNAV( const string& id, const double& freq, FGPositioned:
   FGNavList::TypeFilter filter(type);
   const nav_list_type navlist = FGNavList::findByIdentAndFreq( id.c_str(), freq, &filter );
   
-  if (navlist.size() == 0 ) {
+  if (navlist.empty()) {
     SG_LOG( SG_GENERAL, SG_ALERT, "Failed to locate NAV = "
            << id << ":" << freq );
     return false;
@@ -560,8 +573,8 @@ bool initPosition()
 bool finalizeMetar()
 {
   double hdg = fgGetDouble( "/environment/metar/base-wind-dir-deg", 9999.0 );
-  string apt = fgGetString( "/sim/startup/options/airport" );
-  string rwy = fgGetString( "/sim/startup/options/runway" );
+  string apt = fgGetString("/sim/presets/airport-id");
+  string rwy = fgGetString("/sim/presets/runway");
   double strthdg = fgGetDouble( "/sim/startup/options/heading-deg", 9999.0 );
   string parkpos = fgGetString( "/sim/presets/parkpos" );
   bool onground = fgGetBool( "/sim/presets/onground", false );
@@ -577,11 +590,6 @@ bool finalizeMetar()
     }
     
     if (!fgGetBool( "/environment/metar/valid" )) {
-      // bit hacky - run these two subsystems. We can't run the whole
-      // lot since some view things aren't initialised and hence FGLight
-      // crashes.
-      globals->get_subsystem("http")->update(0.0);
-      globals->get_subsystem("environment")->update(0.0);
       return false;
     }