]> git.mxchange.org Git - flightgear.git/commitdiff
Continuous replay: use correct replay duration
authorThorstenB <brehmt@gmail.com>
Sat, 14 May 2011 08:19:51 +0000 (10:19 +0200)
committerThorstenB <brehmt@gmail.com>
Sat, 14 May 2011 08:19:51 +0000 (10:19 +0200)
(LinuxTag live hacking...)

src/Aircraft/replay.cxx
src/Main/fg_commands.cxx

index 890931a08b593dee4aba51877ec45ba0e44db96f..2baf32855739aa928f55908d0ebaf617a85a8b85 100644 (file)
@@ -197,12 +197,25 @@ void FGReplay::update( double dt )
         case 1:
             {
                 // replay active
+                double current_time = replay_time->getDoubleValue();
+                if (current_time<0.0)
+                {
+                    // initialize start time
+                    fgSetDouble( "/sim/replay/start-time", get_start_time() );
+                    fgSetDouble( "/sim/replay/end-time", get_end_time() );
+                    double duration = fgGetDouble( "/sim/replay/duration" );
+                    if( duration && duration < (get_end_time() - get_start_time()) ) {
+                        current_time = get_end_time() - duration;
+                    } else {
+                        current_time = get_start_time();
+                    }
+                }
                 bool IsFinished = replay( replay_time->getDoubleValue() );
                 if ((IsFinished)&&(replay_looped->getBoolValue()))
-                    replay_time->setDoubleValue(0.0);
+                    current_time = -1;
                 else
-                    replay_time->setDoubleValue( replay_time->getDoubleValue()
-                                                 + ( dt * fgGetInt("/sim/speed-up") ) );
+                    current_time += dt * fgGetInt("/sim/speed-up");
+                replay_time->setDoubleValue(current_time);
             }
             return; // don't record the replay session 
         case 2:
index 8f7a1c18cab9ebb2ca620b7188244e0c520152fe..45d4b901b5a14f39974ef458547e57763b21f3b8 100644 (file)
@@ -1247,17 +1247,7 @@ do_replay (const SGPropertyNode * arg)
     fgSetInt( "/sim/freeze/replay-state", 1 );
     fgSetBool("/sim/freeze/master", 0 );
     fgSetBool("/sim/freeze/clock", 0 );
-
-    FGReplay *r = (FGReplay *)(globals->get_subsystem( "replay" ));
-
-    fgSetDouble( "/sim/replay/start-time", r->get_start_time() );
-    fgSetDouble( "/sim/replay/end-time", r->get_end_time() );
-    double duration = fgGetDouble( "/sim/replay/duration" );
-    if( duration && duration < (r->get_end_time() - r->get_start_time()) ) {
-        fgSetDouble( "/sim/replay/time", r->get_end_time() - duration );
-    } else {
-        fgSetDouble( "/sim/replay/time", r->get_start_time() );
-    }
+    fgSetDouble( "/sim/replay/time", -1 );
 
     // cout << "start = " << r->get_start_time()
     //      << "  end = " << r->get_end_time() << endl;