mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Merge #4330
4330: Try crc for maps if sha256 isn't available (fixes #4327) r=heinrich5991 a=def- Happens with demos cut from KoG <!-- What is the motivation for the changes of this pull request --> ## Checklist - [x] Tested the change ingame - [ ] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [ ] Written a unit test if it works standalone, system.c especially - [ ] Considered possible null pointers and out of bounds array indexing - [ ] Changed no physics that affect existing maps - [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) Co-authored-by: def <dennis@felsin9.de>
This commit is contained in:
commit
0e64a6ccc9
|
@ -841,10 +841,10 @@ int CDemoPlayer::Load(class IStorage *pStorage, class IConsole *pConsole, const
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool CDemoPlayer::ExtractMap(class IStorage *pStorage)
|
||||
unsigned char *CDemoPlayer::GetMapData(class IStorage *pStorage)
|
||||
{
|
||||
if(!m_MapInfo.m_Size)
|
||||
return false;
|
||||
return 0;
|
||||
|
||||
long CurSeek = io_tell(m_File);
|
||||
|
||||
|
@ -853,6 +853,14 @@ bool CDemoPlayer::ExtractMap(class IStorage *pStorage)
|
|||
unsigned char *pMapData = (unsigned char *)malloc(m_MapInfo.m_Size);
|
||||
io_read(m_File, pMapData, m_MapInfo.m_Size);
|
||||
io_seek(m_File, CurSeek, IOSEEK_START);
|
||||
return pMapData;
|
||||
}
|
||||
|
||||
bool CDemoPlayer::ExtractMap(class IStorage *pStorage)
|
||||
{
|
||||
unsigned char *pMapData = GetMapData(pStorage);
|
||||
if(!pMapData)
|
||||
return false;
|
||||
|
||||
// handle sha256
|
||||
SHA256_DIGEST Sha256 = SHA256_ZEROED;
|
||||
|
@ -1170,7 +1178,11 @@ void CDemoEditor::Slice(const char *pDemo, const char *pDst, int StartTick, int
|
|||
Sha256 = pMapInfo->m_Sha256;
|
||||
}
|
||||
|
||||
if(m_pDemoRecorder->Start(m_pStorage, m_pConsole, pDst, m_pNetVersion, pMapInfo->m_aName, &Sha256, pMapInfo->m_Crc, "client", pMapInfo->m_Size, NULL, NULL, pfnFilter, pUser) == -1)
|
||||
unsigned char *pMapData = m_pDemoPlayer->GetMapData(m_pStorage);
|
||||
const int Result = m_pDemoRecorder->Start(m_pStorage, m_pConsole, pDst, m_pNetVersion, pMapInfo->m_aName, &Sha256, pMapInfo->m_Crc, "client", pMapInfo->m_Size, pMapData, NULL, pfnFilter, pUser) == -1;
|
||||
if(pMapData)
|
||||
free(pMapData);
|
||||
if(Result != 0)
|
||||
return;
|
||||
|
||||
m_pDemoPlayer->Play();
|
||||
|
|
|
@ -133,6 +133,7 @@ public:
|
|||
void SetListener(IListener *pListener);
|
||||
|
||||
int Load(class IStorage *pStorage, class IConsole *pConsole, const char *pFilename, int StorageType);
|
||||
unsigned char *GetMapData(class IStorage *pStorage);
|
||||
bool ExtractMap(class IStorage *pStorage);
|
||||
int Play();
|
||||
void Pause();
|
||||
|
|
Loading…
Reference in a new issue