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