]> git.mxchange.org Git - flightgear.git/commitdiff
Some follow up patches from Norman Vine.
authorcurt <curt>
Wed, 6 Feb 2002 23:31:33 +0000 (23:31 +0000)
committercurt <curt>
Wed, 6 Feb 2002 23:31:33 +0000 (23:31 +0000)
src/GUI/gui_local.cxx
src/Main/fg_init.cxx
src/Main/fg_init.hxx
src/Main/main.cxx

index e351f5099af4fa7ca3f794a0d8d884368feabb57..f537d60890d6e37b582a75d3510387501c6828ac 100644 (file)
@@ -73,13 +73,18 @@ void reInit(puObject *cb)
 
     globals->restoreInitialState();
 
-       // Unsuccessful KLUDGE to fix the 'every other time'
-       // problem when doing a 'reset' after a 'goto airport'
+    // Unsuccessful KLUDGE to fix the 'every other time'
+    // problem when doing a 'reset' after a 'goto airport'
        
-       // string AptId( fgGetString("/sim/startup/airport-id") );
-       // if( AptId.c_str() != "\0" )
-       //      fgSetPosFromAirportID( AptId );
+    // string AptId( fgGetString("/sim/startup/airport-id") );
+    // if( AptId.c_str() != "\0" )
+    //      fgSetPosFromAirportID( AptId );
        
+    SGTime *t = globals->get_time_params();
+    delete t;
+    t = fgInitTime();
+    globals->set_time_params( t );
+
     fgReInitSubsystems();
 
     // reduntant(fgReInitSubsystems) ?
index c0922a59840294710189dddbff927296057313b7..8174feee897c2b56ca6c6dd17af22d63b77c947d 100644 (file)
@@ -63,6 +63,7 @@
 #include <simgear/math/sg_geodesy.hxx>
 #include <simgear/misc/sg_path.hxx>
 #include <simgear/timing/sg_time.hxx>
+#include <simgear/timing/lowleveltime.h>
 
 #include <Aircraft/aircraft.hxx>
 #include <FDM/UIUCModel/uiuc_aircraftdir.h>
@@ -583,6 +584,61 @@ void fgInitView() {
 }
 
 
+SGTime *fgInitTime() {
+    // Initialize time
+    static const SGPropertyNode *longitude
+       = fgGetNode("/position/longitude-deg");
+    static const SGPropertyNode *latitude
+       = fgGetNode("/position/latitude-deg");
+       
+    SGPath zone( globals->get_fg_root() );
+    zone.append( "Timezone" );
+    SGTime *t = new SGTime( longitude->getDoubleValue()
+                              * SGD_DEGREES_TO_RADIANS,
+                            latitude->getDoubleValue()
+                              * SGD_DEGREES_TO_RADIANS,
+                            zone.str() );
+
+    // Handle potential user specified time offsets
+    time_t cur_time = t->get_cur_time();
+    time_t currGMT = sgTimeGetGMT( gmtime(&cur_time) );
+    time_t systemLocalTime = sgTimeGetGMT( localtime(&cur_time) );
+    time_t aircraftLocalTime = 
+        sgTimeGetGMT( fgLocaltime(&cur_time, t->get_zonename() ) );
+
+    // Okay, we now have six possible scenarios
+    int offset = fgGetInt("/sim/startup/time-offset");
+    const string &offset_type = fgGetString("/sim/startup/time-offset-type");
+    if (offset_type == "system-offset") {
+        globals->set_warp( offset );
+    } else if (offset_type == "gmt-offset") {
+        globals->set_warp( offset - (currGMT - systemLocalTime) );
+    } else if (offset_type == "latitude-offset") {
+        globals->set_warp( offset - (aircraftLocalTime - systemLocalTime) );
+    } else if (offset_type == "system") {
+        globals->set_warp( offset - cur_time );
+    } else if (offset_type == "gmt") {
+        globals->set_warp( offset - currGMT );
+    } else if (offset_type == "latitude") {
+        globals->set_warp( offset - (aircraftLocalTime - systemLocalTime) - 
+                           cur_time ); 
+    } else {
+        SG_LOG( SG_GENERAL, SG_ALERT,
+                "FG_TIME::Unsupported offset type " << offset_type );
+        exit( -1 );
+    }
+
+    SG_LOG( SG_GENERAL, SG_INFO, "After time init, warp = " 
+            << globals->get_warp() );
+
+    globals->set_warp_delta( 0 );
+
+    t->update( 0.0, 0.0, globals->get_warp() );
+
+    return t;
+}
+
+
 // This is the top level init routine which calls all the other
 // initialization routines.  If you are adding a subsystem to flight
 // gear, its initialization call should located in this routine.
@@ -622,8 +678,8 @@ bool fgInitSubsystems( void ) {
 
     if ( global_tile_mgr.init() ) {
        // Load the local scenery data
-       global_tile_mgr.update( fgGetDouble("/position/longitude-deg"),
-                               fgGetDouble("/position/latitude-deg") );
+       global_tile_mgr.update( longitude->getDoubleValue(),
+                               latitude->getDoubleValue() );
     } else {
        SG_LOG( SG_GENERAL, SG_ALERT, "Error in Tile Manager initialization!" );
        exit(-1);
index ea53fdb8b316cb44a35c709c7154001ab0241cd0..23350450e5afb65ee1d4c74ac0c9d91b0ccd9ae5 100644 (file)
@@ -36,6 +36,7 @@
 #endif
 
 #include <simgear/compiler.h>
+#include <simgear/timing/sg_time.hxx>
 
 #include STL_STRING
 
@@ -79,6 +80,9 @@ bool fgSetPosFromAirportID( const string& id );
 // Set position and heading given an airport id and heading (degrees)
 bool fgSetPosFromAirportIDandHdg( const string& id, double tgt_hdg );
 
+// Initialize various time dependent systems (lighting, sun position, etc.)
+// returns a new instance of the SGTime class
+SGTime *fgInitTime();
 
 #endif // _FG_INIT_HXX
 
index c935e4da2b96da481b00e5a888ccd0c59d36e379..f1042f9fd7fe12fca293575b354844f57df2bd7f 100644 (file)
@@ -561,9 +561,8 @@ void fgRenderFrame( void ) {
 #endif
 
        thesky->modify_vis( cur_fdm_state->get_Altitude() * SG_FEET_TO_METER,
-                           ( global_multi_loop * 
-                             fgGetInt("/sim/speed-up") ) /
-                           (double)fgGetInt("/sim/model-hz") );
+                           ( global_multi_loop * fgGetInt("/sim/speed-up") )
+                            / (double)fgGetInt("/sim/model-hz") );
 
        double actual_visibility = thesky->get_visibility();
        // cout << "actual visibility = " << actual_visibility << endl;
@@ -1518,59 +1517,7 @@ int mainLoop( int argc, char **argv ) {
                                     fgGetDouble("/orientation/heading-deg") );
     }
 
-    // Any time after globals is created we are ready to use the
-    // property system
-    static const SGPropertyNode *longitude
-       = fgGetNode("/position/longitude-deg", true);
-    static const SGPropertyNode *latitude
-       = fgGetNode("/position/latitude-deg", true);
-
-
-    // Initialize time
-    SGPath zone( globals->get_fg_root() );
-    zone.append( "Timezone" );
-    SGTime *t = new SGTime( longitude->getDoubleValue()
-                             * SGD_DEGREES_TO_RADIANS,
-                           latitude->getDoubleValue()
-                             * SGD_DEGREES_TO_RADIANS,
-                           zone.str() );
-
-    // Handle potential user specified time offsets
-    time_t cur_time = t->get_cur_time();
-    time_t currGMT = sgTimeGetGMT( gmtime(&cur_time) );
-    time_t systemLocalTime = sgTimeGetGMT( localtime(&cur_time) );
-    time_t aircraftLocalTime = 
-       sgTimeGetGMT( fgLocaltime(&cur_time, t->get_zonename() ) );
-
-    // Okay, we now have six possible scenarios
-    int offset = fgGetInt("/sim/startup/time-offset");
-    const string &offset_type = fgGetString("/sim/startup/time-offset-type");
-    if (offset_type == "system-offset") {
-        globals->set_warp( offset );
-    } else if (offset_type == "gmt-offset") {
-       globals->set_warp( offset - (currGMT - systemLocalTime) );
-    } else if (offset_type == "latitude-offset") {
-       globals->set_warp( offset - (aircraftLocalTime - systemLocalTime) );
-    } else if (offset_type == "system") {
-       globals->set_warp( offset - cur_time );
-    } else if (offset_type == "gmt") {
-       globals->set_warp( offset - currGMT );
-    } else if (offset_type == "latitude") {
-       globals->set_warp( offset - (aircraftLocalTime - systemLocalTime) - 
-                          cur_time ); 
-    } else {
-        SG_LOG( SG_GENERAL, SG_ALERT,
-               "Unsupported offset type " << offset_type );
-       exit( -1 );
-    }
-
-    SG_LOG( SG_GENERAL, SG_INFO, "After time init, warp = " 
-           << globals->get_warp() );
-
-    globals->set_warp_delta( 0 );
-
-    t->update( 0.0, 0.0, globals->get_warp() );
-
+    SGTime *t = fgInitTime();
     globals->set_time_params( t );
 
     // Do some quick general initializations