From b6d70d2c719d2f62c161a4d8d2445bdba2b21a33 Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Sun, 20 Mar 2011 14:59:19 +0100 Subject: [PATCH] Replay improvements Clear replay buffers on sim reset. Allow instant replay to be activated properly when sim is paused. --- src/Aircraft/replay.cxx | 13 +++++++++---- src/Aircraft/replay.hxx | 2 ++ src/Main/fg_commands.cxx | 4 +++- src/Main/fg_init.cxx | 3 +++ 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Aircraft/replay.cxx b/src/Aircraft/replay.cxx index aa976adcb..6c5c410d8 100644 --- a/src/Aircraft/replay.cxx +++ b/src/Aircraft/replay.cxx @@ -83,6 +83,14 @@ FGReplay::~FGReplay() { */ void FGReplay::init() { + reinit(); +} + +/** + * Reset replay queues. + */ + +void FGReplay::reinit() { sim_time = 0.0; last_mt_time = 0.0; last_lt_time = 0.0; @@ -110,17 +118,16 @@ void FGReplay::init() { (lt_list_time*lt_dt)); for (int i = 0; i < estNrObjects; i++) { recycler.push_back(new FGReplayData); - } } - /** * Bind to the property tree */ void FGReplay::bind() { disable_replay = fgGetNode( "/sim/replay/disable", true ); + replay_master = fgGetNode( "/sim/freeze/replay-state", true ); } @@ -140,8 +147,6 @@ void FGReplay::unbind() { void FGReplay::update( double dt ) { timingInfo.clear(); stamp("begin"); - static SGPropertyNode *replay_master - = fgGetNode( "/sim/freeze/replay-state", true ); if( disable_replay->getBoolValue() ) { if ( sim_time != 0.0 ) { diff --git a/src/Aircraft/replay.hxx b/src/Aircraft/replay.hxx index 0e599c1a4..bad1ce8b1 100644 --- a/src/Aircraft/replay.hxx +++ b/src/Aircraft/replay.hxx @@ -69,6 +69,7 @@ public: virtual ~FGReplay(); virtual void init(); + virtual void reinit(); virtual void bind(); virtual void unbind(); virtual void update( double dt ); @@ -96,6 +97,7 @@ private: replay_list_type long_term; replay_list_type recycler; SGPropertyNode_ptr disable_replay; + SGPropertyNode_ptr replay_master; }; diff --git a/src/Main/fg_commands.cxx b/src/Main/fg_commands.cxx index 97f5ca399..d2b5b021e 100644 --- a/src/Main/fg_commands.cxx +++ b/src/Main/fg_commands.cxx @@ -1243,8 +1243,10 @@ do_log_level (const SGPropertyNode * arg) static bool do_replay (const SGPropertyNode * arg) { - // freeze the master fdm + // freeze the fdm, resume from sim pause fgSetInt( "/sim/freeze/replay-state", 1 ); + fgSetBool("/sim/freeze/master", 0 ); + fgSetBool("/sim/freeze/clock", 0 ); FGReplay *r = (FGReplay *)(globals->get_subsystem( "replay" )); diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index a615eddee..260f9ef22 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -1553,6 +1553,9 @@ void fgReInitSubsystems() // Initialize the FDM globals->get_subsystem("flight")->reinit(); + // reset replay buffers + globals->get_subsystem("replay")->reinit(); + // reload offsets from config defaults globals->get_viewmgr()->reinit(); -- 2.39.5