From 8bd80c8ff9e76222a64aa4abe53c49de8ce60454 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Fri, 19 Jan 2024 22:37:16 +0100 Subject: [PATCH] Render selection grid for Map ownership on the water --- src/openrct2-ui/windows/Map.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/openrct2-ui/windows/Map.cpp b/src/openrct2-ui/windows/Map.cpp index a6d2d3027a78..0f357e41666f 100644 --- a/src/openrct2-ui/windows/Map.cpp +++ b/src/openrct2-ui/windows/Map.cpp @@ -430,12 +430,16 @@ class MapWindow final : public Window { MapInvalidateSelectionRect(); gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; - auto mapCoords = ScreenGetMapXY(screenCoords, nullptr); - if (!mapCoords.has_value()) + + auto info = GetMapCoordinatesFromPos( + screenCoords, EnumsToFlags(ViewportInteractionItem::Terrain, ViewportInteractionItem::Water)); + if (info.SpriteType == ViewportInteractionItem::None) return; + + auto mapCoords = info.Loc; gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; - gMapSelectType = MAP_SELECT_TYPE_FULL; + gMapSelectType = MAP_SELECT_TYPE_FULL_LAND_RIGHTS; int32_t landRightsToolSize = _landRightsToolSize; if (landRightsToolSize == 0) @@ -443,11 +447,12 @@ class MapWindow final : public Window int32_t size = (landRightsToolSize * 32) - 32; int32_t radius = (landRightsToolSize * 16) - 16; - mapCoords->x = (mapCoords->x - radius) & 0xFFE0; - mapCoords->y = (mapCoords->y - radius) & 0xFFE0; - gMapSelectPositionA = *mapCoords; - gMapSelectPositionB.x = mapCoords->x + size; - gMapSelectPositionB.y = mapCoords->y + size; + mapCoords.x -= radius; + mapCoords.y -= radius; + mapCoords = mapCoords.ToTileStart(); + gMapSelectPositionA = mapCoords; + gMapSelectPositionB.x = mapCoords.x + size; + gMapSelectPositionB.y = mapCoords.y + size; MapInvalidateSelectionRect(); } @@ -687,7 +692,7 @@ class MapWindow final : public Window MapInvalidateSelectionRect(); gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; - gMapSelectType = MAP_SELECT_TYPE_FULL; + gMapSelectType = MAP_SELECT_TYPE_FULL_LAND_RIGHTS; gMapSelectPositionA = mapCoords; gMapSelectPositionB = mapCoords + CoordsXY{ size, size }; MapInvalidateSelectionRect();