Ensure /sim/aircraft is only the leaf ID
Keep the (possibly) fully-qualified ID in /sim/aircraft-id property This should fix aircraft which rely on /sim/aircraft to be the variant name. Ticket-Id: https://sourceforge.net/p/flightgear/codetickets/2502/
This commit is contained in:
parent
c031abe8d2
commit
d10d9dfadd
2 changed files with 19 additions and 2 deletions
src/Main
|
@ -745,7 +745,8 @@ int fgInitAircraft(bool reinit)
|
|||
|
||||
SGSharedPtr<Root> pkgRoot(globals->packageRoot());
|
||||
SGPropertyNode* aircraftProp = fgGetNode("/sim/aircraft", true);
|
||||
string aircraftId(aircraftProp->getStringValue());
|
||||
const string fullyQualifiedAircraftId = fgGetString("/sim/aircraft-id");
|
||||
string aircraftId = fullyQualifiedAircraftId.empty() ? aircraftProp->getStringValue() : fullyQualifiedAircraftId;
|
||||
|
||||
flightgear::addSentryTag("aircraft", aircraftId);
|
||||
|
||||
|
@ -757,6 +758,11 @@ int fgInitAircraft(bool reinit)
|
|||
if (acftPackage) {
|
||||
if (acftPackage->isInstalled()) {
|
||||
SG_LOG(SG_GENERAL, SG_INFO, "Loading aircraft from package:" << acftPackage->qualifiedId());
|
||||
// if we resolved a non-qualified ID, set the full one back to /sim/aircraft-id
|
||||
fgSetString("/sim/aircraft-id", acftPackage->qualifiedId());
|
||||
|
||||
// replace this tag, so we know which hangar is in use
|
||||
flightgear::addSentryTag("aircraft", acftPackage->qualifiedId());
|
||||
|
||||
// set catalog path so intra-package dependencies within the catalog
|
||||
// are resolved correctly.
|
||||
|
|
|
@ -2245,10 +2245,21 @@ OptionResult Options::initAircraft()
|
|||
}
|
||||
|
||||
if (!aircraft.empty()) {
|
||||
fgSetString("/sim/aircraft-id", aircraft);
|
||||
const auto lastDotPos = aircraft.rfind('.');
|
||||
if (lastDotPos != string::npos) {
|
||||
// ensure /sim/aircraft is only the local ID, not the fully-qualified ID
|
||||
// otherwise some existing logic gets confused.
|
||||
fgSetString("/sim/aircraft", aircraft.substr(lastDotPos + 1));
|
||||
} else {
|
||||
fgSetString("/sim/aircraft", aircraft);
|
||||
}
|
||||
|
||||
SG_LOG(SG_INPUT, SG_INFO, "aircraft = " << aircraft );
|
||||
fgSetString("/sim/aircraft", aircraft.c_str() );
|
||||
} else {
|
||||
SG_LOG(SG_INPUT, SG_INFO, "No user specified aircraft, using default" );
|
||||
// ensure aircraft-id is valid
|
||||
fgSetString("/sim/aircraft-id", fgGetString("/sim/aircraft"));
|
||||
}
|
||||
|
||||
if (p->showAircraft) {
|
||||
|
|
Loading…
Add table
Reference in a new issue