]> git.mxchange.org Git - flightgear.git/blobdiff - src/Airports/xmlloader.cxx
Several Bugfixes:
[flightgear.git] / src / Airports / xmlloader.cxx
index b5bce6345883194ddcdf7fb69d3e73979661991a..273e2f67f6508c772760a825196f82f4773e3d01 100644 (file)
@@ -14,8 +14,8 @@
 //
 
 #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>
@@ -85,8 +85,7 @@ bool XMLLoader::findAirportData(const std::string& aICAO,
     const std::string& aFileName, SGPath& aPath)
 {
   string fileName(aFileName);
-  int extPos = fileName.size() - 4;
-  if ((int) fileName.rfind(".xml") != extPos) {
+  if (!simgear::strutils::ends_with(aFileName, ".xml")) {
     fileName.append(".xml");
   }
   
@@ -97,13 +96,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;
 }