]> git.mxchange.org Git - flightgear.git/blobdiff - src/Airports/xmlloader.cxx
Alexis Bory:
[flightgear.git] / src / Airports / xmlloader.cxx
index 3d65f7756611241764dab8025d71da53682c44d1..8b35cabd5b03bab346f5df79fd9f2ec9f8a83219 100644 (file)
 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //
 
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
 #include <simgear/misc/sg_path.hxx>
 #include <simgear/xml/easyxml.hxx>
 #include <simgear/misc/strutils.hxx>
@@ -25,6 +29,7 @@
 #include "runwayprefloader.hxx"
 
 #include "dynamics.hxx"
+#include "simple.hxx"
 #include "runwayprefs.hxx"
 
 using std::string;
@@ -32,53 +37,17 @@ using std::string;
 XMLLoader::XMLLoader() {}
 XMLLoader::~XMLLoader() {}
 
-void XMLLoader::load(FGAirportDynamics* d) {
+void XMLLoader::load(FGAirportDynamics* d)
+{
   FGAirportDynamicsXMLLoader visitor(d);
-  if (fgGetBool("/sim/paths/use-custom-scenery-data") == false) {
-   SGPath parkpath( globals->get_fg_root() );
-   parkpath.append( "/AI/Airports/" );
-   parkpath.append( d->getId() );
-   parkpath.append( "parking.xml" );
-   SG_LOG(SG_GENERAL, SG_DEBUG, "running old loader:" << parkpath.c_str());
-   if (parkpath.exists()) {
-       try {
-           readXML(parkpath.str(), visitor);
-           d->init();
-       } 
-       catch (const sg_exception &) {
-       }
-   }
-  } else {
-    if(loadAirportXMLDataIntoVisitor(d->getId(), "groundnet", visitor)) {
-        d->init();
-    }
+  if(loadAirportXMLDataIntoVisitor(d->parent()->ident(), "groundnet", visitor)) {
+    d->init();
   }
 }
 
 void XMLLoader::load(FGRunwayPreference* p) {
   FGRunwayPreferenceXMLLoader visitor(p);
-  if (fgGetBool("/sim/paths/use-custom-scenery-data") == false) {
-    SGPath rwyPrefPath( globals->get_fg_root() );
-    rwyPrefPath.append( "AI/Airports/" );
-    rwyPrefPath.append( p->getId() );
-    rwyPrefPath.append( "rwyuse.xml" );
-    if (rwyPrefPath.exists()) {
-        try {
-            readXML(rwyPrefPath.str(), visitor);
-        } 
-        catch (const sg_exception &) {
-        }
-     }
-  } else {
-    loadAirportXMLDataIntoVisitor(p->getId(), "rwyuse", visitor);
-  }
-}
-
-void XMLLoader::load(FGSidStar* p) {
-  SGPath path;
-  if (findAirportData(p->getId(), "SID", path)) {
-    p->load(path);
-  }
+  loadAirportXMLDataIntoVisitor(p->getId(), "rwyuse", visitor);
 }
 
 bool XMLLoader::findAirportData(const std::string& aICAO, 
@@ -96,13 +65,16 @@ bool XMLLoader::findAirportData(const std::string& aICAO,
     aICAO.c_str(), fileName.c_str());
 
   for (string_list_iterator it = sc.begin(); it != sc.end(); ++it) {
-    SGPath path(*it);
-    path.append("Airports");
-    path.append(string(buffer));
-    if (path.exists()) {
-      aPath = path;
-      return true;
-    } // of path exists
+    // fg_senery contains empty strings as "markers" (see FGGlobals::set_fg_scenery)
+    if (!it->empty()) {
+        SGPath path(*it);
+        path.append("Airports");
+        path.append(string(buffer));
+        if (path.exists()) {
+          aPath = path;
+          return true;
+        } // of path exists
+    }
   } // of scenery path iteration
   return false;
 }