mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge #6118
6118: Copy the demo timeline markers when slicing a demo r=def- a=Robyt3 When slicing a demo, also copy the demo markers that are within the sliced segment to the new demo. This also fixes timeline markers not being added to replay demos, as the replay demos are always created by slicing. Closes #6116. ## Checklist - [X] 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
4695a6b0f1
|
@ -371,18 +371,26 @@ int CDemoRecorder::Stop()
|
|||
|
||||
void CDemoRecorder::AddDemoMarker()
|
||||
{
|
||||
if(m_LastTickMarker < 0 || m_NumTimelineMarkers >= MAX_TIMELINE_MARKERS)
|
||||
if(m_LastTickMarker < 0)
|
||||
return;
|
||||
AddDemoMarker(m_LastTickMarker);
|
||||
}
|
||||
|
||||
void CDemoRecorder::AddDemoMarker(int Tick)
|
||||
{
|
||||
dbg_assert(Tick >= 0, "invalid marker tick");
|
||||
if(m_NumTimelineMarkers >= MAX_TIMELINE_MARKERS)
|
||||
return;
|
||||
|
||||
// not more than 1 marker in a second
|
||||
if(m_NumTimelineMarkers > 0)
|
||||
{
|
||||
int Diff = m_LastTickMarker - m_aTimelineMarkers[m_NumTimelineMarkers - 1];
|
||||
int Diff = Tick - m_aTimelineMarkers[m_NumTimelineMarkers - 1];
|
||||
if(Diff < (float)SERVER_TICK_SPEED)
|
||||
return;
|
||||
}
|
||||
|
||||
m_aTimelineMarkers[m_NumTimelineMarkers++] = m_LastTickMarker;
|
||||
m_aTimelineMarkers[m_NumTimelineMarkers++] = Tick;
|
||||
|
||||
if(m_pConsole)
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "demo_recorder", "Added timeline marker", gs_DemoPrintColor);
|
||||
|
@ -1172,6 +1180,15 @@ void CDemoEditor::Slice(const char *pDemo, const char *pDst, int StartTick, int
|
|||
break;
|
||||
}
|
||||
|
||||
// Copy timeline markers to sliced demo
|
||||
for(int i = 0; i < pInfo->m_Info.m_NumTimelineMarkers; i++)
|
||||
{
|
||||
if((m_SliceFrom == -1 || pInfo->m_Info.m_aTimelineMarkers[i] >= m_SliceFrom) && (m_SliceTo == -1 || pInfo->m_Info.m_aTimelineMarkers[i] <= m_SliceTo))
|
||||
{
|
||||
m_pDemoRecorder->AddDemoMarker(pInfo->m_Info.m_aTimelineMarkers[i]);
|
||||
}
|
||||
}
|
||||
|
||||
m_pDemoPlayer->Stop();
|
||||
m_pDemoRecorder->Stop();
|
||||
} // NOLINT(clang-analyzer-unix.Malloc)
|
||||
|
|
|
@ -40,7 +40,9 @@ public:
|
|||
|
||||
int Start(class IStorage *pStorage, class IConsole *pConsole, const char *pFilename, const char *pNetversion, const char *pMap, SHA256_DIGEST *pSha256, unsigned MapCrc, const char *pType, unsigned MapSize, unsigned char *pMapData, IOHANDLE MapFile = nullptr, DEMOFUNC_FILTER pfnFilter = nullptr, void *pUser = nullptr);
|
||||
int Stop() override;
|
||||
|
||||
void AddDemoMarker();
|
||||
void AddDemoMarker(int Tick);
|
||||
|
||||
void RecordSnapshot(int Tick, const void *pData, int Size);
|
||||
void RecordMessage(const void *pData, int Size);
|
||||
|
|
Loading…
Reference in a new issue