1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-24 00:03:11 +01:00

Merge pull request #8416 from IntelOrca/required-images-extra-checks

Add extra checks in required image code
This commit is contained in:
Ted John
2018-12-10 22:42:43 +00:00
committed by GitHub

View File

@@ -55,7 +55,7 @@ namespace ObjectJsonHelpers
{
auto length = g1_calculate_data_size(&orig);
g1 = orig;
g1.offset = (uint8_t*)std::malloc(length);
g1.offset = new uint8_t[length];
std::memcpy(g1.offset, orig.offset, length);
g1.flags &= ~G1_FLAG_HAS_ZOOM_SPRITE;
}
@@ -67,9 +67,9 @@ namespace ObjectJsonHelpers
{
auto length = g1_calculate_data_size(orig);
g1 = *orig;
g1.offset = (uint8_t*)std::malloc(length);
g1.offset = new uint8_t[length];
std::memcpy(g1.offset, orig->offset, length);
if (g1.flags & G1_FLAG_HAS_ZOOM_SPRITE)
if ((g1.flags & G1_FLAG_HAS_ZOOM_SPRITE) && g1.zoomed_offset != 0)
{
// Fetch image for next zoom level
next_zoom = std::make_unique<RequiredImage>((uint32_t)(idx - g1.zoomed_offset), getter);
@@ -84,7 +84,7 @@ namespace ObjectJsonHelpers
~RequiredImage()
{
std::free(g1.offset);
delete[] g1.offset;
}
};