]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/main.cxx
Make FGControls behave like a standard subsystem.
[flightgear.git] / src / Main / main.cxx
index 31058c2fbc03a1af3779f93b464a95cba7f313b8..792a20cb98416de085feff55417d10aeda18e043 100644 (file)
@@ -49,7 +49,6 @@
 #include <simgear/math/SGMath.hxx>
 #include <simgear/math/sg_random.h>
 
-#include <Aircraft/controls.hxx>
 #include <Model/panelnode.hxx>
 #include <Scenery/scenery.hxx>
 #include <Scenery/tilemgr.hxx>
@@ -60,6 +59,7 @@
 #include <Viewer/WindowSystemAdapter.hxx>
 #include <Viewer/splash.hxx>
 #include <Viewer/renderer.hxx>
+#include <Navaids/NavDataCache.hxx>
 
 #include "fg_commands.hxx"
 #include "fg_io.hxx"
@@ -79,31 +79,6 @@ using std::vector;
 // is initialized.
 extern int _bootstrap_OSInit;
 
-
-static void fgLoadInitialScenery()
-{
-    static SGPropertyNode_ptr scenery_loaded
-        = fgGetNode("sim/sceneryloaded", true);
-    static SGPropertyNode_ptr scenery_override
-        = fgGetNode("/sim/sceneryloaded-override", true);
-
-    if (!scenery_loaded->getBoolValue())
-    {
-        if (scenery_override->getBoolValue() ||
-            (globals->get_tile_mgr()->isSceneryLoaded()
-             && fgGetBool("sim/fdm-initialized"))) {
-            fgSetBool("sim/sceneryloaded",true);
-            fgSplashProgress("");
-        }
-        else
-        {
-            fgSplashProgress("loading scenery");
-            // be nice to loader threads while waiting for initial scenery, reduce to 2fps
-            SGTimeStamp::sleepForMSec(500);
-        }
-    }
-}
-
 // What should we do when we have nothing else to do?  Let's get ready
 // for the next move and update the display?
 static void fgMainLoop( void )
@@ -125,9 +100,6 @@ static void fgMainLoop( void )
     // update all subsystems
     globals->get_subsystem_mgr()->update(sim_dt);
 
-    // END Tile Manager updates
-    fgLoadInitialScenery();
-
     simgear::AtomicChangeListener::fireChangeListeners();
 
     SG_LOG( SG_GENERAL, SG_DEBUG, "" );
@@ -182,7 +154,6 @@ static void fgIdleFunction ( void ) {
     // our initializations out of the idle callback so that we can get a
     // splash screen up and running right away.
     static int idle_state = 0;
-    static int spin_count = 0;
   
     static osg::ref_ptr<GeneralInitOperation> genOp;
     if ( idle_state == 0 ) {
@@ -211,17 +182,17 @@ static void fgIdleFunction ( void ) {
         if (!guiFinishInit())
             return;
         idle_state++;
-        fgSplashProgress("loading aircraft list");
+        fgSplashProgress("loading-aircraft-list");
 
     } else if ( idle_state == 2 ) {
         idle_state++;
-        fgSplashProgress("loading navigation data");
+        fgSplashProgress("loading-nav-data");
 
     } else if ( idle_state == 3 ) {
         idle_state++;
         fgInitNav();
 
-        fgSplashProgress("initializing scenery system");
+        fgSplashProgress("init-scenery");
 
     } else if ( idle_state == 4 ) {
         idle_state+=2;
@@ -263,11 +234,11 @@ static void fgIdleFunction ( void ) {
         globals->get_scenery()->bind();
         globals->set_tile_mgr( new FGTileMgr );
 
-        fgSplashProgress("loading aircraft");
+        fgSplashProgress("loading-aircraft");
 
     } else if ( idle_state == 6 ) {
         idle_state++;
-        fgSplashProgress("creating subsystems");
+        fgSplashProgress("creating-subsystems");
 
     } else if ( idle_state == 7 ) {
         idle_state++;
@@ -275,7 +246,7 @@ static void fgIdleFunction ( void ) {
         st.stamp();
         fgCreateSubsystems();
         SG_LOG(SG_GENERAL, SG_INFO, "Creating subsystems took:" << st.elapsedMSec());
-        fgSplashProgress("binding subsystems");
+        fgSplashProgress("binding-subsystems");
       
     } else if ( idle_state == 8 ) {
         idle_state++;
@@ -284,16 +255,14 @@ static void fgIdleFunction ( void ) {
         globals->get_subsystem_mgr()->bind();
         SG_LOG(SG_GENERAL, SG_INFO, "Binding subsystems took:" << st.elapsedMSec());
 
-        fgSplashProgress("initing subsystems");
+        fgSplashProgress("init-subsystems");
     } else if ( idle_state == 9 ) {
         SGSubsystem::InitStatus status = globals->get_subsystem_mgr()->incrementalInit();
         if ( status == SGSubsystem::INIT_DONE) {
           ++idle_state;
-          fgSplashProgress("finishing subsystem init");
+          fgSplashProgress("finishing-subsystems");
         } else {
-          const char* spinChars = "-\\|/";
-          string msg = string("initing subsystems ") + spinChars[spin_count++ % 4];
-          fgSplashProgress(msg.c_str());
+          fgSplashProgress("init-subsystems");
         }
       
     } else if ( idle_state == 10 ) {
@@ -328,7 +297,7 @@ static void fgIdleFunction ( void ) {
                 "No METAR available to pick active runway" );
         }
 
-        fgSplashProgress("initializing graphics engine");
+        fgSplashProgress("init-graphics");
 
     } else if ( idle_state == 900 ) {
         idle_state = 1000;
@@ -394,9 +363,6 @@ int fgMainInit( int argc, char **argv ) {
     // seed the random number generator
     sg_srandom_time();
 
-    FGControls *controls = new FGControls;
-    globals->set_controls( controls );
-
     string_list *col = new string_list;
     globals->set_channel_options_list( col );
 
@@ -438,5 +404,9 @@ int fgMainInit( int argc, char **argv ) {
     delete globals;
     globals = NULL;
     
+    // delete the NavCache here. This will cause the destruction of many cached
+    // objects (eg, airports, navaids, runways).
+    delete flightgear::NavDataCache::instance();
+  
     return result;
 }