The demoeditors are now initialised in the constructor of the job

This commit is contained in:
Corantin H 2019-05-26 21:06:43 +02:00
parent cbcb8d4830
commit 7c79b48da5
2 changed files with 9 additions and 12 deletions

View file

@ -3325,12 +3325,8 @@ void CClient::SaveReplay()
const int EndTick = GameTick(); const int EndTick = GameTick();
const int StartTick = EndTick - g_Config.m_ClReplayLength * GameTickSpeed(); const int StartTick = EndTick - g_Config.m_ClReplayLength * GameTickSpeed();
// Create a DemoEditor to do the job
CDemoEditor *DemoEditor = new CDemoEditor();
DemoEditor->Init(m_pGameClient->NetVersion(), &m_SnapshotDelta, m_pConsole, m_pStorage);
// Create a job to do this slicing in background because it can be a bit long depending on the file size // Create a job to do this slicing in background because it can be a bit long depending on the file size
std::shared_ptr<CDemoEdit> pDemoEditTask = std::make_shared<CDemoEdit>(this, m_pConsole, DemoEditor, pSrc, aFilename, StartTick, EndTick); std::shared_ptr<CDemoEdit> pDemoEditTask = std::make_shared<CDemoEdit>(this, &m_SnapshotDelta, m_pConsole, pSrc, aFilename, StartTick, EndTick);
Engine()->AddJob(pDemoEditTask); Engine()->AddJob(pDemoEditTask);
} }
} }
@ -3995,25 +3991,26 @@ void CClient::GetSmoothTick(int *pSmoothTick, float *pSmoothIntraTick, float Mix
CDemoEdit::~CDemoEdit() CDemoEdit::~CDemoEdit()
{ {
delete m_pDemoEditor;
} }
CDemoEdit::CDemoEdit(CClient *pClient, IConsole *pConsole, CDemoEditor *pDemoEditor, const char *pDemo, const char *pDst, int StartTick, int EndTick) : CDemoEdit::CDemoEdit(CClient *pClient, CSnapshotDelta *pSnapshotDelta, IConsole *pConsole, const char *pDemo, const char *pDst, int StartTick, int EndTick) :
m_pClient(pClient), m_pClient(pClient),
m_pConsole(pConsole), m_pConsole(pConsole)
m_pDemoEditor(pDemoEditor)
{ {
str_copy(m_pDemo, pDemo, sizeof(m_pDemo)); str_copy(m_pDemo, pDemo, sizeof(m_pDemo));
str_copy(m_pDst, pDst, sizeof(m_pDst)); str_copy(m_pDst, pDst, sizeof(m_pDst));
m_StartTick = StartTick; m_StartTick = StartTick;
m_EndTick = EndTick; m_EndTick = EndTick;
// Init the demoeditor
m_DemoEditor.Init(pClient->GameClient()->NetVersion(), pSnapshotDelta, pConsole, pClient->Storage());
} }
void CDemoEdit::Run() void CDemoEdit::Run()
{ {
// Slice the actual demo // Slice the actual demo
m_pDemoEditor->Slice(m_pDemo, m_pDst, m_StartTick, m_EndTick, NULL, 0); m_DemoEditor.Slice(m_pDemo, m_pDst, m_StartTick, m_EndTick, NULL, 0);
// Notify the player via console and a hud notification // Notify the player via console and a hud notification
char aBuf[256]; char aBuf[256];

View file

@ -429,14 +429,14 @@ class CDemoEdit : public IJob
{ {
CClient *m_pClient; CClient *m_pClient;
IConsole *m_pConsole; IConsole *m_pConsole;
CDemoEditor *m_pDemoEditor; CDemoEditor m_DemoEditor;
char m_pDemo[256]; char m_pDemo[256];
char m_pDst[256]; char m_pDst[256];
int m_StartTick; int m_StartTick;
int m_EndTick; int m_EndTick;
public: public:
CDemoEdit(CClient *pClient, IConsole *pConsole, CDemoEditor *pDemoEditor, const char *pDemo, const char *pDst, int StartTick, int EndTick); CDemoEdit(CClient *pClient, CSnapshotDelta *pSnapshotDelta, IConsole *pConsole, const char *pDemo, const char *pDst, int StartTick, int EndTick);
~CDemoEdit(); ~CDemoEdit();
void Run(); void Run();
}; };