diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index 81b3a972bf..78acbf40fc 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -3489,7 +3489,7 @@ void ride_construction_toolupdate_construct(int32_t screenX, int32_t screenY) z = _trackPlaceZ; if (z == 0) - z = map_get_highest_z(x >> 5, y >> 5); + z = map_get_highest_z({ x, y }); gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_CONSTRUCT; gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_ARROW; @@ -3531,7 +3531,7 @@ void ride_construction_toolupdate_construct(int32_t screenX, int32_t screenY) { if (selectedTile.x < (256 * 32) && selectedTile.y < (256 * 32)) { - z = map_get_highest_z(selectedTile.x / 32, selectedTile.y / 32); + z = map_get_highest_z(selectedTile); if (z > highestZ) highestZ = z; } @@ -3755,7 +3755,7 @@ void ride_construction_tooldown_construct(int32_t screenX, int32_t screenY) if (selectedTile.x >= (256 * 32) || selectedTile.y >= (256 * 32)) continue; - z = map_get_highest_z(selectedTile.x / 32, selectedTile.y / 32); + z = map_get_highest_z(selectedTile); if (z > highestZ) highestZ = z; } @@ -3769,7 +3769,7 @@ void ride_construction_tooldown_construct(int32_t screenX, int32_t screenY) z = _trackPlaceZ; if (z == 0) - z = map_get_highest_z(x >> 5, y >> 5); + z = map_get_highest_z({ x, y }); tool_cancel(); diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index ca983f49ca..8de2e83be8 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -1723,11 +1723,11 @@ static void clear_elements_at(const CoordsXY& loc) clear_element_at(loc, &tileElement); } -int32_t map_get_highest_z(int32_t tileX, int32_t tileY) +int32_t map_get_highest_z(const CoordsXY& loc) { uint32_t z; - auto surfaceElement = map_get_surface_element_at(tileX, tileY); + auto surfaceElement = map_get_surface_element_at(loc); if (surfaceElement == nullptr) return -1; diff --git a/src/openrct2/world/Map.h b/src/openrct2/world/Map.h index ae8724084f..896043c7ce 100644 --- a/src/openrct2/world/Map.h +++ b/src/openrct2/world/Map.h @@ -200,7 +200,7 @@ void tile_element_iterator_restart_for_tile(tile_element_iterator* it); void wall_remove_intersecting_walls(int32_t x, int32_t y, int32_t z0, int32_t z1, int32_t direction); void map_update_tiles(); -int32_t map_get_highest_z(int32_t tileX, int32_t tileY); +int32_t map_get_highest_z(const CoordsXY& loc); bool tile_element_wants_path_connection_towards(TileCoordsXYZD coords, const TileElement* const elementToBeRemoved);