]> git.mxchange.org Git - flightgear.git/commitdiff
Fixed init-order bug that caused c172-set.xml defaults always to be
authordavid <david>
Thu, 10 Oct 2002 18:39:52 +0000 (18:39 +0000)
committerdavid <david>
Thu, 10 Oct 2002 18:39:52 +0000 (18:39 +0000)
used unless explicitly overwritten.  Now, the options are parsed
twice, and only the *-set.xml file for the *last* aircraft specified
is loaded.

src/Main/fg_init.cxx
src/Main/options.cxx

index 8314d7bbdce987ac655ecc3383e3be92c32954c7..65c52b1e356f41a887ede947cb63ab025b6b578c 100644 (file)
@@ -341,6 +341,46 @@ bool fgDetectLanguage() {
     return true;
 }
 
+// Attempt to locate and parse the various non-XML config files in order
+// from least precidence to greatest precidence
+static void
+do_options (int argc, char ** argv)
+{
+    // Check for $fg_root/system.fgfsrc
+    SGPath config( globals->get_fg_root() );
+    config.append( "system.fgfsrc" );
+    fgParseOptions(config.str());
+
+#if defined( unix ) || defined( __CYGWIN__ )
+    char name[256];
+    // Check for $fg_root/system.fgfsrc.hostname
+    gethostname( name, 256 );
+    config.concat( "." );
+    config.concat( name );
+    fgParseOptions(config.str());
+#endif
+
+    // Check for ~/.fgfsrc
+    char* envp = ::getenv( "HOME" );
+    if ( envp != NULL ) {
+        config.set( envp );
+        config.append( ".fgfsrc" );
+        fgParseOptions(config.str());
+    }
+
+#if defined( unix ) || defined( __CYGWIN__ )
+    // Check for ~/.fgfsrc.hostname
+    gethostname( name, 256 );
+    config.concat( "." );
+    config.concat( name );
+    fgParseOptions(config.str());
+#endif
+
+    // Parse remaining command line options
+    // These will override anything specified in a config file
+    fgParseArgs(argc, argv);
+}
+
 
 // Read in configuration (file and command line)
 bool fgInitConfig ( int argc, char **argv ) {
@@ -360,6 +400,7 @@ bool fgInitConfig ( int argc, char **argv ) {
        return false;
 
     // Read the default aircraft config file.
+    do_options(argc, argv);     // preparse options for default aircraft
     string aircraft = fgGetString("/sim/aircraft", "");
     if (aircraft.size() > 0) {
       SGPath aircraft_path(globals->get_fg_root());
@@ -380,42 +421,7 @@ bool fgInitConfig ( int argc, char **argv ) {
       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
-
-    // Check for $fg_root/system.fgfsrc
-    SGPath config( globals->get_fg_root() );
-    config.append( "system.fgfsrc" );
-    fgParseOptions(config.str());
-
-#if defined( unix ) || defined( __CYGWIN__ )
-    char name[256];
-    // Check for $fg_root/system.fgfsrc.hostname
-    gethostname( name, 256 );
-    config.concat( "." );
-    config.concat( name );
-    fgParseOptions(config.str());
-#endif
-
-    // Check for ~/.fgfsrc
-    char* envp = ::getenv( "HOME" );
-    if ( envp != NULL ) {
-        config.set( envp );
-        config.append( ".fgfsrc" );
-        fgParseOptions(config.str());
-    }
-
-#if defined( unix ) || defined( __CYGWIN__ )
-    // Check for ~/.fgfsrc.hostname
-    gethostname( name, 256 );
-    config.concat( "." );
-    config.concat( name );
-    fgParseOptions(config.str());
-#endif
-
-    // Parse remaining command line options
-    // These will override anything specified in a config file
-    fgParseArgs(argc, argv);
+    do_options(argc, argv);
 
     return true;
 }
index 9dd26a91213a33a80b80a2514970d68b54cdee61..abbbcd1d491005b87ebd26c2f5508154ced17a4b 100644 (file)
@@ -989,14 +989,7 @@ parse_option (const string& arg)
          exit(2);
        }
     } else if ( arg.find( "--aircraft=" ) == 0 ) {
-        // read in the top level aircraft definition file
-        SGPath apath( globals->get_fg_root() );
-        apath.append( "Aircraft" );
-        apath.append( arg.substr(11) );
-        apath.concat( "-set.xml" );
-       SG_LOG(SG_INPUT, SG_INFO, "Reading aircraft: " << arg.substr(11)
-           << " from " << apath.str());
-       readProperties( apath.str(), globals->get_props() );
+        fgSetString("/sim/aircraft", arg.substr(11).c_str());
     } else {
        SG_LOG( SG_GENERAL, SG_ALERT, "Unknown option '" << arg << "'" );
        return FG_OPTIONS_ERROR;