From 9ea665cd697685defb36e7fecf446e0f17bcb350 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Tue, 3 Jan 2023 15:38:51 +0100 Subject: [PATCH] Fix undefined demo timeline markers when recording is not stopped When the demo recording is not stopped properly (e.g. client crashes during recording), the timeline markers and the demo length are not updated. The length is always set to zero when starting the recording, but uninitialized memory is written for the timeline markers, which causes these demos to likely show the maximum number of markers with some markers possibly being outside the ticks that the demo contains. This is fixed by initially setting all timeline marker data to zero when starting the recording. --- src/engine/shared/demo.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/engine/shared/demo.cpp b/src/engine/shared/demo.cpp index 7ed9daf24..0d7c43422 100644 --- a/src/engine/shared/demo.cpp +++ b/src/engine/shared/demo.cpp @@ -65,8 +65,6 @@ int CDemoRecorder::Start(class IStorage *pStorage, class IConsole *pConsole, con return -1; } - CDemoHeader Header; - CTimelineMarkers TimelineMarkers; if(m_File) { io_close(DemoFile); @@ -130,6 +128,7 @@ int CDemoRecorder::Start(class IStorage *pStorage, class IConsole *pConsole, con MapSize = io_length(MapFile); // write header + CDemoHeader Header; mem_zero(&Header, sizeof(Header)); mem_copy(Header.m_aMarker, gs_aHeaderMarker, sizeof(Header.m_aMarker)); Header.m_Version = gs_CurVersion; @@ -141,6 +140,9 @@ int CDemoRecorder::Start(class IStorage *pStorage, class IConsole *pConsole, con // Header.m_Length - add this on stop str_timestamp(Header.m_aTimestamp, sizeof(Header.m_aTimestamp)); io_write(DemoFile, &Header, sizeof(Header)); + + CTimelineMarkers TimelineMarkers; + mem_zero(&TimelineMarkers, sizeof(TimelineMarkers)); io_write(DemoFile, &TimelineMarkers, sizeof(TimelineMarkers)); // fill this on stop //Write Sha256