Allow aircraft-dir option to override aircraft search logic completely.
This commit is contained in:
parent
ccb21d4c0c
commit
3d0254f6ec
2 changed files with 29 additions and 1 deletions
|
@ -338,6 +338,29 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
_searchAircraft = aircraft + "-set.xml";
|
_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()) {
|
if (!checkCache()) {
|
||||||
// prepare cache for re-scan
|
// prepare cache for re-scan
|
||||||
SGPropertyNode *n = _cache->getNode("fg-root", true);
|
SGPropertyNode *n = _cache->getNode("fg-root", true);
|
||||||
|
|
|
@ -1395,7 +1395,7 @@ struct OptionDesc {
|
||||||
{"fg-aircraft", true, OPTION_IGNORE | OPTION_MULTI, "", false, "", 0 },
|
{"fg-aircraft", true, OPTION_IGNORE | OPTION_MULTI, "", false, "", 0 },
|
||||||
{"fdm", true, OPTION_STRING, "/sim/flight-model", false, "", 0 },
|
{"fdm", true, OPTION_STRING, "/sim/flight-model", false, "", 0 },
|
||||||
{"aero", true, OPTION_STRING, "/sim/aero", 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 },
|
{"model-hz", true, OPTION_INT, "/sim/model-hz", false, "", 0 },
|
||||||
{"speed", true, OPTION_INT, "/sim/speed-up", false, "", 0 },
|
{"speed", true, OPTION_INT, "/sim/speed-up", false, "", 0 },
|
||||||
{"trim", false, OPTION_BOOL, "/sim/presets/trim", true, "", 0 },
|
{"trim", false, OPTION_BOOL, "/sim/presets/trim", true, "", 0 },
|
||||||
|
@ -1764,6 +1764,11 @@ void Options::initAircraft()
|
||||||
fgShowAircraft(path);
|
fgShowAircraft(path);
|
||||||
exit(0);
|
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)
|
void Options::processArgResult(int result)
|
||||||
|
|
Loading…
Add table
Reference in a new issue