Prevent temporary demo file from being deleted multiple times

Each time the client disconnected or stopped a demo, it tried to delete the previous temporary replay file, which causes an error message "could not delete file" to be shown in the console.

This is prevented by clearing the current filename of the demo recorder after deleting the file.
This commit is contained in:
Robert Müller 2022-12-30 14:20:42 +01:00
parent f230ad0bdc
commit a3e48bef27
2 changed files with 4 additions and 0 deletions

View file

@ -3978,7 +3978,10 @@ void CClient::DemoRecorder_Stop(int Recorder, bool RemoveFile)
{ {
const char *pFilename = m_aDemoRecorder[Recorder].GetCurrentFilename(); const char *pFilename = m_aDemoRecorder[Recorder].GetCurrentFilename();
if(pFilename[0] != '\0') if(pFilename[0] != '\0')
{
Storage()->RemoveFile(pFilename, IStorage::TYPE_SAVE); Storage()->RemoveFile(pFilename, IStorage::TYPE_SAVE);
m_aDemoRecorder[Recorder].ClearCurrentFilename();
}
} }
} }

View file

@ -49,6 +49,7 @@ public:
bool IsRecording() const override { return m_File != nullptr; } bool IsRecording() const override { return m_File != nullptr; }
char *GetCurrentFilename() override { return m_aCurrentFilename; } char *GetCurrentFilename() override { return m_aCurrentFilename; }
void ClearCurrentFilename() { m_aCurrentFilename[0] = '\0'; }
int Length() const override { return (m_LastTickMarker - m_FirstTick) / SERVER_TICK_SPEED; } int Length() const override { return (m_LastTickMarker - m_FirstTick) / SERVER_TICK_SPEED; }
}; };