From e93fa5342a6c447fa0d32492281af9459ceaed24 Mon Sep 17 00:00:00 2001 From: Sjoerd de Bruin Date: Sat, 12 Sep 2026 10:40:52 +0200 Subject: [PATCH] Close #21400: draw staff patrol area selector on the water (#27067) --- distribution/changelog.txt | 1 + src/openrct2-ui/windows/LandRights.cpp | 4 ++-- src/openrct2-ui/windows/PatrolArea.cpp | 16 ++++++++++------ .../paint/tile_element/Paint.Surface.cpp | 5 +++-- src/openrct2/world/MapSelection.h | 2 +- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 3b7fe0a31b..382d9b9e8f 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -1,5 +1,6 @@ 0.5.6 (in development) ------------------------------------------------------------------------ +- Improved: [#21400] The selector for setting staff patrol areas is now drawn on the water as well as on the surface under water. - Fix: [#21320] RCT1 allows more cars per train on some rides than OpenRCT2. - Fix: [#24457] Yellow is always rendered as third remap in Ride window. - Fix: [#26754] Switching window tabs by touch could crash the game on some Linux builds. diff --git a/src/openrct2-ui/windows/LandRights.cpp b/src/openrct2-ui/windows/LandRights.cpp index 04d444ef39..a8907229b7 100644 --- a/src/openrct2-ui/windows/LandRights.cpp +++ b/src/openrct2-ui/windows/LandRights.cpp @@ -485,9 +485,9 @@ namespace OpenRCT2::Ui::Windows state_changed++; } - if (gMapSelectType != MapSelectType::fullLandRights) + if (gMapSelectType != MapSelectType::fullTerrainAndWater) { - gMapSelectType = MapSelectType::fullLandRights; + gMapSelectType = MapSelectType::fullTerrainAndWater; state_changed++; } diff --git a/src/openrct2-ui/windows/PatrolArea.cpp b/src/openrct2-ui/windows/PatrolArea.cpp index e33f873365..d8f62ba95a 100644 --- a/src/openrct2-ui/windows/PatrolArea.cpp +++ b/src/openrct2-ui/windows/PatrolArea.cpp @@ -7,8 +7,6 @@ * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ -#include "../interface/ViewportQuery.h" - #include #include #include @@ -162,7 +160,7 @@ namespace OpenRCT2::Ui::Windows if (!gMapSelectFlags.has(MapSelectFlag::enable)) stateChanged = true; - if (gMapSelectType != MapSelectType::full) + if (gMapSelectType != MapSelectType::fullTerrainAndWater) stateChanged = true; auto toolSize = std::max(1, gLandToolSize); @@ -182,7 +180,7 @@ namespace OpenRCT2::Ui::Windows if (stateChanged) { gMapSelectFlags.set(MapSelectFlag::enable); - gMapSelectType = MapSelectType::full; + gMapSelectType = MapSelectType::fullTerrainAndWater; gMapSelectPositionA = posA; gMapSelectPositionB = posB; } @@ -279,8 +277,14 @@ namespace OpenRCT2::Ui::Windows std::optional GetBestCoordsFromPos(const ScreenCoordsXY& pos) { - auto coords = FootpathGetCoordinatesFromPos(pos, nullptr, nullptr); - return coords.isNull() ? std::nullopt : std::make_optional(coords); + auto info = GetMapCoordinatesFromPos( + pos, + EnumsToFlags( + ViewportInteractionItem::terrain, ViewportInteractionItem::water, ViewportInteractionItem::footpath)); + if (info.interactionType == ViewportInteractionItem::none) + return std::nullopt; + + return info.Loc; } }; diff --git a/src/openrct2/paint/tile_element/Paint.Surface.cpp b/src/openrct2/paint/tile_element/Paint.Surface.cpp index f80f11ad0f..d68914ffc6 100644 --- a/src/openrct2/paint/tile_element/Paint.Surface.cpp +++ b/src/openrct2/paint/tile_element/Paint.Surface.cpp @@ -806,7 +806,8 @@ static std::pair SurfaceGetHeightAboveWater( std::optional GetPatrolAreaTileColour(const CoordsXY& pos) { - bool selected = gMapSelectFlags.has(MapSelectFlag::enable) && gMapSelectType == MapSelectType::full + bool selected = gMapSelectFlags.has(MapSelectFlag::enable) + && (gMapSelectType == MapSelectType::full || gMapSelectType == MapSelectType::fullTerrainAndWater) && pos.x >= gMapSelectPositionA.x && pos.x <= gMapSelectPositionB.x && pos.y >= gMapSelectPositionA.y && pos.y <= gMapSelectPositionB.y; @@ -1131,7 +1132,7 @@ void PaintSurface(PaintSession& session, uint8_t direction, uint16_t height, con const auto image_id = ImageId(SPR_TERRAIN_SELECTION_CORNER + Byte97B444[surfaceShape], fpId); PaintAttachToPreviousPS(session, image_id, 0, 0); } - else if (mapSelectionType == MapSelectType::fullLandRights) + else if (mapSelectionType == MapSelectType::fullTerrainAndWater) { auto [waterHeight, waterSurfaceShape] = SurfaceGetHeightAboveWater(tileElement, height, surfaceShape); diff --git a/src/openrct2/world/MapSelection.h b/src/openrct2/world/MapSelection.h index e053c2e6ae..04a65674a4 100644 --- a/src/openrct2/world/MapSelection.h +++ b/src/openrct2/world/MapSelection.h @@ -35,7 +35,7 @@ enum class MapSelectType : uint8_t corner3, full, fullWater, - fullLandRights, + fullTerrainAndWater, quarter0, quarter1, quarter2,