1
0
Fork 0

Allow aircraft-dir option to override aircraft search logic completely.

This commit is contained in:
James Turner 2011-10-16 21:15:54 +01:00
parent ccb21d4c0c
commit 3d0254f6ec
2 changed files with 29 additions and 1 deletions

View file

@ -338,6 +338,29 @@ public:
}
_searchAircraft = aircraft + "-set.xml";
std::string aircraftDir = fgGetString("/sim/aircraft-dir", "");
if (!aircraftDir.empty()) {
// aircraft-dir was set, skip any searching at all, if it's valid
simgear::Dir acPath(aircraftDir);
SGPath setFile = acPath.file(_searchAircraft);
if (setFile.exists()) {
SG_LOG(SG_GENERAL, SG_INFO, "found aircraft in dir: " << aircraftDir );
try {
readProperties(setFile.str(), globals->get_props());
} catch ( const sg_exception &e ) {
SG_LOG(SG_INPUT, SG_ALERT, "Error reading aircraft: " << e.getFormattedMessage());
return false;
}
return true;
} else {
SG_LOG(SG_GENERAL, SG_ALERT, "aircraft '" << _searchAircraft <<
"' not found in specified dir:" << aircraftDir);
return false;
}
}
if (!checkCache()) {
// prepare cache for re-scan
SGPropertyNode *n = _cache->getNode("fg-root", true);

View file

@ -1395,7 +1395,7 @@ struct OptionDesc {
{"fg-aircraft", true, OPTION_IGNORE | OPTION_MULTI, "", false, "", 0 },
{"fdm", true, OPTION_STRING, "/sim/flight-model", false, "", 0 },
{"aero", true, OPTION_STRING, "/sim/aero", false, "", 0 },
{"aircraft-dir", true, OPTION_STRING, "/sim/aircraft-dir", false, "", 0 },
{"aircraft-dir", true, OPTION_IGNORE, "", false, "", 0 },
{"model-hz", true, OPTION_INT, "/sim/model-hz", false, "", 0 },
{"speed", true, OPTION_INT, "/sim/speed-up", false, "", 0 },
{"trim", false, OPTION_BOOL, "/sim/presets/trim", true, "", 0 },
@ -1764,6 +1764,11 @@ void Options::initAircraft()
fgShowAircraft(path);
exit(0);
}
if (isOptionSet("aircraft-dir")) {
// set this now, so it's available in FindAndCacheAircraft
fgSetString("/sim/aircraft-dir", valueForOption("aircraft-dir"));
}
}
void Options::processArgResult(int result)