From 9bd00a62facf50830e4eeccfbf8ce57f4c1f444f Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Sat, 14 May 2011 10:19:51 +0200 Subject: [PATCH] Continuous replay: use correct replay duration (LinuxTag live hacking...) --- src/Aircraft/replay.cxx | 19 ++++++++++++++++--- src/Main/fg_commands.cxx | 12 +----------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/Aircraft/replay.cxx b/src/Aircraft/replay.cxx index 890931a08..2baf32855 100644 --- a/src/Aircraft/replay.cxx +++ b/src/Aircraft/replay.cxx @@ -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: diff --git a/src/Main/fg_commands.cxx b/src/Main/fg_commands.cxx index 8f7a1c18c..45d4b901b 100644 --- a/src/Main/fg_commands.cxx +++ b/src/Main/fg_commands.cxx @@ -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; -- 2.39.5