mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Merge #6222
6222: Fix undefined demo timeline markers when recording is not stopped r=def- a=Robyt3 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. ## Checklist - [ ] Tested the change ingame - [ ] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [ ] Written a unit test (especially base/) or added coverage to integration test - [ ] Considered possible null pointers and out of bounds array indexing - [ ] Changed no physics that affect existing maps - [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) Co-authored-by: Robert Müller <robytemueller@gmail.com>
This commit is contained in:
commit
1f5c2696d2
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue