]> git.mxchange.org Git - flightgear.git/commitdiff
Remove static subsystem dependencies
authorThorstenB <brehmt@gmail.com>
Sun, 18 Nov 2012 16:20:11 +0000 (17:20 +0100)
committerThorstenB <brehmt@gmail.com>
Sun, 18 Nov 2012 16:29:29 +0000 (17:29 +0100)
preventing us from recreating subsystems on reset/reinit.

src/Airports/simple.cxx
src/Main/main.cxx

index 3ebaf29e2d7fa4224f45892056f46b314398c714..98aaba6f953fd276df827c1462e75ef0b14aefde 100644 (file)
@@ -257,10 +257,7 @@ FGPavement* FGAirport::getPavementByIndex(unsigned int aIndex) const
 
 FGRunway* FGAirport::getActiveRunwayForUsage() const
 {
-  static FGEnvironmentMgr* envMgr = NULL;
-  if (!envMgr) {
-    envMgr = (FGEnvironmentMgr *) globals->get_subsystem("environment");
-  }
+  FGEnvironmentMgr* envMgr = (FGEnvironmentMgr *) globals->get_subsystem("environment");
   
   // This forces West-facing rwys to be used in no-wind situations
   // which is consistent with Flightgear's initial setup.
index f8b0fe0aac403ca8de42302c1b4d5f31c43b22f0..50b1bb0264136a53bc8111cdf19c240f2469b980 100644 (file)
@@ -76,6 +76,7 @@ using std::vector;
 extern int _bootstrap_OSInit;
 
 static SGPropertyNode_ptr frame_signal;
+static TimeManager* timeMgr;
 
 // What should we do when we have nothing else to do?  Let's get ready
 // for the next move and update the display?
@@ -89,7 +90,6 @@ static void fgMainLoop( void )
     // compute simulated time (allowing for pause, warp, etc) and
     // real elapsed time
     double sim_dt, real_dt;
-    static TimeManager* timeMgr = (TimeManager*) globals->get_subsystem("time");
     timeMgr->computeTimeDeltas(sim_dt, real_dt);
 
     // update all subsystems
@@ -101,6 +101,14 @@ static void fgMainLoop( void )
 }
 
 
+static void registerMainLoop()
+{
+    // stash current frame signal property
+    frame_signal = fgGetNode("/sim/signals/frame", true);
+    timeMgr = (TimeManager*) globals->get_subsystem("time");
+    fgRegisterIdleHandler( fgMainLoop );
+}
+
 // This is the top level master main function that is registered as
 // our idle function
 
@@ -263,9 +271,7 @@ static void fgIdleFunction ( void ) {
         // We've finished all our initialization steps, from now on we
         // run the main loop.
         fgSetBool("sim/sceneryloaded", false);
-        // stash current frame signal property
-        frame_signal = fgGetNode("/sim/signals/frame", true);
-        fgRegisterIdleHandler( fgMainLoop );
+        registerMainLoop();
     }
 }