eng.set_IAS( V_calibrated_kts );
eng.set_Throttle_Lever_Pos( controls.get_throttle( 0 ) * 100.0 );
eng.set_Propeller_Lever_Pos( 100 );
- if ( controls.get_mixture( 0 ) > 0.51 ) {
+ if ( controls.get_mixture( 0 ) > 0.60 ) {
eng.set_Mixture_Lever_Pos( controls.get_mixture( 0 ) * 100.0 );
} else {
- eng.set_Mixture_Lever_Pos( 51.0 );
+ eng.set_Mixture_Lever_Pos( 60.0 );
}
// update engine model
e->set_EGT( eng.get_EGT() );
e->set_prop_thrust( eng.get_prop_thrust_SI() );
-#if 0
cout << "Throttle = " << controls.get_throttle( 0 ) * 100.0;
- cout << " Mixture = " << 80;
+ cout << " Mixture = " << controls.get_mixture( 0 ) * 100.0;
cout << " RPM = " << eng.get_RPM();
cout << " MP = " << eng.get_Manifold_Pressure();
cout << " HP = " << ( eng.get_MaxHP() * eng.get_Percentage_Power()
cout << " EGT = " << eng.get_EGT();
cout << " Thrust (N) " << eng.get_prop_thrust_SI(); // Thrust in Newtons
cout << '\n';
-#endif // 0
F_X_engine = eng.get_prop_thrust_SI() * 0.07;
#endif // USE_NEW_ENGINE_CODE
extern const char *default_root;
+// Read in configuration (file and command line) and just set fg_root
+bool fgInitFGRoot ( int argc, char **argv ) {
+ // Attempt to locate and parse a config file
+ // First check fg_root
+ FGPath config( current_options.get_fg_root() );
+ config.append( "system.fgfsrc" );
+ current_options.scan_config_file_for_root( config.str() );
+
+ // Next check home directory
+ char* envp = ::getenv( "HOME" );
+ if ( envp != NULL ) {
+ config.set( envp );
+ config.append( ".fgfsrc" );
+ current_options.scan_config_file_for_root( config.str() );
+ }
+
+ // Parse remaining command line options
+ // These will override anything specified in a config file
+ current_options.scan_command_line_for_root(argc, argv);
+
+ return true;
+}
+
+
// Read in configuration (file and command line)
bool fgInitConfig ( int argc, char **argv ) {
// Attempt to locate and parse a config file
return false;
}
- return true;
+ return true;
}
#endif
+// Read in configuration (file and command line) and just set fg_root
+bool fgInitFGRoot ( int argc, char **argv );
+
+
// Read in configuration (file and command line)
bool fgInitConfig ( int argc, char **argv );
// seed the random number generater
fg_srandom();
- // Read global preferences from $FG_ROOT/preferences.xml
- // FIXME: this will *not* work with an --fg_root option because
- // we have not read the command-line yet. Suggestions?
+ // Scan the config file(s) and command line options to see if
+ // fg_root was specified (ignore all other options for now)
+ fgInitFGRoot(argc, argv);
+ // Read global preferences from $FG_ROOT/preferences.xml
FGPath props_path(current_options.get_fg_root());
props_path.append("preferences.xml");
FG_LOG(FG_INPUT, FG_INFO, "Reading global preferences");
}
+// Scan the command line options for an fg_root definition and set
+// just that.
+int fgOPTIONS::scan_command_line_for_root( int argc, char **argv ) {
+ int i = 1;
+ int result;
+
+ FG_LOG(FG_GENERAL, FG_INFO, "Processing command line arguments");
+
+ while ( i < argc ) {
+ FG_LOG( FG_GENERAL, FG_DEBUG, "argv[" << i << "] = " << argv[i] );
+
+ string arg = argv[i];
+ if ( arg.find( "--fg-root=" ) != string::npos ) {
+ fg_root = arg.substr( 10 );
+ }
+
+ i++;
+ }
+
+ return FG_OPTIONS_OK;
+}
+
+
+// Scan the config file for an fg_root definition and set just that.
+int fgOPTIONS::scan_config_file_for_root( const string& path ) {
+ fg_gzifstream in( path );
+ if ( !in.is_open() )
+ return(FG_OPTIONS_ERROR);
+
+ FG_LOG( FG_GENERAL, FG_INFO, "Processing config file: " << path );
+
+ in >> skipcomment;
+#ifndef __MWERKS__
+ while ( ! in.eof() ) {
+#else
+ char c = '\0';
+ while ( in.get(c) && c != '\0' ) {
+ in.putback(c);
+#endif
+ string line;
+
+#ifdef GETLINE_NEEDS_TERMINATOR
+ getline( in, line, '\n' );
+#elif defined( macintosh )
+ getline( in, line, '\r' );
+#else
+ getline( in, line );
+#endif
+
+ if ( line.find( "--fg-root=" ) != string::npos ) {
+ fg_root = line.substr( 10 );
+ }
+
+ in >> skipcomment;
+ }
+
+ return FG_OPTIONS_OK;
+}
+
+
// Parse the command line options
int fgOPTIONS::parse_command_line( int argc, char **argv ) {
int i = 1;
i++;
}
- return(FG_OPTIONS_OK);
+ return FG_OPTIONS_OK;
}
// Parse a single option
int parse_option( const string& arg );
+ // Scan the command line options for an fg_root definition and set
+ // just that.
+ int scan_command_line_for_root( int argc, char **argv );
+
+ // Scan the config file for an fg_root definition and set just
+ // that.
+ int scan_config_file_for_root( const string& path );
+
// Parse the command line options
int parse_command_line( int argc, char **argv );