From 1c8d9ef13215a2f6f41be25adbe5df260d2eebd8 Mon Sep 17 00:00:00 2001 From: James Turner Date: Thu, 13 Dec 2012 09:10:39 +0000 Subject: [PATCH] Search the current aircraft-dir implicitly. If a file is specified without an 'Aircraft/subdir' prefix, check for it relative to the the current aircraft dir. --- src/Main/globals.cxx | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Main/globals.cxx b/src/Main/globals.cxx index 683339dcf..ca9f4fba7 100644 --- a/src/Main/globals.cxx +++ b/src/Main/globals.cxx @@ -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); -- 2.39.5