Modified initial property parsing order to be more intuitive. It now
works like this: 1. Parse preferences.xml, which will usually specify a default aircraft using the /sim/aircraft property. 2. If /sim/aircraft is specified and not empty, parse the properties in $FG_ROOT/Aircraft/{/sim/aircraft}-set.xml to set up a default aircraft. 3. During command-line parsing, whenever the --aircraft option appears set /sim/aircraft appropriately and parse the properties in $FG_ROOT/Aircraft/{/sim/aircraft}-set.xml. Any --config, --prop, or --aircraft options afterwards will take precedence.
This commit is contained in:
parent
c5d8a7a8ad
commit
519224d9fc
2 changed files with 21 additions and 2 deletions
|
@ -232,6 +232,26 @@ bool fgInitConfig ( int argc, char **argv ) {
|
|||
}
|
||||
SG_LOG(SG_INPUT, SG_INFO, "Finished Reading global preferences");
|
||||
|
||||
// Read the default aircraft config file.
|
||||
string aircraft = fgGetString("/sim/aircraft", "");
|
||||
if (aircraft.size() > 0) {
|
||||
SGPath aircraft_path(globals->get_fg_root());
|
||||
aircraft_path.append("Aircraft");
|
||||
aircraft_path.append(aircraft);
|
||||
aircraft_path.concat("-set.xml");
|
||||
SG_LOG(SG_INPUT, SG_INFO, "Reading default aircraft: " << aircraft);
|
||||
try {
|
||||
readProperties(props_path.str(), globals->get_props());
|
||||
} catch (const sg_exception &e) {
|
||||
string message = "Error reading default aircraft: ";
|
||||
message += e.getFormattedMessage();
|
||||
SG_LOG(SG_INPUT, SG_ALERT, message);
|
||||
exit(2);
|
||||
}
|
||||
} else {
|
||||
SG_LOG(SG_INPUT, SG_ALERT, "No default aircraft specified");
|
||||
}
|
||||
|
||||
// Attempt to locate and parse the various config files in order
|
||||
// from least precidence to greatest precidence
|
||||
|
||||
|
|
|
@ -909,8 +909,7 @@ parse_option (const string& arg)
|
|||
apath.append( arg.substr(11) );
|
||||
apath.concat( "-set.xml" );
|
||||
try {
|
||||
SGPropertyNode *sim = fgGetNode("/sim");
|
||||
readProperties( apath.str(), sim );
|
||||
readProperties( apath.str(), globals->get_props() );
|
||||
} catch (const sg_exception &e) {
|
||||
string message = "Error loading aircraft file: ";
|
||||
message += e.getFormattedMessage();
|
||||
|
|
Loading…
Add table
Reference in a new issue