diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index a9a5e29b1..fe733251b 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -3420,10 +3420,12 @@ const char *CClient::DemoPlayer_Play(const char *pFilename, int StorageType) // load map Crc = m_DemoPlayer.GetMapInfo()->m_Crc; SHA256_DIGEST Sha = m_DemoPlayer.GetMapInfo()->m_Sha256; - pError = LoadMapSearch(m_DemoPlayer.Info()->m_Header.m_aMapName, &Sha, Crc); + pError = LoadMapSearch(m_DemoPlayer.Info()->m_Header.m_aMapName, Sha != SHA256_ZEROED ? &Sha : nullptr, Crc); if(pError) { - m_DemoPlayer.ExtractMap(Storage()); + if(!m_DemoPlayer.ExtractMap(Storage())) + return pError; + Sha = m_DemoPlayer.GetMapInfo()->m_Sha256; pError = LoadMapSearch(m_DemoPlayer.Info()->m_Header.m_aMapName, &Sha, Crc); if(pError) diff --git a/src/engine/shared/demo.cpp b/src/engine/shared/demo.cpp index 19aa64357..f345c789a 100644 --- a/src/engine/shared/demo.cpp +++ b/src/engine/shared/demo.cpp @@ -791,10 +791,10 @@ int CDemoPlayer::Load(class IStorage *pStorage, class IConsole *pConsole, const return 0; } -void CDemoPlayer::ExtractMap(class IStorage *pStorage) +bool CDemoPlayer::ExtractMap(class IStorage *pStorage) { if(!m_MapInfo.m_Size) - return; + return false; long CurSeek = io_tell(m_File); @@ -821,11 +821,16 @@ void CDemoPlayer::ExtractMap(class IStorage *pStorage) // save map IOHANDLE MapFile = pStorage->OpenFile(aMapFilename, IOFLAG_WRITE, IStorage::TYPE_SAVE); + if(!MapFile) + return false; + io_write(MapFile, pMapData, m_MapInfo.m_Size); io_close(MapFile); // free data free(pMapData); + + return true; } int CDemoPlayer::NextFrame() diff --git a/src/engine/shared/demo.h b/src/engine/shared/demo.h index dc3b2f502..b6d73b323 100644 --- a/src/engine/shared/demo.h +++ b/src/engine/shared/demo.h @@ -121,7 +121,7 @@ public: void SetListener(IListener *pListener); int Load(class IStorage *pStorage, class IConsole *pConsole, const char *pFilename, int StorageType); - void ExtractMap(class IStorage *pStorage); + bool ExtractMap(class IStorage *pStorage); int Play(); void Pause(); void Unpause();