Keep the same aircraft on sim reset
When user has installed more aircrafts with the same short ID, preserve the selected dir, so we use the exact same aircraft.
This commit is contained in:
parent
857b163ee7
commit
2f0705bd49
2 changed files with 20 additions and 1 deletions
|
@ -796,6 +796,13 @@ int fgInitAircraft(bool reinit, bool didUseLauncher)
|
|||
|
||||
SGSharedPtr<Root> pkgRoot(globals->packageRoot());
|
||||
SGPropertyNode* aircraftProp = fgGetNode("/sim/aircraft", true);
|
||||
SGPropertyNode* aircraftDirProp = fgGetNode("/sim/aircraft-dir", true);
|
||||
|
||||
// ensure aircraft-dir survives reset, so we find the same aircraft
|
||||
// after a reset as we did prior to it. Without this, aircraft
|
||||
// can unintentionally change on a reset
|
||||
aircraftDirProp->setAttribute(SGPropertyNode::PRESERVE, true);
|
||||
|
||||
const string fullyQualifiedAircraftId = fgGetString("/sim/aircraft-id");
|
||||
string aircraftId = fullyQualifiedAircraftId.empty() ? aircraftProp->getStringValue() : fullyQualifiedAircraftId;
|
||||
|
||||
|
@ -1404,7 +1411,6 @@ void fgStartNewReset()
|
|||
"Some errors restoring preserved state (read-only props?)" );
|
||||
}
|
||||
|
||||
fgGetNode("/sim")->removeChild("aircraft-dir");
|
||||
fgInitAircraftPaths(true);
|
||||
fgInitAircraft(true, false /* not from launcher */);
|
||||
|
||||
|
|
|
@ -101,6 +101,19 @@ static bool
|
|||
do_switch_aircraft (const SGPropertyNode * arg, SGPropertyNode * root)
|
||||
{
|
||||
fgSetString("/sim/aircraft", arg->getStringValue("aircraft"));
|
||||
|
||||
// we could validate the new aircraft is find-able, and if not, bail out
|
||||
// of the command at this point? Might give a better user experience?
|
||||
// would need something like bool fgIsValidAircraft(name, dir);
|
||||
// which could be cooked up by modifying FindAndCacheAircraft
|
||||
|
||||
// We assume that we are changing the aircraft, so we remove the aircraft path.
|
||||
// this forces aircraft-dir to be recomputed by a full search as the user hopefully
|
||||
// expects.
|
||||
// We could allow pasing the dir as an optional argument to this command, if that
|
||||
// is ever needed in the future.
|
||||
fgGetNode("/sim")->removeChild("aircraft-dir");
|
||||
|
||||
// start a reset
|
||||
fgResetIdleState();
|
||||
return true;
|
||||
|
|
Loading…
Add table
Reference in a new issue