mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
Fix small bug with demos that don't include a map
This commit is contained in:
parent
71857fdb80
commit
65ec25a8a1
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue