From 0506a72b30c3856177e4fa5040dffdd1ad34f95b Mon Sep 17 00:00:00 2001 From: Julian Smith Date: Thu, 18 Jun 2020 16:17:44 +0100 Subject: [PATCH] Improved handling of continuous replay and added recovery system. Continuous replay: If the user replays a continuous recording from file and then end replay with the 'My controls' or 'End replay' buttons, we now forget about the continuous recording. This enables the usual in-memory record/replay to be used subsequently. Also added a '-continuous' suffix to continuous fgtape filenames. New recovery system: If /sim/replay/recovery-period is set and greater than zero, we periodically save a single-item continuous recording to a recovery file called -recovery.fgtape (with no date or time in the name), doing so in such a way as to ensure that there is always a valid recovery file even if flightgear crashes. One can then resume the flight from the most recently-saved point by loading this from within flightgear or with the --load-tape=... option. Also did a fair amount of refactoring and tried to clarify the different property nodes that we embed within recordings. --- src/Aircraft/flightrecorder.cxx | 2 +- src/Aircraft/replay.cxx | 393 +++++++++++++++++++++----------- src/Aircraft/replay.hxx | 15 +- 3 files changed, 268 insertions(+), 142 deletions(-) diff --git a/src/Aircraft/flightrecorder.cxx b/src/Aircraft/flightrecorder.cxx index 81a8842b9..afcfcaecb 100644 --- a/src/Aircraft/flightrecorder.cxx +++ b/src/Aircraft/flightrecorder.cxx @@ -338,7 +338,7 @@ FGFlightRecorder::capture(double SimTime, FGReplayData* ReplayData) ReplayData->sim_time = SimTime; - if (in_replay) { + if (in_replay && !s_recent_raw_data.empty()) { // Record the fixed position of live user aircraft at the point at // which we started replay. // diff --git a/src/Aircraft/replay.cxx b/src/Aircraft/replay.cxx index 7521a8d10..1072d3ca0 100644 --- a/src/Aircraft/replay.cxx +++ b/src/Aircraft/replay.cxx @@ -161,7 +161,6 @@ FGReplay::FGReplay() : fdm->addChangeListener(this, true /*initial*/); } -static bool saveSetup(const SGPropertyNode* ConfigData, SGPath& p, SGPropertyNode_ptr& myMetaData, double Duration); static int PropertiesWrite(SGPropertyNode* root, std::ostream& out) { @@ -200,6 +199,45 @@ static void popupTip(const char* message, int delay) globals->get_commands()->execute("show-message", args); } +enum FGTapeType +{ + FGTapeType_NORMAL, + FGTapeType_CONTINUOUS, + FGTapeType_RECOVERY, +}; + +// Returns a path using different formats depending on : +// +// FGTapeType_NORMAL: /--