]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/fg_init.cxx
Code reorganization.
[flightgear.git] / src / Main / fg_init.cxx
index 84a7d693b1ee160baa636f7c29104e5887a02167..8fd02cd841c05513bd06b34dd796996caa8c0255 100644 (file)
@@ -33,7 +33,7 @@
 #endif
 
 #include <GL/glut.h>
-#include <XGL/xgl.h>
+#include <simgear/xgl.h>
 
 #include <stdio.h>
 #include <stdlib.h>
 #  define _G_NO_EXTERN_TEMPLATES
 #endif
 
-#include <Include/compiler.h>
+#include <simgear/compiler.h>
 
 #include STL_STRING
 
-#include <Debug/logstream.hxx>
+#include <simgear/logstream.hxx>
+#include <simgear/constants.h>
+#include <simgear/fg_geodesy.hxx>
+#include <simgear/point3d.hxx>
+#include <simgear/polar3d.hxx>
+#include <simgear/fgpath.hxx>
+
 #include <Aircraft/aircraft.hxx>
 #include <Airports/simple.hxx>
 #include <Astro/sky.hxx>
 #include <Autopilot/autopilot.hxx>
 #include <Cockpit/cockpit.hxx>
 #include <FDM/Balloon.h>
+#include <FDM/External.hxx>
 #include <FDM/JSBsim.hxx>
 #include <FDM/LaRCsim.hxx>
 #include <FDM/MagicCarpet.hxx>
-#include <Include/fg_constants.h>
 #include <Include/general.hxx>
 #include <Joystick/joystick.hxx>
-#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>
@@ -82,9 +84,9 @@
 #endif
 
 #include "fg_init.hxx"
+#include "fg_io.hxx"
 #include "options.hxx"
 #include "views.hxx"
-#include "fg_serial.hxx"
 
 #if defined(FX) && defined(XMESA)
 #include <GL/xmesa.h>
@@ -123,7 +125,7 @@ bool fgInitConfig ( int argc, char **argv ) {
        return false;
     }
 
-    return true;
+   return true;
 }
 
 
@@ -181,7 +183,10 @@ bool fgInitPosition( void ) {
 // General house keeping initializations
 bool fgInitGeneral( void ) {
     string root;
+
+#if defined(FX) && defined(XMESA)
     char *mesa_win_state;
+#endif
 
     FG_LOG( FG_GENERAL, FG_INFO, "General Initialization" );
     FG_LOG( FG_GENERAL, FG_INFO, "======= ==============" );
@@ -233,11 +238,14 @@ bool fgInitSubsystems( void ) {
     } else if ( current_options.get_flight_model() == FGInterface::FG_JSBSIM ) {
        cur_fdm_state = new FGJSBsim;
     } else if ( current_options.get_flight_model() == 
-               FGInterface::FG_BALLOONSIM ) {
+               FGInterface::FG_BALLOONSIM ) {
        cur_fdm_state = new FGBalloonSim;
     } else if ( current_options.get_flight_model() == 
                FGInterface::FG_MAGICCARPET ) {
        cur_fdm_state = new FGMagicCarpet;
+    } else if ( current_options.get_flight_model() == 
+               FGInterface::FG_EXTERNAL ) {
+       cur_fdm_state = new FGExternal;
     } else {
        FG_LOG( FG_GENERAL, FG_ALERT,
                "No flight model, can't init aircraft" );
@@ -427,23 +435,31 @@ bool fgInitSubsystems( void ) {
                            fgMethodCallback<fgLIGHT>( &cur_light_params,
                                                       &fgLIGHT::Update),
                            fgEVENT::FG_EVENT_READY, 30000 );
+    // update the current timezone each 30 minutes
+    global_events.Register( "fgTIME::updateLocal()",
+                           fgMethodCallback<FGTime>(FGTime::cur_time_params, 
+                                                    &FGTime::updateLocal),
+                           fgEVENT::FG_EVENT_READY, 1800000);
 
     // Initialize the weather modeling subsystem
 #ifndef FG_OLD_WEATHER
     // Initialize the WeatherDatabase
     FG_LOG(FG_GENERAL, FG_INFO, "Creating LocalWeatherDatabase");
+    sgVec3 position;
+    sgSetVec3( position, current_aircraft.fdm_state->get_Latitude(),
+              current_aircraft.fdm_state->get_Longitude(),
+              current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER );
     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) );
+       new FGLocalWeatherDatabase( position );
+    // cout << theFGLocalWeatherDatabase << endl;
+    // cout << "visibility = " 
+    //      << theFGLocalWeatherDatabase->getWeatherVisibility() << endl;
 
     WeatherDatabase = FGLocalWeatherDatabase::theFGLocalWeatherDatabase;
-
+     
     // register the periodic update of the weather
     global_events.Register( "weather update", fgUpdateWeatherDatabase,
-                           fgEVENT::FG_EVENT_READY, 30000);
+                            fgEVENT::FG_EVENT_READY, 30000);
 #else
     current_weather.Init();
 #endif
@@ -491,9 +507,9 @@ bool fgInitSubsystems( void ) {
     // Autopilot init added here, by Jeff Goeke-Smith
     fgAPInit(&current_aircraft);
 
-    // Initialize serial ports
+    // Initialize I/O channels
 #if ! defined( MACOS )
-    fgSerialInit();
+    fgIOInit();
 #endif
 
     FG_LOG( FG_GENERAL, FG_INFO, endl);