]> git.mxchange.org Git - flightgear.git/blobdiff - src/Airports/xmlloader.cxx
Fix file access mode for newnavradio.[ch]xx
[flightgear.git] / src / Airports / xmlloader.cxx
index 58539a1f2ccac87f4f759b1207ed05cc1395b68b..b2ce07ed4b3fdbb28975f48a48685f4db96b6994 100644 (file)
 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //
 
-#include <simgear/misc/sg_path.hxx>
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
 
+#include <simgear/misc/sg_path.hxx>
 #include <simgear/xml/easyxml.hxx>
+#include <simgear/misc/strutils.hxx>
 
 #include <Main/globals.hxx>
 #include <Main/fg_props.hxx>
@@ -34,7 +38,7 @@ XMLLoader::~XMLLoader() {}
 
 void XMLLoader::load(FGAirportDynamics* d) {
   FGAirportDynamicsXMLLoader visitor(d);
-  if (fgGetBool("/sim/traffic-manager/use-custom-scenery-data") == false) {
+  if (fgGetBool("/sim/paths/use-custom-scenery-data") == false) {
    SGPath parkpath( globals->get_fg_root() );
    parkpath.append( "/AI/Airports/" );
    parkpath.append( d->getId() );
@@ -49,13 +53,15 @@ void XMLLoader::load(FGAirportDynamics* d) {
        }
    }
   } else {
-    loadAirportXMLDataIntoVisitor(d->getId(), "groundnet", visitor);
+    if(loadAirportXMLDataIntoVisitor(d->getId(), "groundnet", visitor)) {
+        d->init();
+    }
   }
 }
 
 void XMLLoader::load(FGRunwayPreference* p) {
   FGRunwayPreferenceXMLLoader visitor(p);
-  if (fgGetBool("/sim/traffic-manager/use-custom-scenery-data") == false) {
+  if (fgGetBool("/sim/paths/use-custom-scenery-data") == false) {
     SGPath rwyPrefPath( globals->get_fg_root() );
     rwyPrefPath.append( "AI/Airports/" );
     rwyPrefPath.append( p->getId() );
@@ -82,20 +88,28 @@ void XMLLoader::load(FGSidStar* p) {
 bool XMLLoader::findAirportData(const std::string& aICAO, 
     const std::string& aFileName, SGPath& aPath)
 {
+  string fileName(aFileName);
+  if (!simgear::strutils::ends_with(aFileName, ".xml")) {
+    fileName.append(".xml");
+  }
+  
   string_list sc = globals->get_fg_scenery();
   char buffer[128];
-  ::snprintf(buffer, 128, "%c/%c/%c/%s.%s.xml", 
+  ::snprintf(buffer, 128, "%c/%c/%c/%s.%s", 
     aICAO[0], aICAO[1], aICAO[2], 
-    aICAO.c_str(), aFileName.c_str());
+    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;
 }