]> git.mxchange.org Git - flightgear.git/commitdiff
Search the current aircraft-dir implicitly.
authorJames Turner <zakalawe@mac.com>
Thu, 13 Dec 2012 09:10:39 +0000 (09:10 +0000)
committerJames Turner <zakalawe@mac.com>
Thu, 13 Dec 2012 09:10:39 +0000 (09:10 +0000)
If a file is specified without an 'Aircraft/subdir' prefix, check for it relative to the the current aircraft dir.

src/Main/globals.cxx

index 683339dcf03d480056b1e0b46b0efda030247cf6..ca9f4fba7587e2465af9ae3c106d98155d234951 100644 (file)
@@ -106,6 +106,23 @@ public:
   }
 };
 
+class CurrentAircraftDirProvider : public simgear::ResourceProvider
+{
+public:
+  CurrentAircraftDirProvider() :
+    simgear::ResourceProvider(simgear::ResourceManager::PRIORITY_HIGH)
+  {
+  }
+  
+  virtual SGPath resolve(const std::string& aResource, SGPath&) const
+  {
+    const char* aircraftDir = fgGetString("/sim/aircraft-dir");
+    SGPath p(aircraftDir);
+    p.append(aResource);
+    return p.exists() ? p : SGPath();
+  }
+};
+
 ////////////////////////////////////////////////////////////////////////
 // Implementation of FGGlobals.
 ////////////////////////////////////////////////////////////////////////
@@ -141,7 +158,8 @@ FGGlobals::FGGlobals() :
     channellist( NULL ),
     haveUserSettings(false)
 {
-  simgear::ResourceManager::instance()->addProvider(new AircraftResourceProvider());
+  simgear::ResourceManager::instance()->addProvider(new AircraftResourceProvider);
+  simgear::ResourceManager::instance()->addProvider(new CurrentAircraftDirProvider);
   simgear::PropertyObjectBase::setDefaultRoot(props);
   
   positionLon = props->getNode("position/longitude-deg", true);