1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-18 20:43:04 +01:00

try to read objects with bad image tables

This commit is contained in:
Ted John
2016-06-28 21:16:09 +01:00
parent f0844370bb
commit 1b4079536d
5 changed files with 41 additions and 4 deletions

View File

@@ -14,6 +14,7 @@
*****************************************************************************/
#pragma endregion
#include "../core/Console.hpp"
#include "../core/IStream.hpp"
#include "../core/Memory.hpp"
#include "ImageTable.h"
@@ -53,5 +54,16 @@ void ImageTable::Read(IStream * stream)
}
// Read g1 element data
stream->Read(_data, _dataSize);
size_t readBytes = (size_t)stream->TryRead(_data, _dataSize);
// If data is shorter than expected (some custom objects are unfortunately like that)
size_t unreadBytes = _dataSize - readBytes;
if (unreadBytes > 0)
{
void * ptr = (void*)(((uintptr_t)_data) + readBytes);
Memory::Set(ptr, 0, unreadBytes);
Console::Error::WriteFormat("Warning: Image table size shorter than expected.");
Console::Error::WriteLine();
}
}