Allow aircraft directory name validation.
Patch by Michael Danilov: allow an aircraft set XML to define the requied directory name, and if one is provided, validate the actual name against this. This catches common issues where a manually downloaded aircraft has the wrong name and some assets will therefore not load. SF-Ticket-ID: https://sourceforge.net/p/flightgear/codetickets/2647/
This commit is contained in:
parent
f00d843c8f
commit
07dfb6496c
1 changed files with 30 additions and 1 deletions
|
@ -255,6 +255,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
checkAircraftMinVersion();
|
checkAircraftMinVersion();
|
||||||
|
checkAircraftDirName();
|
||||||
|
|
||||||
// apply state after the -set.xml, but before any options are are set
|
// apply state after the -set.xml, but before any options are are set
|
||||||
flightgear::applyInitialState();
|
flightgear::applyInitialState();
|
||||||
|
@ -340,6 +341,7 @@ public:
|
||||||
flightgear::applyInitialState();
|
flightgear::applyInitialState();
|
||||||
|
|
||||||
checkAircraftMinVersion();
|
checkAircraftMinVersion();
|
||||||
|
checkAircraftDirName();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -451,6 +453,33 @@ private:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool checkAircraftDirName()
|
||||||
|
{
|
||||||
|
auto expectedDirNode = globals->get_props()->getNode("/sim/expected-aircraft-dir-name");
|
||||||
|
const string aircraftId = fgGetString("/sim/aircraft");
|
||||||
|
if (aircraftId != fgGetString("/sim/aircraft-id")){
|
||||||
|
// Skip the check for aircraft installed from catalog.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expectedDirNode) {
|
||||||
|
const string expectedDir = expectedDirNode->getStringValue();
|
||||||
|
const SGPath dir(fgGetString("/sim/aircraft-dir"));
|
||||||
|
if (dir.file() != expectedDirNode->getStringValue()) {
|
||||||
|
flightgear::fatalMessageBoxThenExit("Aircraft folder named incorrectly",
|
||||||
|
"The folder of the selected aircraft must be named '" + expectedDir +
|
||||||
|
"' (instead of '" + dir.file() + "') to work correctly. If you downloaded it yourself, " +
|
||||||
|
"please ensure the folder is called '" +
|
||||||
|
expectedDir + "' and re-name if necessary.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// TODO Uncomment for the next release.
|
||||||
|
//SG_LOG(SG_AIRCRAFT, SG_DEV_ALERT, "Aircraft does not specify the required aircraft directory name: please add one at /sim/expected-aircraft-dir-name");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
std::string _searchAircraft;
|
std::string _searchAircraft;
|
||||||
SGPath _foundPath;
|
SGPath _foundPath;
|
||||||
SGPropertyNode* _cache = nullptr;
|
SGPropertyNode* _cache = nullptr;
|
||||||
|
|
Loading…
Reference in a new issue