1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-02-02 19:56:13 +01:00

Prevent import of tiles outsized of map boundaries

This commit is contained in:
duncanspumpkin
2021-11-21 19:02:56 +00:00
committed by Gymnasiast
parent 0e57643a68
commit d31f658368
2 changed files with 4 additions and 2 deletions

View File

@@ -1540,12 +1540,13 @@ namespace RCT1
RCT1_MAX_MAP_SIZE, _s4.tile_elements, std::size(_s4.tile_elements));
std::vector<TileElement> tileElements;
const auto maxSize = std::min<uint16_t>(RCT1_MAX_MAP_SIZE, _s4.map_size);
for (TileCoordsXY coords = { 0, 0 }; coords.y < MAXIMUM_MAP_SIZE_TECHNICAL; coords.y++)
{
for (coords.x = 0; coords.x < MAXIMUM_MAP_SIZE_TECHNICAL; coords.x++)
{
auto tileAdded = false;
if (coords.x < RCT1_MAX_MAP_SIZE && coords.y < RCT1_MAX_MAP_SIZE)
if (coords.x < maxSize && coords.y < maxSize)
{
// This is the equivalent of map_get_first_element_at(x, y), but on S4 data.
RCT12TileElement* srcElement = tilePointerIndex.GetFirstElementAt(coords);

View File

@@ -1091,6 +1091,7 @@ public:
std::vector<TileElement> tileElements;
bool nextElementInvisible = false;
bool restOfTileInvisible = false;
const auto maxSize = std::min(RCT2_MAXIMUM_MAP_SIZE_TECHNICAL, _s6.map_size);
for (TileCoordsXY coords = { 0, 0 }; coords.y < MAXIMUM_MAP_SIZE_TECHNICAL; coords.y++)
{
for (coords.x = 0; coords.x < MAXIMUM_MAP_SIZE_TECHNICAL; coords.x++)
@@ -1099,7 +1100,7 @@ public:
restOfTileInvisible = false;
auto tileAdded = false;
if (coords.x < RCT2_MAXIMUM_MAP_SIZE_TECHNICAL && coords.y < RCT2_MAXIMUM_MAP_SIZE_TECHNICAL)
if (coords.x < maxSize && coords.y < maxSize)
{
const auto* srcElement = tilePointerIndex.GetFirstElementAt(coords);
if (srcElement != nullptr)