From 519224d9fc97f1f8d88d8552fb4cb4bc5161a92c Mon Sep 17 00:00:00 2001 From: david Date: Tue, 11 Dec 2001 19:27:37 +0000 Subject: [PATCH] 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. --- src/Main/fg_init.cxx | 20 ++++++++++++++++++++ src/Main/options.cxx | 3 +-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 9917c989c..2f0aedac4 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -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 diff --git a/src/Main/options.cxx b/src/Main/options.cxx index d640ffe2e..44aae7246 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -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(); -- 2.39.5