mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
handle invalid filename for save_replay
This commit is contained in:
parent
8d2de4b8c2
commit
268b79cb61
|
@ -3466,9 +3466,6 @@ void CClient::SaveReplay(const int Length, const char *pFilename)
|
|||
}
|
||||
else
|
||||
{
|
||||
// First we stop the recorder to slice correctly the demo after
|
||||
DemoRecorder(RECORDER_REPLAYS)->Stop(IDemoRecorder::EStopMode::KEEP_FILE);
|
||||
|
||||
char aFilename[IO_MAX_PATH_LENGTH];
|
||||
if(pFilename[0] == '\0')
|
||||
{
|
||||
|
@ -3479,8 +3476,19 @@ void CClient::SaveReplay(const int Length, const char *pFilename)
|
|||
else
|
||||
{
|
||||
str_format(aFilename, sizeof(aFilename), "demos/replays/%s.demo", pFilename);
|
||||
IOHANDLE Handle = m_pStorage->OpenFile(aFilename, IOFLAG_WRITE, IStorage::TYPE_SAVE);
|
||||
if(!Handle)
|
||||
{
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "replay", "ERROR: invalid filename. Try a different one!");
|
||||
return;
|
||||
}
|
||||
io_close(Handle);
|
||||
m_pStorage->RemoveFile(aFilename, IStorage::TYPE_SAVE);
|
||||
}
|
||||
|
||||
// Stop the recorder to correctly slice the demo after
|
||||
DemoRecorder(RECORDER_REPLAYS)->Stop(IDemoRecorder::EStopMode::KEEP_FILE);
|
||||
|
||||
// Slice the demo to get only the last cl_replay_length seconds
|
||||
const char *pSrc = m_aDemoRecorder[RECORDER_REPLAYS].CurrentFilename();
|
||||
const int EndTick = GameTick(g_Config.m_ClDummy);
|
||||
|
|
Loading…
Reference in a new issue