1#include "demoedit.h"
2
3#include <base/str.h>
4
5#include <engine/shared/demo.h>
6#include <engine/storage.h>
7
8CDemoEdit::CDemoEdit(const char *pNetVersion, class CSnapshotDelta *pSnapshotDelta, IStorage *pStorage, const char *pDemo, const char *pDst, int StartTick, int EndTick) :
9 m_SnapshotDelta(*pSnapshotDelta),
10 m_pStorage(pStorage)
11{
12 str_copy(dst&: m_aDemo, src: pDemo);
13 str_copy(dst&: m_aDst, src: pDst);
14
15 m_StartTick = StartTick;
16 m_EndTick = EndTick;
17
18 // Init the demoeditor
19 m_DemoEditor.Init(pSnapshotDelta: &m_SnapshotDelta, pConsole: nullptr, pStorage);
20}
21
22void CDemoEdit::Run()
23{
24 // Slice the current demo
25 m_Success = m_DemoEditor.Slice(pDemo: m_aDemo, pDst: m_aDst, StartTick: m_StartTick, EndTick: m_EndTick, pfnFilter: nullptr, pUser: nullptr);
26 // We remove the temporary demo file if slicing is successful
27 if(m_Success)
28 m_pStorage->RemoveFile(pFilename: m_aDemo, Type: IStorage::TYPE_SAVE);
29}
30