1
0
Fork 0

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.
This commit is contained in:
James Turner 2012-12-13 09:10:39 +00:00
parent 18506d3e65
commit 1c8d9ef132

View 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);