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 ) {
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());
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;
}
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;