From d7b889a74a31d62530f1823ef855034c323af1af Mon Sep 17 00:00:00 2001 From: Julian Smith Date: Sun, 28 Feb 2021 11:41:11 +0000 Subject: [PATCH] src/Aircraft/replay.*: Be able to exclude user aircraft's signals from Continuous recording. Controlled by /sim/replay/record-signals. E.g. one can now record only multiplayer aircraft. --- src/Aircraft/replay.cxx | 38 +++++++++++++++++++++++++++++++++++--- src/Aircraft/replay.hxx | 2 ++ 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/Aircraft/replay.cxx b/src/Aircraft/replay.cxx index 81c364482..331c52980 100644 --- a/src/Aircraft/replay.cxx +++ b/src/Aircraft/replay.cxx @@ -727,8 +727,10 @@ static SGPropertyNode_ptr saveSetup( copyProperties(extra->getNode("user-data"), meta->getNode("user-data", 0, true)); } - // We always record signals. - config->addChild("data")->setStringValue("signals"); + if (tape_type != FGTapeType_CONTINUOUS + || fgGetBool("/sim/replay/record-signals", true)) { + config->addChild("data")->setStringValue("signals"); + } if (tape_type == FGTapeType_CONTINUOUS) { if (fgGetBool("/sim/replay/record-multiplayer", false)) { @@ -803,6 +805,36 @@ FGReplay::continuousWriteFrame(FGReplayData* r, std::ostream& out, SGPropertyNod << " out.tellp()=" << out.tellp() << " r->sim_time=" << r->sim_time ); + // Don't write frame if no data to write. + bool r_has_data = false; + for (auto data: config->getChildren("data")) { + const char* data_type = data->getStringValue(); + if (!strcmp(data_type, "signals")) { + r_has_data = true; + break; + } + else if (!strcmp(data_type, "multiplayer")) { + if (!r->multiplayer_messages.empty()) { + r_has_data = true; + break; + } + } + else if (!strcmp(data_type, "extra-properties")) { + if (!r->extra_properties.empty()) { + r_has_data = true; + break; + } + } + else { + SG_LOG(SG_SYSTEMS, SG_ALERT, "unrecognised data_type=" << data_type); + assert(0); + } + } + if (!r_has_data) { + SG_LOG(SG_SYSTEMS, SG_DEBUG, "Not writing frame because no data to write"); + return true; + } + out.write(reinterpret_cast(&r->sim_time), sizeof(r->sim_time)); for (auto data: config->getChildren("data")) { @@ -1564,7 +1596,7 @@ static std::unique_ptr ReadFGReplayData( std::unique_ptr ret(new FGReplayData); in.read(reinterpret_cast(&ret->sim_time), sizeof(ret->sim_time)); - + ret->raw_data.resize(0); for (auto data: config->getChildren("data")) { const char* data_type = data->getStringValue(); SG_LOG(SG_SYSTEMS, SG_DEBUG, "in.tellg()=" << in.tellg() << " data_type=" << data_type); diff --git a/src/Aircraft/replay.hxx b/src/Aircraft/replay.hxx index ab938b58c..c297d6d38 100644 --- a/src/Aircraft/replay.hxx +++ b/src/Aircraft/replay.hxx @@ -251,6 +251,8 @@ private: void valueChanged(SGPropertyNode * node); + bool m_continuoue_out_signals; + // Things for replaying from uncompressed fgtape file. std::ifstream m_continuous_in; bool m_continuous_in_multiplayer;