Prefetch a previously saved aircraft settings configuration file to retrieve aircraft usage and livery information. Fallback to default settings in aircraft-set.xml file if not found.
This commit is contained in:
parent
fcf0371777
commit
5ae207c2fc
1 changed files with 33 additions and 6 deletions
|
@ -907,15 +907,42 @@ static bool fgSetPosFromAirportIDandParkpos( const string& id, const string& par
|
|||
|
||||
int park_index = dcs->getNrOfParkings() - 1;
|
||||
bool succes;
|
||||
double radius = fgGetDouble("/sim/atc/acradius");
|
||||
//cerr << "Using radius " << radius << endl;
|
||||
//cerr << "Checking parkpos comparison " << (bool) (parkpos == string("AVAILABLE")) << endl;
|
||||
double radius = fgGetDouble("/sim/dimensions/radius-m");
|
||||
if ((parkpos == string("AVAILABLE")) && (radius > 0)) {
|
||||
double lat, lon, heading;
|
||||
string fltType = fgGetString("/sim/atc/flight-type");
|
||||
string airline = fgGetString("/sim/atc/airline" );
|
||||
string fltType;
|
||||
string acOperator;
|
||||
SGPath acData;
|
||||
try {
|
||||
acData = fgGetString("/sim/fg-home");
|
||||
acData.append("aircraft-data");
|
||||
string acfile = fgGetString("/sim/aircraft") + string(".xml");
|
||||
acData.append(acfile);
|
||||
SGPropertyNode root;
|
||||
readProperties(acData.str(), &root);
|
||||
SGPropertyNode * node = root.getNode("sim");
|
||||
fltType = node->getStringValue("aircraft-class", "NONE" );
|
||||
acOperator = node->getStringValue("aircraft-operator", "NONE" );
|
||||
} catch (const sg_exception &) {
|
||||
SG_LOG(SG_GENERAL, SG_INFO,
|
||||
"Could not load aircraft aircrat type and operator information from: " << acData.str() << ". Using defaults");
|
||||
|
||||
// cout << path.str() << endl;
|
||||
}
|
||||
if (fltType.empty() || fltType == "NONE") {
|
||||
SG_LOG(SG_GENERAL, SG_INFO,
|
||||
"Aircraft type information not found in: " << acData.str() << ". Using default value");
|
||||
fltType = fgGetString("/sim/aircraft-class" );
|
||||
}
|
||||
if (acOperator.empty() || fltType == "NONE") {
|
||||
SG_LOG(SG_GENERAL, SG_INFO,
|
||||
"Aircraft type information not found in: " << acData.str() << ". Using default value");
|
||||
acOperator = fgGetString("/sim/aircraft-class" );
|
||||
}
|
||||
|
||||
cerr << "Running aircraft " << fltType << " of livery " << acOperator << endl;
|
||||
string acType; // Currently not used by findAvailable parking, so safe to leave empty.
|
||||
succes = dcs->getAvailableParking(&lat, &lon, &heading, &park_index, radius, fltType, acType, airline);
|
||||
succes = dcs->getAvailableParking(&lat, &lon, &heading, &park_index, radius, fltType, acType, acOperator);
|
||||
if (succes) {
|
||||
fgGetString("/sim/presets/parkpos");
|
||||
fgSetString("/sim/presets/parkpos", dcs->getParking(park_index)->getName());
|
||||
|
|
Loading…
Reference in a new issue