From 9ec25e85cb4ff8303076ac8114e9e2fd7950a5e3 Mon Sep 17 00:00:00 2001 From: Tulio Leao Date: Fri, 27 Dec 2019 08:36:47 -0300 Subject: [PATCH] Coords for map_get_tile* (#10440) * Make Map::map_get_tile_side() use CoordsXY * Make Map::map_get_tile_quadrant() use CoordsXY --- src/openrct2/interface/Viewport.cpp | 8 ++++---- src/openrct2/world/Map.cpp | 12 ++++++------ src/openrct2/world/Map.h | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/openrct2/interface/Viewport.cpp b/src/openrct2/interface/Viewport.cpp index 2fe75d32bf..5d3c6a9982 100644 --- a/src/openrct2/interface/Viewport.cpp +++ b/src/openrct2/interface/Viewport.cpp @@ -1803,7 +1803,7 @@ std::optional screen_get_map_xy_quadrant(ScreenCoordsXY screenCoords, if (!mapCoords) return std::nullopt; - *quadrant = map_get_tile_quadrant(mapCoords->x, mapCoords->y); + *quadrant = map_get_tile_quadrant(*mapCoords); return mapCoords->ToTileStart(); } @@ -1817,7 +1817,7 @@ std::optional screen_get_map_xy_quadrant_with_z(ScreenCoordsXY screenC if (!mapCoords) return std::nullopt; - *quadrant = map_get_tile_quadrant(mapCoords->x, mapCoords->y); + *quadrant = map_get_tile_quadrant(*mapCoords); return mapCoords->ToTileStart(); } @@ -1831,7 +1831,7 @@ std::optional screen_get_map_xy_side(ScreenCoordsXY screenCoords, uint if (!mapCoords) return std::nullopt; - *side = map_get_tile_side(mapCoords->x, mapCoords->y); + *side = map_get_tile_side(*mapCoords); return mapCoords->ToTileStart(); } @@ -1845,7 +1845,7 @@ std::optional screen_get_map_xy_side_with_z(ScreenCoordsXY screenCoord if (!mapCoords) return std::nullopt; - *side = map_get_tile_side(mapCoords->x, mapCoords->y); + *side = map_get_tile_side(*mapCoords); return mapCoords->ToTileStart(); } diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index e965c92614..7aed934a0a 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -2043,17 +2043,17 @@ void map_invalidate_region(const CoordsXY& mins, const CoordsXY& maxs) } } -int32_t map_get_tile_side(int32_t mapX, int32_t mapY) +int32_t map_get_tile_side(const CoordsXY& mapPos) { - int32_t subMapX = mapX & (32 - 1); - int32_t subMapY = mapY & (32 - 1); + int32_t subMapX = mapPos.x & (32 - 1); + int32_t subMapY = mapPos.y & (32 - 1); return (subMapX < subMapY) ? ((subMapX + subMapY) < 32 ? 0 : 1) : ((subMapX + subMapY) < 32 ? 3 : 2); } -int32_t map_get_tile_quadrant(int32_t mapX, int32_t mapY) +int32_t map_get_tile_quadrant(const CoordsXY& mapPos) { - int32_t subMapX = mapX & (32 - 1); - int32_t subMapY = mapY & (32 - 1); + int32_t subMapX = mapPos.x & (32 - 1); + int32_t subMapY = mapPos.y & (32 - 1); return (subMapX > 16) ? (subMapY < 16 ? 1 : 0) : (subMapY < 16 ? 2 : 3); } diff --git a/src/openrct2/world/Map.h b/src/openrct2/world/Map.h index 2914699924..112ca7dde6 100644 --- a/src/openrct2/world/Map.h +++ b/src/openrct2/world/Map.h @@ -214,8 +214,8 @@ void map_invalidate_tile_full(int32_t x, int32_t y); void map_invalidate_element(int32_t x, int32_t y, TileElement* tileElement); void map_invalidate_region(const CoordsXY& mins, const CoordsXY& maxs); -int32_t map_get_tile_side(int32_t mapX, int32_t mapY); -int32_t map_get_tile_quadrant(int32_t mapX, int32_t mapY); +int32_t map_get_tile_side(const CoordsXY& mapPos); +int32_t map_get_tile_quadrant(const CoordsXY& mapPos); int32_t map_get_corner_height(int32_t z, int32_t slope, int32_t direction); int32_t tile_element_get_corner_height(const SurfaceElement* surfaceElement, int32_t direction);