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, CSnapshotDelta *pSnapshotDelta, CSnapshotDelta *pSnapshotDeltaSixup, IStorage *pStorage, const char *pDemo, const char *pDst, int StartTick, int EndTick) :
9 m_SnapshotDelta(*pSnapshotDelta),
10 m_SnapshotDeltaSixup(*pSnapshotDeltaSixup),
11 m_pStorage(pStorage)
12{
13 str_copy(dst&: m_aDemo, src: pDemo);
14 str_copy(dst&: m_aDst, src: pDst);
15
16 m_StartTick = StartTick;
17 m_EndTick = EndTick;
18
19 // Init the demoeditor
20 m_DemoEditor.Init(pSnapshotDelta: &m_SnapshotDelta, pSnapshotDeltaSixup: &m_SnapshotDeltaSixup, pConsole: nullptr, pStorage);
21}
22
23void CDemoEdit::Run()
24{
25 // Slice the current demo
26 m_Success = m_DemoEditor.Slice(pDemo: m_aDemo, pDst: m_aDst, StartTick: m_StartTick, EndTick: m_EndTick, pfnFilter: nullptr, pUser: nullptr);
27 // We remove the temporary demo file if slicing is successful
28 if(m_Success)
29 m_pStorage->RemoveFile(pFilename: m_aDemo, Type: IStorage::TYPE_SAVE);
30}
31