]> git.mxchange.org Git - flightgear.git/commitdiff
Added a clock freeze option (/sim/freeze/clock). This can be specified
authorcurt <curt>
Wed, 13 Feb 2002 02:37:44 +0000 (02:37 +0000)
committercurt <curt>
Wed, 13 Feb 2002 02:37:44 +0000 (02:37 +0000)
via the command line (--enable-clock-freeze / --disable-clock-freeze)
and can be toggled during a run.  However this property is not currently
bound to any menu or keystroke so you have to do it via the gui property
interface or externally via the web property browser or a script.

src/Main/main.cxx
src/Main/options.cxx

index 771a671bd32757dc2997f4f8d2966b2a3d3bb027..129eb53045d9fc4738144988bb828b58bc3d1efe 100644 (file)
@@ -999,6 +999,8 @@ static void fgMainLoop( void ) {
        = fgGetNode("/position/latitude-deg");
     static const SGPropertyNode *altitude
        = fgGetNode("/position/altitude-ft");
+    static const SGPropertyNode *clock_freeze
+       = fgGetNode("/sim/freeze/clock", true);
     static const SGPropertyNode *cur_time_override
        = fgGetNode("/sim/time/cur-time-override", true);
 
@@ -1077,10 +1079,32 @@ static void fgMainLoop( void ) {
     // cout << "Warp = " << globals->get_warp() << endl;
 
     // update "time"
-    if ( globals->get_warp_delta() != 0 ) {
-       globals->inc_warp( globals->get_warp_delta() );
+    static bool last_clock_freeze = false;
+
+    if ( clock_freeze->getBoolValue() ) {
+       // clock freeze requested
+       if ( cur_time_override->getLongValue() == 0 ) {
+           fgSetLong( "/sim/time/cur-time-override",
+                      t->get_cur_time() + globals->get_warp() );
+           globals->set_warp( 0 );
+       }
+    } else {
+       // no clock freeze requested
+       if ( last_clock_freeze == true ) {
+           // clock just unfroze, let's set warp as the difference
+           // between frozen time and current time so we don't get a
+           // time jump (and corresponding sky object and lighting
+           // jump.)
+           globals->set_warp( cur_time_override->getLongValue() - time(NULL) );
+           fgSetLong( "/sim/time/cur-time-override", 0 );
+       }
+       if ( globals->get_warp_delta() != 0 ) {
+           globals->inc_warp( globals->get_warp_delta() );
+       }
     }
 
+    last_clock_freeze = clock_freeze->getBoolValue();
+
     t->update( longitude->getDoubleValue() * SGD_DEGREES_TO_RADIANS,
               latitude->getDoubleValue() * SGD_DEGREES_TO_RADIANS,
               cur_time_override->getLongValue(),
index 63bee6de04fb76b5ba4aef575a4eff1e2693e0f2..b6cd6741dc40dcb3da5ce2c0f57300ee4321bfd1 100644 (file)
@@ -192,7 +192,7 @@ fgSetDefaults ()
                                 // Freeze options
     fgSetBool("/sim/freeze/master", false);
     fgSetBool("/sim/freeze/position", false);
-    fgSetBool("/sim/freeze/time-of-day", false);
+    fgSetBool("/sim/freeze/clock", false);
     fgSetBool("/sim/freeze/fuel", false);
 }
 
@@ -562,10 +562,10 @@ parse_option (const string& arg)
         fgSetBool("/sim/freeze/fuel", false);
     } else if ( arg == "--enable-fuel-freeze" ) {
         fgSetBool("/sim/freeze/fuel", true);
-    } else if ( arg == "--disable-tod-freeze" ) {
-        fgSetBool("/sim/freeze/time-of-day", false);
-    } else if ( arg == "--enable-tod-freeze" ) {
-        fgSetBool("/sim/freeze/time-of-day", true);
+    } else if ( arg == "--disable-clock-freeze" ) {
+        fgSetBool("/sim/freeze/clock", false);
+    } else if ( arg == "--enable-clock-freeze" ) {
+        fgSetBool("/sim/freeze/clock", true);
     } else if ( arg == "--disable-anti-alias-hud" ) {
        fgSetBool("/sim/hud/antialiased", false);
     } else if ( arg == "--enable-anti-alias-hud" ) {
@@ -1117,8 +1117,8 @@ fgUsage ()
          << "    --enable-freeze               Start in a frozen state" << endl
          << "    --disable-fuel-freeze         Fuel is consumed normally" << endl
          << "    --enable-fuel-freeze          Fuel tank quantity forced to remain constant" << endl
-         << "    --disable-tod-freeze          Time of day advances normally" << endl
-         << "    --enable-tod-freeze           Do not advance time of day" << endl
+         << "    --disable-clock-freeze        Clock advances normally" << endl
+         << "    --enable-clock-freeze         Do not advance clock" << endl
          << "    --control=mode                Primary control mode (joystick, keyboard," << endl
          << "                                  mouse)" << endl
          << "    --enable-auto-coordination    Enable auto coordination" << endl