]> git.mxchange.org Git - flightgear.git/commitdiff
Don't expect an 'Aircraft' sub-directory within each aircraft-dir.
authorJames Turner <zakalawe@mac.com>
Wed, 8 Sep 2010 10:01:26 +0000 (11:01 +0100)
committerJames Turner <zakalawe@mac.com>
Wed, 8 Sep 2010 10:01:26 +0000 (11:01 +0100)
src/Main/globals.cxx

index c84870dde06fa6de97c18fbde13334cb2e5f8540..0bd14a3bc56f6f722fce888c31adafaae4e237f2 100644 (file)
@@ -72,6 +72,7 @@ public:
       return SGPath(); // not an Aircraft path
     }
     
+  // test against the aircraft-dir property
     const char* aircraftDir = fgGetString("/sim/aircraft-dir");
     string_list aircraftDirPieces(sgPathBranchSplit(aircraftDir));
     if (aircraftDirPieces.empty() || (aircraftDirPieces.back() != pieces[1])) {
@@ -83,7 +84,24 @@ public:
       r.append(pieces[i]);
     }
     
-    return r.exists() ? r : SGPath();
+    if (r.exists()) {
+      SG_LOG(SG_IO, SG_INFO, "found path:" << aResource << " via /sim/aircraft-dir: " << r.str());
+      return r;
+    }
+  
+  // try each aircaft dir in turn
+    std::string res(aResource, 9); // resource path with 'Aircraft/' removed
+    const string_list& dirs(globals->get_aircraft_paths());
+    string_list::const_iterator it = dirs.begin();
+    for (; it != dirs.end(); ++it) {
+      SGPath p(*it, res);
+      if (p.exists()) {
+        SG_LOG(SG_IO, SG_INFO, "found path:" << aResource << " in aircraft dir: " << r.str());
+        return p;
+      }
+    } // of aircraft path iteration
+    
+    return SGPath(); // not found
   }
 };
 
@@ -276,9 +294,6 @@ void FGGlobals::append_aircraft_path(const std::string& path)
   unsigned int index = fg_aircraft_dirs.size();  
   fg_aircraft_dirs.push_back(path);
   
-  simgear::ResourceManager::instance()->addBasePath(path, 
-    simgear::ResourceManager::PRIORITY_NORMAL);
-  
 // make aircraft dirs available to Nasal
   SGPropertyNode* sim = fgGetNode("/sim", true);
   sim->removeChild("fg-aircraft", index, false);