]> git.mxchange.org Git - flightgear.git/blobdiff - src/Airports/runwayprefs.cxx
Merge branch 'next' of gitorious.org:fg/flightgear into next
[flightgear.git] / src / Airports / runwayprefs.cxx
index ae204474e46dc2a68b5cfce948006da5c51e4445..8337d31f9fad3e60c7c8ea5430536fa4fe8bed47 100644 (file)
 #endif
 
 #include <math.h>
-//#include <algorithm>
 
 #include <simgear/compiler.h>
 
-//#include <plib/sg.h>
-//#include <plib/ul.h>
-
-//#include <Environment/environment_mgr.hxx>
-//#include <Environment/environment.hxx>
-//#include <simgear/misc/sg_path.hxx>
-//#include <simgear/props/props.hxx>
-//#include <simgear/structure/subsystem_mgr.hxx>
 #include <simgear/debug/logstream.hxx>
 #include <Main/globals.hxx>
-//#include <Main/fg_props.hxx>
 #include <Airports/runways.hxx>
 
 #include "runwayprefs.hxx"
@@ -202,7 +192,7 @@ void RunwayGroup::setActive(const FGAirport* airport,
                            stringVec *currentlyActive)
 {
 
-  FGRunway rwy;
+  FGRunway* rwy;
   int activeRwys = rwyList.size(); // get the number of runways active
   int nrOfPreferences;
   // bool found = true;
@@ -235,10 +225,16 @@ void RunwayGroup::setActive(const FGAirport* airport,
          validSelection = true;
          for (int j = 0; j < activeRwys; j++)
     {
-            rwy = airport->getRunwayByIdent(rwyList[j].getRwyList(i));
+      string ident(rwyList[j].getRwyList(i));
+      if (!airport->hasRunwayWithIdent(ident)) {
+        SG_LOG(SG_GENERAL, SG_WARN, "no such runway:" << ident << " at " << airport->ident());
+        continue;
+      }
+      
+            rwy = airport->getRunwayByIdent(ident);
        
                          //cerr << "Succes" << endl;
-                 hdgDiff = fabs(windHeading - rwy._heading);
+                 hdgDiff = fabs(windHeading - rwy->headingDeg());
                  //cerr << "Wind Heading: " << windHeading << "Runway Heading: " <<rwy._heading << endl;
                  //cerr << "Wind Speed  : " << windSpeed << endl;
                  if (hdgDiff > 180)
@@ -307,7 +303,7 @@ void RunwayGroup::setActive(const FGAirport* airport,
         rwy = airport->getRunwayByIdent(name);
         
                  //cerr << "Succes" << endl;
-                 hdgDiff = fabs(windHeading - rwy._heading);
+                 hdgDiff = fabs(windHeading - rwy->headingDeg());
                  if (hdgDiff > 180)
                    hdgDiff = 360 - hdgDiff;
                  hdgDiff *= ((2*M_PI)/360.0); // convert to radians