#include <Math/fg_geodesy.hxx>
#include <Math/point3d.hxx>
#include <Math/polar3d.hxx>
+#include <Misc/fgpath.hxx>
#include <Scenery/scenery.hxx>
#include <Scenery/tilemgr.hxx>
#include <Time/event.hxx>
#include <Time/light.hxx>
#include <Time/sunpos.hxx>
#include <Time/moonpos.hxx>
-#include <Weather/weather.hxx>
+// #include <Weather/weather.hxx>
+#include <WeatherCM/FGLocalWeatherDatabase.h>
#include "fg_init.hxx"
#include "options.hxx"
extern const char *default_root;
+// Read in configuration (file and command line)
+bool fgInitConfig ( 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.parse_config_file( config.str() );
+
+ // Next check home directory
+ char* envp = ::getenv( "HOME" );
+ if ( envp != NULL ) {
+ config.set( envp );
+ config.append( ".fgfsrc" );
+ current_options.parse_config_file( config.str() );
+ }
+
+ // Parse remaining command line options
+ // These will override anything specified in a config file
+ if ( current_options.parse_command_line(argc, argv) !=
+ fgOPTIONS::FG_OPTIONS_OK )
+ {
+ // Something must have gone horribly wrong with the command
+ // line parsing or maybe the user just requested help ... :-)
+ current_options.usage();
+ FG_LOG( FG_GENERAL, FG_ALERT, "\nExiting ...");
+ return false;
+ }
+
+ return true;
+}
+
+
// Set initial position and orientation
-int fgInitPosition( void ) {
+bool fgInitPosition( void ) {
string id;
FGInterface *f;
<< (f->get_Latitude() * RAD_TO_DEG) << ", "
<< (f->get_Altitude() * FEET_TO_METER) << ")" );
- return(1);
+ return true;
}
// General house keeping initializations
-int fgInitGeneral( void ) {
+bool fgInitGeneral( void ) {
string root;
char *mesa_win_state;
}
#endif
- return 1;
+ return true;
}
// initialization routines. If you are adding a subsystem to flight
// gear, its initialization call should located in this routine.
// Returns non-zero if a problem encountered.
-int fgInitSubsystems( void )
-{
+bool fgInitSubsystems( void ) {
FGTime::cur_time_params = new FGTime();
FGInterface *f; // assigned later
// and should really be read in from one or more files.
// Initial Velocity
- f->set_Velocities_Local( 0.0, 0.0, 0.0 );
+ f->set_Velocities_Local( current_options.get_uBody(),
+ current_options.get_vBody(),
+ current_options.get_wBody());
// Initial Orientation
f->set_Euler_Angles( current_options.get_roll() * DEG_TO_RAD,
FG_LOG( FG_GENERAL, FG_DEBUG, "After v->init()");
v->UpdateViewMath(f);
FG_LOG( FG_GENERAL, FG_DEBUG, " abs_view_pos = " << v->get_abs_view_pos());
- v->UpdateWorldToEye(f);
+ // v->UpdateWorldToEye(f);
// Build the solar system
//fgSolarSystemInit(*t);
fgEVENT::FG_EVENT_READY, 30000 );
// Initialize the weather modeling subsystem
- current_weather.Init();
+ // current_weather.Init();
+ // Initialize the WeatherDatabase
+ FG_LOG(FG_GENERAL, FG_INFO, "Creating LocalWeatherDatabase");
+ FGLocalWeatherDatabase::theFGLocalWeatherDatabase =
+ new FGLocalWeatherDatabase(
+ Point3D( current_aircraft.fdm_state->get_Latitude(),
+ current_aircraft.fdm_state->get_Longitude(),
+ current_aircraft.fdm_state->get_Altitude()
+ * FEET_TO_METER) );
+
+ WeatherDatabase = FGLocalWeatherDatabase::theFGLocalWeatherDatabase;
+
+ // register the periodic update of the weather
+ global_events.Register( "weather update", fgUpdateWeatherDatabase,
+ fgEVENT::FG_EVENT_READY, 30000);
// Initialize the Cockpit subsystem
if( fgCockpitInit( ¤t_aircraft )) {
FG_LOG( FG_GENERAL, FG_INFO, endl);
- return(1);
+ return true;
}
// and should really be read in from one or more files.
// Initial Velocity
- f->set_Velocities_Local( 0.0, 0.0, 0.0 );
+ f->set_Velocities_Local( current_options.get_uBody(),
+ current_options.get_vBody(),
+ current_options.get_wBody());
// Initial Orientation
f->set_Euler_Angles( current_options.get_roll() * DEG_TO_RAD,
FG_LOG( FG_GENERAL, FG_DEBUG, "After v->init()");
v->UpdateViewMath(f);
FG_LOG( FG_GENERAL, FG_DEBUG, " abs_view_pos = " << v->get_abs_view_pos());
- v->UpdateWorldToEye(f);
+ // v->UpdateWorldToEye(f);
fgFDMInit( current_options.get_flight_model(), cur_fdm_state,
1.0 / DEFAULT_MODEL_HZ );