]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/fg_init.cxx
Fix the nmea and garmin output to a) fake a GSA sentence, b) fix a y2k bug
[flightgear.git] / src / Main / fg_init.cxx
index c3662cfc93fe7fd3edc72608a926af90ac03b635..52d9199349fbaedb9ab9dcbe2c2419a1ea8d621b 100644 (file)
@@ -58,6 +58,7 @@
 #include <simgear/math/polar3d.hxx>
 #include <simgear/math/sg_geodesy.hxx>
 #include <simgear/misc/sg_path.hxx>
+#include <simgear/misc/interpolator.hxx>
 #include <simgear/scene/material/matlib.hxx>
 #ifdef FG_USE_CLOUDS_3D
 #  include <simgear/scene/sky/clouds3d/SkySceneLoader.hpp>
@@ -95,6 +96,7 @@
 #include <Input/input.hxx>
 #include <Instrumentation/instrument_mgr.hxx>
 #include <Model/acmodel.hxx>
+#include <AIModel/AIManager.hxx>
 #include <Navaids/fixlist.hxx>
 #include <Navaids/ilslist.hxx>
 #include <Navaids/mkrbeacons.hxx>
 #include <Replay/replay.hxx>
 #include <Scenery/scenery.hxx>
 #include <Scenery/tilemgr.hxx>
-#if defined(HAVE_PLIB_PSL)
-#include <Scripting/scriptmgr.hxx>
-#endif
+#include <Scripting/NasalSys.hxx>
 #include <Sound/fg_fx.hxx>
 #include <Systems/system_mgr.hxx>
 #include <Time/light.hxx>
@@ -856,6 +856,7 @@ static bool fgSetPosFromAirportIDandRwy( const string& id, const string& rwy ) {
 
 
 static void fgSetDistOrAltFromGlideSlope() {
+    // cout << "fgSetDistOrAltFromGlideSlope()" << endl;
     string apt_id = fgGetString("/sim/presets/airport-id");
     double gs = fgGetDouble("/sim/presets/glideslope-deg")
         * SG_DEGREES_TO_RADIANS ;
@@ -1043,12 +1044,18 @@ fgInitNav ()
 
 // Set the initial position based on presets (or defaults)
 bool fgInitPosition() {
+    // cout << "fgInitPosition()" << endl;
+    double gs = fgGetDouble("/sim/presets/glideslope-deg")
+        * SG_DEGREES_TO_RADIANS ;
+    double od = fgGetDouble("/sim/presets/offset-distance");
+    double alt = fgGetDouble("/sim/presets/altitude-ft");
+
     bool set_pos = false;
 
     // If glideslope is specified, then calculate offset-distance or
     // altitude relative to glide slope if either of those was not
     // specified.
-    if ( fgGetDouble("/sim/presets/glideslope-deg") > 0.1 ) {
+    if ( fabs( gs ) > 0.01 ) {
         fgSetDistOrAltFromGlideSlope();
     }
 
@@ -1131,6 +1138,13 @@ bool fgInitPosition() {
     fgSetDouble( "/orientation/heading-deg",
                  fgGetDouble("/sim/presets/heading-deg") );
 
+    // determine if this should be an on-ground or in-air start
+    if ( fabs(gs) > 0.01 || fabs(od) > 0.1 || alt > 0.1 ) {
+        fgSetBool("/sim/presets/onground", false);
+    } else {
+        fgSetBool("/sim/presets/onground", true);
+    }                              
+
     return true;
 }
 
@@ -1433,14 +1447,13 @@ bool fgInitSubsystems() {
     // Initialize the event manager subsystem.
     ////////////////////////////////////////////////////////////////////
 
-     globals->get_event_mgr()->bind();
      globals->get_event_mgr()->init();
+     globals->get_event_mgr()->setFreezeProperty(fgGetNode("/sim/freeze/clock"));
 
-     // Output event stats every 60 seconds
-     globals->get_event_mgr()->add( "SGEventMgr::print_stats()",
-                                    globals->get_event_mgr(),
-                                    &SGEventMgr::print_stats,
-                                    60000 );
+    ////////////////////////////////////////////////////////////////////
+    // Initialize the property interpolator subsystem
+    ////////////////////////////////////////////////////////////////////
+    globals->add_subsystem("interpolator", new SGInterpolator());
 
     ////////////////////////////////////////////////////////////////////
     // Initialize the material property subsystem.
@@ -1469,10 +1482,10 @@ bool fgInitSubsystems() {
     }
 
     // cause refresh of viewer scenery timestamps every 15 seconds...
-    globals->get_event_mgr()->add( "FGTileMgr::refresh_view_timestamps()",
-                                   globals->get_tile_mgr(),
-                                   &FGTileMgr::refresh_view_timestamps,
-                                   15000 );
+    globals->get_event_mgr()->addTask( "FGTileMgr::refresh_view_timestamps()",
+                                       globals->get_tile_mgr(),
+                                       &FGTileMgr::refresh_view_timestamps,
+                                       15 );
 
     SG_LOG( SG_GENERAL, SG_DEBUG,
             "Current terrain elevation after tile mgr init " <<
@@ -1503,16 +1516,6 @@ bool fgInitSubsystems() {
     
     globals->add_subsystem("logger", new FGLogger);
 
-
-#if defined(HAVE_PLIB_PSL)
-    ////////////////////////////////////////////////////////////////////
-    // Create and register the script manager.
-    ////////////////////////////////////////////////////////////////////
-
-    globals->add_subsystem("scripting", new FGScriptMgr);
-#endif // HAVE_PLIB_PSL
-
-
     ////////////////////////////////////////////////////////////////////
     // Create and register the XML GUI.
     ////////////////////////////////////////////////////////////////////
@@ -1525,8 +1528,8 @@ bool fgInitSubsystems() {
     ////////////////////////////////////////////////////////////////////
 
     // update the current timezone each 30 minutes
-    globals->get_event_mgr()->add( "fgUpdateLocalTime()",
-                                   &fgUpdateLocalTime, 30*60*1000 );
+    globals->get_event_mgr()->addTask( "fgUpdateLocalTime()",
+                                       &fgUpdateLocalTime, 30*60 );
 
 
     ////////////////////////////////////////////////////////////////////
@@ -1645,6 +1648,14 @@ bool fgInitSubsystems() {
     globals->get_AI_mgr()->init();
 
 
+    ////////////////////////////////////////////////////////////////////
+    // Initialise the AI Model Manager
+    ////////////////////////////////////////////////////////////////////
+
+    SG_LOG(SG_GENERAL, SG_INFO, "  AI Model Manager");
+    globals->add_subsystem("ai_model", new FGAIManager);
+
+
 #ifdef ENABLE_AUDIO_SUPPORT
     ////////////////////////////////////////////////////////////////////
     // Initialize the sound subsystem.
@@ -1774,6 +1785,14 @@ bool fgInitSubsystems() {
     globals->get_multiplayer_rx_mgr()->init();
 #endif
 
+    ////////////////////////////////////////////////////////////////////////
+    // Initialize the Nasal interpreter.
+    // Do this last, so that the loaded scripts see initialized state
+    ////////////////////////////////////////////////////////////////////////
+    FGNasalSys* nasal = new FGNasalSys();
+    globals->add_subsystem("nasal", nasal);
+    nasal->init();
+
     ////////////////////////////////////////////////////////////////////////
     // End of subsystem initialization.
     ////////////////////////////////////////////////////////////////////
@@ -1825,6 +1844,9 @@ void fgReInitSubsystems()
 
     fgUpdateLocalTime();
 
+    // re-init to proper time of day setting
+    fgInitTimeOffset();
+
     if ( !freeze ) {
         fgSetBool("/sim/freeze/master", false);
     }