Refactor tile access to be continuous when iterating

This commit is contained in:
ζeh Matt 2021-12-30 14:03:32 -08:00 committed by GitHub
parent 678dd0f69f
commit 2329d3d681
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 13 deletions

View File

@ -951,9 +951,9 @@ namespace OpenRCT2
void UpdateTrackElementsRideType()
{
for (int32_t x = 0; x < MAXIMUM_MAP_SIZE_TECHNICAL; x++)
for (int32_t y = 0; y < MAXIMUM_MAP_SIZE_TECHNICAL; y++)
{
for (int32_t y = 0; y < MAXIMUM_MAP_SIZE_TECHNICAL; y++)
for (int32_t x = 0; x < MAXIMUM_MAP_SIZE_TECHNICAL; x++)
{
TileElement* tileElement = map_get_first_element_at(TileCoordsXY{ x, y });
if (tileElement == nullptr)

View File

@ -5582,9 +5582,9 @@ void determine_ride_entrance_and_exit_locations()
// Search the map to find it. Skip the outer ring of invisible tiles.
bool alreadyFoundEntrance = false;
bool alreadyFoundExit = false;
for (int32_t x = 1; x < MAXIMUM_MAP_SIZE_TECHNICAL - 1; x++)
for (int32_t y = 1; y < MAXIMUM_MAP_SIZE_TECHNICAL - 1; y++)
{
for (int32_t y = 1; y < MAXIMUM_MAP_SIZE_TECHNICAL - 1; y++)
for (int32_t x = 1; x < MAXIMUM_MAP_SIZE_TECHNICAL - 1; x++)
{
TileElement* tileElement = map_get_first_element_at(TileCoordsXY{ x, y });

View File

@ -298,17 +298,17 @@ int32_t tile_element_iterator_next(tile_element_iterator* it)
return 1;
}
if (it->x < (MAXIMUM_MAP_SIZE_TECHNICAL - 1))
if (it->y < (MAXIMUM_MAP_SIZE_TECHNICAL - 1))
{
it->x++;
it->y++;
it->element = map_get_first_element_at(TileCoordsXY{ it->x, it->y });
return 1;
}
if (it->y < (MAXIMUM_MAP_SIZE_TECHNICAL - 1))
if (it->x < (MAXIMUM_MAP_SIZE_TECHNICAL - 1))
{
it->x = 0;
it->y++;
it->y = 0;
it->x++;
it->element = map_get_first_element_at(TileCoordsXY{ it->x, it->y });
return 1;
}
@ -462,9 +462,9 @@ void map_count_remaining_land_rights()
gLandRemainingOwnershipSales = 0;
gLandRemainingConstructionSales = 0;
for (int32_t x = 0; x < MAXIMUM_MAP_SIZE_TECHNICAL; x++)
for (int32_t y = 0; y < MAXIMUM_MAP_SIZE_TECHNICAL; y++)
{
for (int32_t y = 0; y < MAXIMUM_MAP_SIZE_TECHNICAL; y++)
for (int32_t x = 0; x < MAXIMUM_MAP_SIZE_TECHNICAL; x++)
{
auto* surfaceElement = map_get_surface_element_at(TileCoordsXY{ x, y }.ToCoordsXY());
// Surface elements are sometimes hacked out to save some space for other map elements

View File

@ -116,9 +116,9 @@ template<typename T> bool CompareLists(const CoordsXY& pos)
template<typename T> void CheckMapTiles()
{
for (int x = 0; x < MAXIMUM_MAP_SIZE_TECHNICAL; ++x)
for (int y = 0; y < MAXIMUM_MAP_SIZE_TECHNICAL; ++y)
{
for (int y = 0; y < MAXIMUM_MAP_SIZE_TECHNICAL; ++y)
for (int x = 0; x < MAXIMUM_MAP_SIZE_TECHNICAL; ++x)
{
auto pos = TileCoordsXY(x, y).ToCoordsXY();