]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/fg_init.cxx
Add David Culp's AI model manager code which is derived from David Luff's AI/ATC...
[flightgear.git] / src / Main / fg_init.cxx
index 818015a46ca6d5a3db71bdb28e0979763feddddf..873e82aac22f3a4e5424726fdf02c34c323abce9 100644 (file)
@@ -95,6 +95,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>
 #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,7 +858,7 @@ static bool fgSetPosFromAirportIDandRwy( const string& id, const string& rwy ) {
 
 
 static void fgSetDistOrAltFromGlideSlope() {
-  cout << "fgSetDistOrAltFromGlideSlope()" << endl;
+    // cout << "fgSetDistOrAltFromGlideSlope()" << endl;
     string apt_id = fgGetString("/sim/presets/airport-id");
     double gs = fgGetDouble("/sim/presets/glideslope-deg")
         * SG_DEGREES_TO_RADIANS ;
@@ -1044,7 +1046,7 @@ fgInitNav ()
 
 // Set the initial position based on presets (or defaults)
 bool fgInitPosition() {
-  cout << "fgInitPosition()" << endl;
+    // cout << "fgInitPosition()" << endl;
     double gs = fgGetDouble("/sim/presets/glideslope-deg")
         * SG_DEGREES_TO_RADIANS ;
     double od = fgGetDouble("/sim/presets/offset-distance");
@@ -1447,14 +1449,8 @@ bool fgInitSubsystems() {
     // Initialize the event manager subsystem.
     ////////////////////////////////////////////////////////////////////
 
-     globals->get_event_mgr()->bind();
      globals->get_event_mgr()->init();
-
-     // Output event stats every 60 seconds
-     globals->get_event_mgr()->add( "SGEventMgr::print_stats()",
-                                    globals->get_event_mgr(),
-                                    &SGEventMgr::print_stats,
-                                    60000 );
+     globals->get_event_mgr()->setFreezeProperty(fgGetNode("/sim/freeze/clock"));
 
     ////////////////////////////////////////////////////////////////////
     // Initialize the material property subsystem.
@@ -1483,10 +1479,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 " <<
@@ -1539,8 +1535,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 );
 
 
     ////////////////////////////////////////////////////////////////////
@@ -1659,6 +1655,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.
@@ -1788,6 +1792,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.
     ////////////////////////////////////////////////////////////////////