From 7a30169c283c182dfdd83dac13673213af65f249 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Wed, 20 Oct 2021 21:47:56 +0300 Subject: [PATCH 1/7] Refactor out construction clearance into a new compilation unit --- src/openrct2/actions/FootpathPlaceAction.cpp | 1 + .../actions/FootpathPlaceFromTrackAction.cpp | 1 + src/openrct2/actions/LandSetHeightAction.cpp | 1 + .../actions/LargeSceneryPlaceAction.cpp | 1 + src/openrct2/actions/MazePlaceTrackAction.cpp | 1 + src/openrct2/actions/MazeSetTrackAction.cpp | 1 + .../actions/PlaceParkEntranceAction.cpp | 1 + .../actions/RideEntranceExitPlaceAction.cpp | 1 + .../actions/SmallSceneryPlaceAction.cpp | 1 + src/openrct2/actions/TrackPlaceAction.cpp | 1 + src/openrct2/actions/WallPlaceAction.cpp | 1 + src/openrct2/actions/WaterSetHeightAction.cpp | 1 + src/openrct2/libopenrct2.vcxproj | 2 + src/openrct2/peep/Peep.cpp | 1 + src/openrct2/world/ConstructionClearance.cpp | 359 ++++++++++++++++++ src/openrct2/world/ConstructionClearance.h | 25 ++ src/openrct2/world/Map.cpp | 286 -------------- src/openrct2/world/Map.h | 16 - src/openrct2/world/SmallScenery.cpp | 52 --- 19 files changed, 399 insertions(+), 354 deletions(-) create mode 100644 src/openrct2/world/ConstructionClearance.cpp create mode 100644 src/openrct2/world/ConstructionClearance.h diff --git a/src/openrct2/actions/FootpathPlaceAction.cpp b/src/openrct2/actions/FootpathPlaceAction.cpp index df93c33327..b83e5062f7 100644 --- a/src/openrct2/actions/FootpathPlaceAction.cpp +++ b/src/openrct2/actions/FootpathPlaceAction.cpp @@ -15,6 +15,7 @@ #include "../interface/Window.h" #include "../localisation/StringIds.h" #include "../management/Finance.h" +#include "../world/ConstructionClearance.h" #include "../world/Footpath.h" #include "../world/Location.hpp" #include "../world/Park.h" diff --git a/src/openrct2/actions/FootpathPlaceFromTrackAction.cpp b/src/openrct2/actions/FootpathPlaceFromTrackAction.cpp index 80a67d0ddb..295e05e166 100644 --- a/src/openrct2/actions/FootpathPlaceFromTrackAction.cpp +++ b/src/openrct2/actions/FootpathPlaceFromTrackAction.cpp @@ -15,6 +15,7 @@ #include "../interface/Window.h" #include "../localisation/StringIds.h" #include "../management/Finance.h" +#include "../world/ConstructionClearance.h" #include "../world/Footpath.h" #include "../world/Location.hpp" #include "../world/Park.h" diff --git a/src/openrct2/actions/LandSetHeightAction.cpp b/src/openrct2/actions/LandSetHeightAction.cpp index 02c6c35b02..aa43b243c3 100644 --- a/src/openrct2/actions/LandSetHeightAction.cpp +++ b/src/openrct2/actions/LandSetHeightAction.cpp @@ -17,6 +17,7 @@ #include "../management/Finance.h" #include "../ride/RideData.h" #include "../windows/Intent.h" +#include "../world/ConstructionClearance.h" #include "../world/Park.h" #include "../world/Scenery.h" #include "../world/SmallScenery.h" diff --git a/src/openrct2/actions/LargeSceneryPlaceAction.cpp b/src/openrct2/actions/LargeSceneryPlaceAction.cpp index 51b3801cec..8fc746df28 100644 --- a/src/openrct2/actions/LargeSceneryPlaceAction.cpp +++ b/src/openrct2/actions/LargeSceneryPlaceAction.cpp @@ -14,6 +14,7 @@ #include "../object/ObjectLimits.h" #include "../ride/Ride.h" #include "../world/Banner.h" +#include "../world/ConstructionClearance.h" #include "../world/MapAnimation.h" #include "../world/Surface.h" diff --git a/src/openrct2/actions/MazePlaceTrackAction.cpp b/src/openrct2/actions/MazePlaceTrackAction.cpp index a2e01c3642..ed7da150e9 100644 --- a/src/openrct2/actions/MazePlaceTrackAction.cpp +++ b/src/openrct2/actions/MazePlaceTrackAction.cpp @@ -11,6 +11,7 @@ #include "../management/Finance.h" #include "../ride/RideData.h" #include "../ride/TrackData.h" +#include "../world/ConstructionClearance.h" using namespace OpenRCT2::TrackMetaData; diff --git a/src/openrct2/actions/MazeSetTrackAction.cpp b/src/openrct2/actions/MazeSetTrackAction.cpp index 2d740b4de6..8f47f6eb49 100644 --- a/src/openrct2/actions/MazeSetTrackAction.cpp +++ b/src/openrct2/actions/MazeSetTrackAction.cpp @@ -18,6 +18,7 @@ #include "../ride/RideData.h" #include "../ride/Track.h" #include "../ride/TrackData.h" +#include "../world/ConstructionClearance.h" #include "../world/Footpath.h" #include "../world/Park.h" diff --git a/src/openrct2/actions/PlaceParkEntranceAction.cpp b/src/openrct2/actions/PlaceParkEntranceAction.cpp index 0603218380..93f1eb82ef 100644 --- a/src/openrct2/actions/PlaceParkEntranceAction.cpp +++ b/src/openrct2/actions/PlaceParkEntranceAction.cpp @@ -14,6 +14,7 @@ #include "../core/MemoryStream.h" #include "../localisation/StringIds.h" #include "../management/Finance.h" +#include "../world/ConstructionClearance.h" #include "../world/Entrance.h" #include "../world/Footpath.h" #include "../world/MapAnimation.h" diff --git a/src/openrct2/actions/RideEntranceExitPlaceAction.cpp b/src/openrct2/actions/RideEntranceExitPlaceAction.cpp index df49331e73..c98366ea6a 100644 --- a/src/openrct2/actions/RideEntranceExitPlaceAction.cpp +++ b/src/openrct2/actions/RideEntranceExitPlaceAction.cpp @@ -13,6 +13,7 @@ #include "../management/Finance.h" #include "../ride/Ride.h" #include "../ride/Station.h" +#include "../world/ConstructionClearance.h" #include "../world/MapAnimation.h" RideEntranceExitPlaceAction::RideEntranceExitPlaceAction( diff --git a/src/openrct2/actions/SmallSceneryPlaceAction.cpp b/src/openrct2/actions/SmallSceneryPlaceAction.cpp index e6e536d19b..92a819ec11 100644 --- a/src/openrct2/actions/SmallSceneryPlaceAction.cpp +++ b/src/openrct2/actions/SmallSceneryPlaceAction.cpp @@ -19,6 +19,7 @@ #include "../management/Finance.h" #include "../ride/Ride.h" #include "../ride/TrackDesign.h" +#include "../world/ConstructionClearance.h" #include "../world/MapAnimation.h" #include "../world/Park.h" #include "../world/SmallScenery.h" diff --git a/src/openrct2/actions/TrackPlaceAction.cpp b/src/openrct2/actions/TrackPlaceAction.cpp index ec46e18123..e8ad36a7c0 100644 --- a/src/openrct2/actions/TrackPlaceAction.cpp +++ b/src/openrct2/actions/TrackPlaceAction.cpp @@ -16,6 +16,7 @@ #include "../ride/TrackData.h" #include "../ride/TrackDesign.h" #include "../util/Math.hpp" +#include "../world/ConstructionClearance.h" #include "../world/MapAnimation.h" #include "../world/Surface.h" #include "RideSetSettingAction.h" diff --git a/src/openrct2/actions/WallPlaceAction.cpp b/src/openrct2/actions/WallPlaceAction.cpp index fca2f02f11..5b528b2934 100644 --- a/src/openrct2/actions/WallPlaceAction.cpp +++ b/src/openrct2/actions/WallPlaceAction.cpp @@ -14,6 +14,7 @@ #include "../ride/Track.h" #include "../ride/TrackDesign.h" #include "../world/Banner.h" +#include "../world/ConstructionClearance.h" #include "../world/LargeScenery.h" #include "../world/MapAnimation.h" #include "../world/SmallScenery.h" diff --git a/src/openrct2/actions/WaterSetHeightAction.cpp b/src/openrct2/actions/WaterSetHeightAction.cpp index 523ab0b358..298df52762 100644 --- a/src/openrct2/actions/WaterSetHeightAction.cpp +++ b/src/openrct2/actions/WaterSetHeightAction.cpp @@ -11,6 +11,7 @@ #include "../OpenRCT2.h" #include "../management/Finance.h" +#include "../world/ConstructionClearance.h" #include "../world/Park.h" #include "../world/Surface.h" diff --git a/src/openrct2/libopenrct2.vcxproj b/src/openrct2/libopenrct2.vcxproj index 26dcee802b..cc3067e1e5 100644 --- a/src/openrct2/libopenrct2.vcxproj +++ b/src/openrct2/libopenrct2.vcxproj @@ -466,6 +466,7 @@ + @@ -911,6 +912,7 @@ + diff --git a/src/openrct2/peep/Peep.cpp b/src/openrct2/peep/Peep.cpp index e5b1ba67d8..1a7eb5a5d4 100644 --- a/src/openrct2/peep/Peep.cpp +++ b/src/openrct2/peep/Peep.cpp @@ -36,6 +36,7 @@ #include "../windows/Intent.h" #include "../world/Balloon.h" #include "../world/Climate.h" +#include "../world/ConstructionClearance.h" #include "../world/EntityTweener.h" #include "../world/Entrance.h" #include "../world/Footpath.h" diff --git a/src/openrct2/world/ConstructionClearance.cpp b/src/openrct2/world/ConstructionClearance.cpp new file mode 100644 index 0000000000..430119a991 --- /dev/null +++ b/src/openrct2/world/ConstructionClearance.cpp @@ -0,0 +1,359 @@ +/***************************************************************************** + * Copyright (c) 2014-2021 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#include "ConstructionClearance.h" + +#include "../Game.h" +#include "../openrct2/Cheats.h" +#include "../ride/Ride.h" +#include "../ride/RideData.h" +#include "Map.h" +#include "Park.h" +#include "Scenery.h" +#include "SmallScenery.h" +#include "Surface.h" + +static int32_t map_place_clear_func( + TileElement** tile_element, const CoordsXY& coords, uint8_t flags, money32* price, bool is_scenery) +{ + if ((*tile_element)->GetType() != TILE_ELEMENT_TYPE_SMALL_SCENERY) + return 1; + + if (is_scenery && !(flags & GAME_COMMAND_FLAG_PATH_SCENERY)) + return 1; + + auto* scenery = (*tile_element)->AsSmallScenery()->GetEntry(); + + if (gParkFlags & PARK_FLAGS_FORBID_TREE_REMOVAL) + { + if (scenery != nullptr && scenery->HasFlag(SMALL_SCENERY_FLAG_IS_TREE)) + return 1; + } + + if (!(gParkFlags & PARK_FLAGS_NO_MONEY) && scenery != nullptr) + *price += scenery->removal_price * 10; + + if (flags & GAME_COMMAND_FLAG_GHOST) + return 0; + + if (!(flags & GAME_COMMAND_FLAG_APPLY)) + return 0; + + map_invalidate_tile({ coords, (*tile_element)->GetBaseZ(), (*tile_element)->GetClearanceZ() }); + + tile_element_remove(*tile_element); + + (*tile_element)--; + return 0; +} + +/** + * + * rct2: 0x006E0D6E, 0x006B8D88 + */ +int32_t map_place_scenery_clear_func(TileElement** tile_element, const CoordsXY& coords, uint8_t flags, money32* price) +{ + return map_place_clear_func(tile_element, coords, flags, price, /*is_scenery=*/true); +} + +/** + * + * rct2: 0x006C5A4F, 0x006CDE57, 0x006A6733, 0x0066637E + */ +int32_t map_place_non_scenery_clear_func(TileElement** tile_element, const CoordsXY& coords, uint8_t flags, money32* price) +{ + return map_place_clear_func(tile_element, coords, flags, price, /*is_scenery=*/false); +} + +static bool MapLoc68BABCShouldContinue( + TileElement* tileElement, const CoordsXYRangedZ& pos, CLEAR_FUNC clearFunc, uint8_t flags, money32& price, + uint8_t crossingMode, bool canBuildCrossing) +{ + if (clearFunc != nullptr) + { + if (!clearFunc(&tileElement, pos, flags, &price)) + { + return true; + } + } + + // Crossing mode 1: building track over path + if (crossingMode == 1 && canBuildCrossing && tileElement->GetType() == TILE_ELEMENT_TYPE_PATH + && tileElement->GetBaseZ() == pos.baseZ && !tileElement->AsPath()->IsQueue() && !tileElement->AsPath()->IsSloped()) + { + return true; + } + // Crossing mode 2: building path over track + else if ( + crossingMode == 2 && canBuildCrossing && tileElement->GetType() == TILE_ELEMENT_TYPE_TRACK + && tileElement->GetBaseZ() == pos.baseZ && tileElement->AsTrack()->GetTrackType() == TrackElemType::Flat) + { + auto ride = get_ride(tileElement->AsTrack()->GetRideIndex()); + if (ride != nullptr && ride->GetRideTypeDescriptor().HasFlag(RIDE_TYPE_FLAG_SUPPORTS_LEVEL_CROSSINGS)) + { + return true; + } + } + + return false; +} + +/** + * + * rct2: 0x0068B932 + * ax = x + * cx = y + * dl = zLow + * dh = zHigh + * ebp = clearFunc + * bl = bl + */ +std::unique_ptr MapCanConstructWithClearAt( + const CoordsXYRangedZ& pos, CLEAR_FUNC clearFunc, QuarterTile quarterTile, uint8_t flags, uint8_t crossingMode, bool isTree) +{ + int32_t northZ, eastZ, baseHeight, southZ, westZ, water_height; + northZ = eastZ = baseHeight = southZ = westZ = water_height = 0; + auto res = std::make_unique(); + uint8_t slope = 0; + + res->GroundFlags = ELEMENT_IS_ABOVE_GROUND; + bool canBuildCrossing = false; + if (map_is_edge(pos)) + { + res->Error = GameActions::Status::InvalidParameters; + res->ErrorMessage = STR_OFF_EDGE_OF_MAP; + return res; + } + + if (gCheatsDisableClearanceChecks) + { + return res; + } + + TileElement* tileElement = map_get_first_element_at(pos); + if (tileElement == nullptr) + { + res->Error = GameActions::Status::Unknown; + res->ErrorMessage = STR_NONE; + return res; + } + do + { + if (tileElement->GetType() != TILE_ELEMENT_TYPE_SURFACE) + { + if (pos.baseZ < tileElement->GetClearanceZ() && pos.clearanceZ > tileElement->GetBaseZ() + && !(tileElement->IsGhost())) + { + if (tileElement->GetOccupiedQuadrants() & (quarterTile.GetBaseQuarterOccupied())) + { + if (MapLoc68BABCShouldContinue( + tileElement, pos, clearFunc, flags, res->Cost, crossingMode, canBuildCrossing)) + { + continue; + } + + if (tileElement != nullptr) + { + map_obstruction_set_error_text(tileElement, *res); + res->Error = GameActions::Status::NoClearance; + } + return res; + } + } + continue; + } + water_height = tileElement->AsSurface()->GetWaterHeight(); + if (water_height && water_height > pos.baseZ && tileElement->GetBaseZ() < pos.clearanceZ) + { + res->GroundFlags |= ELEMENT_IS_UNDERWATER; + if (water_height < pos.clearanceZ) + { + bool returnError = true; + if (clearFunc != nullptr) + { + if (!clearFunc(&tileElement, pos, flags, &res->Cost)) + { + returnError = false; + } + } + if (returnError) + { + if (tileElement != nullptr) + { + res->Error = GameActions::Status::NoClearance; + res->ErrorMessage = STR_CANNOT_BUILD_PARTLY_ABOVE_AND_PARTLY_BELOW_WATER; + } + return res; + } + } + } + + if (gParkFlags & PARK_FLAGS_FORBID_HIGH_CONSTRUCTION && !isTree) + { + auto heightFromGround = pos.clearanceZ - tileElement->GetBaseZ(); + + if (heightFromGround > (18 * COORDS_Z_STEP)) + { + res->Error = GameActions::Status::Disallowed; + res->ErrorMessage = STR_LOCAL_AUTHORITY_WONT_ALLOW_CONSTRUCTION_ABOVE_TREE_HEIGHT; + return res; + } + } + + // Only allow building crossings directly on a flat surface tile. + if (tileElement->GetType() == TILE_ELEMENT_TYPE_SURFACE + && (tileElement->AsSurface()->GetSlope()) == TILE_ELEMENT_SLOPE_FLAT && tileElement->GetBaseZ() == pos.baseZ) + { + canBuildCrossing = true; + } + + if (quarterTile.GetZQuarterOccupied() != 0b1111) + { + if (tileElement->GetBaseZ() >= pos.clearanceZ) + { + // loc_68BA81 + res->GroundFlags |= ELEMENT_IS_UNDERGROUND; + res->GroundFlags &= ~ELEMENT_IS_ABOVE_GROUND; + } + else + { + northZ = tileElement->GetBaseZ(); + eastZ = northZ; + southZ = northZ; + westZ = northZ; + slope = tileElement->AsSurface()->GetSlope(); + if (slope & TILE_ELEMENT_SLOPE_N_CORNER_UP) + { + northZ += LAND_HEIGHT_STEP; + if (slope == (TILE_ELEMENT_SLOPE_S_CORNER_DN | TILE_ELEMENT_SLOPE_DOUBLE_HEIGHT)) + northZ += LAND_HEIGHT_STEP; + } + if (slope & TILE_ELEMENT_SLOPE_E_CORNER_UP) + { + eastZ += LAND_HEIGHT_STEP; + if (slope == (TILE_ELEMENT_SLOPE_W_CORNER_DN | TILE_ELEMENT_SLOPE_DOUBLE_HEIGHT)) + eastZ += LAND_HEIGHT_STEP; + } + if (slope & TILE_ELEMENT_SLOPE_S_CORNER_UP) + { + southZ += LAND_HEIGHT_STEP; + if (slope == (TILE_ELEMENT_SLOPE_N_CORNER_DN | TILE_ELEMENT_SLOPE_DOUBLE_HEIGHT)) + southZ += LAND_HEIGHT_STEP; + } + if (slope & TILE_ELEMENT_SLOPE_W_CORNER_UP) + { + westZ += LAND_HEIGHT_STEP; + if (slope == (TILE_ELEMENT_SLOPE_E_CORNER_DN | TILE_ELEMENT_SLOPE_DOUBLE_HEIGHT)) + westZ += LAND_HEIGHT_STEP; + } + baseHeight = pos.baseZ + (4 * COORDS_Z_STEP); + { + auto baseQuarter = quarterTile.GetBaseQuarterOccupied(); + auto zQuarter = quarterTile.GetZQuarterOccupied(); + if ((!(baseQuarter & 0b0001) || ((zQuarter & 0b0001 || pos.baseZ >= northZ) && baseHeight >= northZ)) + && (!(baseQuarter & 0b0010) || ((zQuarter & 0b0010 || pos.baseZ >= eastZ) && baseHeight >= eastZ)) + && (!(baseQuarter & 0b0100) || ((zQuarter & 0b0100 || pos.baseZ >= southZ) && baseHeight >= southZ)) + && (!(baseQuarter & 0b1000) || ((zQuarter & 0b1000 || pos.baseZ >= westZ) && baseHeight >= westZ))) + { + continue; + } + } + + if (MapLoc68BABCShouldContinue(tileElement, pos, clearFunc, flags, res->Cost, crossingMode, canBuildCrossing)) + { + continue; + } + + if (tileElement != nullptr) + { + map_obstruction_set_error_text(tileElement, *res); + res->Error = GameActions::Status::NoClearance; + } + return res; + } + } + } while (!(tileElement++)->IsLastForTile()); + return res; +} + +std::unique_ptr MapCanConstructAt(const CoordsXYRangedZ& pos, QuarterTile bl) +{ + return MapCanConstructWithClearAt(pos, nullptr, bl, 0); +} + +/** + * + * rct2: 0x0068BB18 + */ +void map_obstruction_set_error_text(TileElement* tileElement, GameActions::Result& res) +{ + Ride* ride; + + res.ErrorMessage = STR_OBJECT_IN_THE_WAY; + switch (tileElement->GetType()) + { + case TILE_ELEMENT_TYPE_SURFACE: + res.ErrorMessage = STR_RAISE_OR_LOWER_LAND_FIRST; + break; + case TILE_ELEMENT_TYPE_PATH: + res.ErrorMessage = STR_FOOTPATH_IN_THE_WAY; + break; + case TILE_ELEMENT_TYPE_TRACK: + ride = get_ride(tileElement->AsTrack()->GetRideIndex()); + if (ride != nullptr) + { + res.ErrorMessage = STR_X_IN_THE_WAY; + + Formatter ft(res.ErrorMessageArgs.data()); + ride->FormatNameTo(ft); + } + break; + case TILE_ELEMENT_TYPE_SMALL_SCENERY: + { + auto* sceneryEntry = tileElement->AsSmallScenery()->GetEntry(); + res.ErrorMessage = STR_X_IN_THE_WAY; + auto ft = Formatter(res.ErrorMessageArgs.data()); + rct_string_id stringId = sceneryEntry != nullptr ? sceneryEntry->name : static_cast(STR_EMPTY); + ft.Add(stringId); + break; + } + case TILE_ELEMENT_TYPE_ENTRANCE: + switch (tileElement->AsEntrance()->GetEntranceType()) + { + case ENTRANCE_TYPE_RIDE_ENTRANCE: + res.ErrorMessage = STR_RIDE_ENTRANCE_IN_THE_WAY; + break; + case ENTRANCE_TYPE_RIDE_EXIT: + res.ErrorMessage = STR_RIDE_EXIT_IN_THE_WAY; + break; + case ENTRANCE_TYPE_PARK_ENTRANCE: + res.ErrorMessage = STR_PARK_ENTRANCE_IN_THE_WAY; + break; + } + break; + case TILE_ELEMENT_TYPE_WALL: + { + auto* wallEntry = tileElement->AsWall()->GetEntry(); + res.ErrorMessage = STR_X_IN_THE_WAY; + auto ft = Formatter(res.ErrorMessageArgs.data()); + rct_string_id stringId = wallEntry != nullptr ? wallEntry->name : static_cast(STR_EMPTY); + ft.Add(stringId); + break; + } + case TILE_ELEMENT_TYPE_LARGE_SCENERY: + { + auto* sceneryEntry = tileElement->AsLargeScenery()->GetEntry(); + res.ErrorMessage = STR_X_IN_THE_WAY; + auto ft = Formatter(res.ErrorMessageArgs.data()); + rct_string_id stringId = sceneryEntry != nullptr ? sceneryEntry->name : static_cast(STR_EMPTY); + ft.Add(stringId); + break; + } + } +} diff --git a/src/openrct2/world/ConstructionClearance.h b/src/openrct2/world/ConstructionClearance.h new file mode 100644 index 0000000000..9662e04e1a --- /dev/null +++ b/src/openrct2/world/ConstructionClearance.h @@ -0,0 +1,25 @@ +/***************************************************************************** + * Copyright (c) 2014-2021 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include "../actions/GameActionResult.h" + +using CLEAR_FUNC = int32_t (*)(TileElement** tile_element, const CoordsXY& coords, uint8_t flags, money32* price); + +int32_t map_place_non_scenery_clear_func(TileElement** tile_element, const CoordsXY& coords, uint8_t flags, money32* price); +int32_t map_place_scenery_clear_func(TileElement** tile_element, const CoordsXY& coords, uint8_t flags, money32* price); + +[[nodiscard]] std::unique_ptr MapCanConstructWithClearAt( + const CoordsXYRangedZ& pos, CLEAR_FUNC clearFunc, QuarterTile quarterTile, uint8_t flags, + uint8_t crossingMode = CREATE_CROSSING_MODE_NONE, bool isTree = false); + +[[nodiscard]] std::unique_ptr MapCanConstructAt(const CoordsXYRangedZ& pos, QuarterTile bl); + +void map_obstruction_set_error_text(TileElement* tileElement, GameActions::Result& res); diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 7185a6665f..b50ed72521 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -1264,292 +1264,6 @@ TileElement* tile_element_insert(const CoordsXYZ& loc, int32_t occupiedQuadrants return insertedElement; } -/** - * - * rct2: 0x0068BB18 - */ -void map_obstruction_set_error_text(TileElement* tileElement, GameActions::Result& res) -{ - Ride* ride; - - res.ErrorMessage = STR_OBJECT_IN_THE_WAY; - switch (tileElement->GetType()) - { - case TILE_ELEMENT_TYPE_SURFACE: - res.ErrorMessage = STR_RAISE_OR_LOWER_LAND_FIRST; - break; - case TILE_ELEMENT_TYPE_PATH: - res.ErrorMessage = STR_FOOTPATH_IN_THE_WAY; - break; - case TILE_ELEMENT_TYPE_TRACK: - ride = get_ride(tileElement->AsTrack()->GetRideIndex()); - if (ride != nullptr) - { - res.ErrorMessage = STR_X_IN_THE_WAY; - - Formatter ft(res.ErrorMessageArgs.data()); - ride->FormatNameTo(ft); - } - break; - case TILE_ELEMENT_TYPE_SMALL_SCENERY: - { - auto* sceneryEntry = tileElement->AsSmallScenery()->GetEntry(); - res.ErrorMessage = STR_X_IN_THE_WAY; - auto ft = Formatter(res.ErrorMessageArgs.data()); - rct_string_id stringId = sceneryEntry != nullptr ? sceneryEntry->name : static_cast(STR_EMPTY); - ft.Add(stringId); - break; - } - case TILE_ELEMENT_TYPE_ENTRANCE: - switch (tileElement->AsEntrance()->GetEntranceType()) - { - case ENTRANCE_TYPE_RIDE_ENTRANCE: - res.ErrorMessage = STR_RIDE_ENTRANCE_IN_THE_WAY; - break; - case ENTRANCE_TYPE_RIDE_EXIT: - res.ErrorMessage = STR_RIDE_EXIT_IN_THE_WAY; - break; - case ENTRANCE_TYPE_PARK_ENTRANCE: - res.ErrorMessage = STR_PARK_ENTRANCE_IN_THE_WAY; - break; - } - break; - case TILE_ELEMENT_TYPE_WALL: - { - auto* wallEntry = tileElement->AsWall()->GetEntry(); - res.ErrorMessage = STR_X_IN_THE_WAY; - auto ft = Formatter(res.ErrorMessageArgs.data()); - rct_string_id stringId = wallEntry != nullptr ? wallEntry->name : static_cast(STR_EMPTY); - ft.Add(stringId); - break; - } - case TILE_ELEMENT_TYPE_LARGE_SCENERY: - { - auto* sceneryEntry = tileElement->AsLargeScenery()->GetEntry(); - res.ErrorMessage = STR_X_IN_THE_WAY; - auto ft = Formatter(res.ErrorMessageArgs.data()); - rct_string_id stringId = sceneryEntry != nullptr ? sceneryEntry->name : static_cast(STR_EMPTY); - ft.Add(stringId); - break; - } - } -} - -static bool MapLoc68BABCShouldContinue( - TileElement* tileElement, const CoordsXYRangedZ& pos, CLEAR_FUNC clearFunc, uint8_t flags, money32& price, - uint8_t crossingMode, bool canBuildCrossing) -{ - if (clearFunc != nullptr) - { - if (!clearFunc(&tileElement, pos, flags, &price)) - { - return true; - } - } - - // Crossing mode 1: building track over path - if (crossingMode == 1 && canBuildCrossing && tileElement->GetType() == TILE_ELEMENT_TYPE_PATH - && tileElement->GetBaseZ() == pos.baseZ && !tileElement->AsPath()->IsQueue() && !tileElement->AsPath()->IsSloped()) - { - return true; - } - // Crossing mode 2: building path over track - else if ( - crossingMode == 2 && canBuildCrossing && tileElement->GetType() == TILE_ELEMENT_TYPE_TRACK - && tileElement->GetBaseZ() == pos.baseZ && tileElement->AsTrack()->GetTrackType() == TrackElemType::Flat) - { - auto ride = get_ride(tileElement->AsTrack()->GetRideIndex()); - if (ride != nullptr && ride->GetRideTypeDescriptor().HasFlag(RIDE_TYPE_FLAG_SUPPORTS_LEVEL_CROSSINGS)) - { - return true; - } - } - - return false; -} - -/** - * - * rct2: 0x0068B932 - * ax = x - * cx = y - * dl = zLow - * dh = zHigh - * ebp = clearFunc - * bl = bl - */ -std::unique_ptr MapCanConstructWithClearAt( - const CoordsXYRangedZ& pos, CLEAR_FUNC clearFunc, QuarterTile quarterTile, uint8_t flags, uint8_t crossingMode, bool isTree) -{ - int32_t northZ, eastZ, baseHeight, southZ, westZ, water_height; - northZ = eastZ = baseHeight = southZ = westZ = water_height = 0; - auto res = std::make_unique(); - uint8_t slope = 0; - - res->GroundFlags = ELEMENT_IS_ABOVE_GROUND; - bool canBuildCrossing = false; - if (map_is_edge(pos)) - { - res->Error = GameActions::Status::InvalidParameters; - res->ErrorMessage = STR_OFF_EDGE_OF_MAP; - return res; - } - - if (gCheatsDisableClearanceChecks) - { - return res; - } - - TileElement* tileElement = map_get_first_element_at(pos); - if (tileElement == nullptr) - { - res->Error = GameActions::Status::Unknown; - res->ErrorMessage = STR_NONE; - return res; - } - do - { - if (tileElement->GetType() != TILE_ELEMENT_TYPE_SURFACE) - { - if (pos.baseZ < tileElement->GetClearanceZ() && pos.clearanceZ > tileElement->GetBaseZ() - && !(tileElement->IsGhost())) - { - if (tileElement->GetOccupiedQuadrants() & (quarterTile.GetBaseQuarterOccupied())) - { - if (MapLoc68BABCShouldContinue( - tileElement, pos, clearFunc, flags, res->Cost, crossingMode, canBuildCrossing)) - { - continue; - } - - if (tileElement != nullptr) - { - map_obstruction_set_error_text(tileElement, *res); - res->Error = GameActions::Status::NoClearance; - } - return res; - } - } - continue; - } - water_height = tileElement->AsSurface()->GetWaterHeight(); - if (water_height && water_height > pos.baseZ && tileElement->GetBaseZ() < pos.clearanceZ) - { - res->GroundFlags |= ELEMENT_IS_UNDERWATER; - if (water_height < pos.clearanceZ) - { - bool returnError = true; - if (clearFunc != nullptr) - { - if (!clearFunc(&tileElement, pos, flags, &res->Cost)) - { - returnError = false; - } - } - if (returnError) - { - if (tileElement != nullptr) - { - res->Error = GameActions::Status::NoClearance; - res->ErrorMessage = STR_CANNOT_BUILD_PARTLY_ABOVE_AND_PARTLY_BELOW_WATER; - } - return res; - } - } - } - - if (gParkFlags & PARK_FLAGS_FORBID_HIGH_CONSTRUCTION && !isTree) - { - auto heightFromGround = pos.clearanceZ - tileElement->GetBaseZ(); - - if (heightFromGround > (18 * COORDS_Z_STEP)) - { - res->Error = GameActions::Status::Disallowed; - res->ErrorMessage = STR_LOCAL_AUTHORITY_WONT_ALLOW_CONSTRUCTION_ABOVE_TREE_HEIGHT; - return res; - } - } - - // Only allow building crossings directly on a flat surface tile. - if (tileElement->GetType() == TILE_ELEMENT_TYPE_SURFACE - && (tileElement->AsSurface()->GetSlope()) == TILE_ELEMENT_SLOPE_FLAT && tileElement->GetBaseZ() == pos.baseZ) - { - canBuildCrossing = true; - } - - if (quarterTile.GetZQuarterOccupied() != 0b1111) - { - if (tileElement->GetBaseZ() >= pos.clearanceZ) - { - // loc_68BA81 - res->GroundFlags |= ELEMENT_IS_UNDERGROUND; - res->GroundFlags &= ~ELEMENT_IS_ABOVE_GROUND; - } - else - { - northZ = tileElement->GetBaseZ(); - eastZ = northZ; - southZ = northZ; - westZ = northZ; - slope = tileElement->AsSurface()->GetSlope(); - if (slope & TILE_ELEMENT_SLOPE_N_CORNER_UP) - { - northZ += LAND_HEIGHT_STEP; - if (slope == (TILE_ELEMENT_SLOPE_S_CORNER_DN | TILE_ELEMENT_SLOPE_DOUBLE_HEIGHT)) - northZ += LAND_HEIGHT_STEP; - } - if (slope & TILE_ELEMENT_SLOPE_E_CORNER_UP) - { - eastZ += LAND_HEIGHT_STEP; - if (slope == (TILE_ELEMENT_SLOPE_W_CORNER_DN | TILE_ELEMENT_SLOPE_DOUBLE_HEIGHT)) - eastZ += LAND_HEIGHT_STEP; - } - if (slope & TILE_ELEMENT_SLOPE_S_CORNER_UP) - { - southZ += LAND_HEIGHT_STEP; - if (slope == (TILE_ELEMENT_SLOPE_N_CORNER_DN | TILE_ELEMENT_SLOPE_DOUBLE_HEIGHT)) - southZ += LAND_HEIGHT_STEP; - } - if (slope & TILE_ELEMENT_SLOPE_W_CORNER_UP) - { - westZ += LAND_HEIGHT_STEP; - if (slope == (TILE_ELEMENT_SLOPE_E_CORNER_DN | TILE_ELEMENT_SLOPE_DOUBLE_HEIGHT)) - westZ += LAND_HEIGHT_STEP; - } - baseHeight = pos.baseZ + (4 * COORDS_Z_STEP); - { - auto baseQuarter = quarterTile.GetBaseQuarterOccupied(); - auto zQuarter = quarterTile.GetZQuarterOccupied(); - if ((!(baseQuarter & 0b0001) || ((zQuarter & 0b0001 || pos.baseZ >= northZ) && baseHeight >= northZ)) - && (!(baseQuarter & 0b0010) || ((zQuarter & 0b0010 || pos.baseZ >= eastZ) && baseHeight >= eastZ)) - && (!(baseQuarter & 0b0100) || ((zQuarter & 0b0100 || pos.baseZ >= southZ) && baseHeight >= southZ)) - && (!(baseQuarter & 0b1000) || ((zQuarter & 0b1000 || pos.baseZ >= westZ) && baseHeight >= westZ))) - { - continue; - } - } - - if (MapLoc68BABCShouldContinue(tileElement, pos, clearFunc, flags, res->Cost, crossingMode, canBuildCrossing)) - { - continue; - } - - if (tileElement != nullptr) - { - map_obstruction_set_error_text(tileElement, *res); - res->Error = GameActions::Status::NoClearance; - } - return res; - } - } - } while (!(tileElement++)->IsLastForTile()); - return res; -} - -std::unique_ptr MapCanConstructAt(const CoordsXYRangedZ& pos, QuarterTile bl) -{ - return MapCanConstructWithClearAt(pos, nullptr, bl, 0); -} /** * Updates grass length, scenery age and jumping fountains. * diff --git a/src/openrct2/world/Map.h b/src/openrct2/world/Map.h index d9f524c646..38654a35d4 100644 --- a/src/openrct2/world/Map.h +++ b/src/openrct2/world/Map.h @@ -233,21 +233,6 @@ template T* TileElementInsert(const CoordsXYZ& loc, int32_t occupied return (element != nullptr) ? element->template as() : nullptr; } -namespace GameActions -{ - class Result; - class ConstructClearResult; -} // namespace GameActions - -using CLEAR_FUNC = int32_t (*)(TileElement** tile_element, const CoordsXY& coords, uint8_t flags, money32* price); - -int32_t map_place_non_scenery_clear_func(TileElement** tile_element, const CoordsXY& coords, uint8_t flags, money32* price); -int32_t map_place_scenery_clear_func(TileElement** tile_element, const CoordsXY& coords, uint8_t flags, money32* price); -[[nodiscard]] std::unique_ptr MapCanConstructWithClearAt( - const CoordsXYRangedZ& pos, CLEAR_FUNC clearFunc, QuarterTile quarterTile, uint8_t flags, - uint8_t crossingMode = CREATE_CROSSING_MODE_NONE, bool isTree = false); -[[nodiscard]] std::unique_ptr MapCanConstructAt(const CoordsXYRangedZ& pos, QuarterTile bl); - struct tile_element_iterator { int32_t x; @@ -305,7 +290,6 @@ TileElement* map_get_track_element_at_from_ride(const CoordsXYZ& trackPos, ride_ TileElement* map_get_track_element_at_with_direction_from_ride(const CoordsXYZD& trackPos, ride_id_t rideIndex); bool map_is_location_at_edge(const CoordsXY& loc); -void map_obstruction_set_error_text(TileElement* tileElement, GameActions::Result& res); uint16_t check_max_allowable_land_rights_for_tile(const CoordsXYZ& tileMapPos); diff --git a/src/openrct2/world/SmallScenery.cpp b/src/openrct2/world/SmallScenery.cpp index 8e01331916..5abe1a2967 100644 --- a/src/openrct2/world/SmallScenery.cpp +++ b/src/openrct2/world/SmallScenery.cpp @@ -24,58 +24,6 @@ #include "Scenery.h" #include "Surface.h" -static int32_t map_place_clear_func( - TileElement** tile_element, const CoordsXY& coords, uint8_t flags, money32* price, bool is_scenery) -{ - if ((*tile_element)->GetType() != TILE_ELEMENT_TYPE_SMALL_SCENERY) - return 1; - - if (is_scenery && !(flags & GAME_COMMAND_FLAG_PATH_SCENERY)) - return 1; - - auto* scenery = (*tile_element)->AsSmallScenery()->GetEntry(); - - if (gParkFlags & PARK_FLAGS_FORBID_TREE_REMOVAL) - { - if (scenery != nullptr && scenery->HasFlag(SMALL_SCENERY_FLAG_IS_TREE)) - return 1; - } - - if (!(gParkFlags & PARK_FLAGS_NO_MONEY) && scenery != nullptr) - *price += scenery->removal_price * 10; - - if (flags & GAME_COMMAND_FLAG_GHOST) - return 0; - - if (!(flags & GAME_COMMAND_FLAG_APPLY)) - return 0; - - map_invalidate_tile({ coords, (*tile_element)->GetBaseZ(), (*tile_element)->GetClearanceZ() }); - - tile_element_remove(*tile_element); - - (*tile_element)--; - return 0; -} - -/** - * - * rct2: 0x006E0D6E, 0x006B8D88 - */ -int32_t map_place_scenery_clear_func(TileElement** tile_element, const CoordsXY& coords, uint8_t flags, money32* price) -{ - return map_place_clear_func(tile_element, coords, flags, price, /*is_scenery=*/true); -} - -/** - * - * rct2: 0x006C5A4F, 0x006CDE57, 0x006A6733, 0x0066637E - */ -int32_t map_place_non_scenery_clear_func(TileElement** tile_element, const CoordsXY& coords, uint8_t flags, money32* price) -{ - return map_place_clear_func(tile_element, coords, flags, price, /*is_scenery=*/false); -} - uint8_t SmallSceneryElement::GetSceneryQuadrant() const { return (this->type & TILE_ELEMENT_QUADRANT_MASK) >> 6; From a40f6a8444258b00469bf4d17ed0ae8d4c0d60a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Wed, 20 Oct 2021 21:53:36 +0300 Subject: [PATCH 2/7] Include required headers --- src/openrct2/world/ConstructionClearance.cpp | 1 - src/openrct2/world/ConstructionClearance.h | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/openrct2/world/ConstructionClearance.cpp b/src/openrct2/world/ConstructionClearance.cpp index 430119a991..af78a35a25 100644 --- a/src/openrct2/world/ConstructionClearance.cpp +++ b/src/openrct2/world/ConstructionClearance.cpp @@ -13,7 +13,6 @@ #include "../openrct2/Cheats.h" #include "../ride/Ride.h" #include "../ride/RideData.h" -#include "Map.h" #include "Park.h" #include "Scenery.h" #include "SmallScenery.h" diff --git a/src/openrct2/world/ConstructionClearance.h b/src/openrct2/world/ConstructionClearance.h index 9662e04e1a..8b6800098e 100644 --- a/src/openrct2/world/ConstructionClearance.h +++ b/src/openrct2/world/ConstructionClearance.h @@ -10,6 +10,11 @@ #pragma once #include "../actions/GameActionResult.h" +#include "Location.hpp" +#include "Map.h" +#include "TileElement.h" + +#include using CLEAR_FUNC = int32_t (*)(TileElement** tile_element, const CoordsXY& coords, uint8_t flags, money32* price); From b15dc66acb38d9002e5dea14fac116548823de4f Mon Sep 17 00:00:00 2001 From: Steve Blythe <47742805+agentblythe@users.noreply.github.com> Date: Wed, 20 Oct 2021 23:43:32 +0100 Subject: [PATCH 3/7] Part of #12098: Use ScreenRect in gfx_filter_rect() (#15603) --- .../windows/EditorBottomToolbar.cpp | 19 ++++++------ .../windows/EditorInventionsList.cpp | 2 +- .../windows/EditorObjectSelection.cpp | 2 +- .../windows/EditorObjectiveOptions.cpp | 2 +- src/openrct2-ui/windows/GameBottomToolbar.cpp | 29 +++++++++---------- src/openrct2-ui/windows/Guest.cpp | 2 +- src/openrct2-ui/windows/GuestList.cpp | 4 +-- src/openrct2-ui/windows/LoadSave.cpp | 2 +- src/openrct2-ui/windows/Multiplayer.cpp | 5 ++-- src/openrct2-ui/windows/RideList.cpp | 2 +- src/openrct2-ui/windows/ScenarioSelect.cpp | 2 +- src/openrct2-ui/windows/ServerList.cpp | 2 +- src/openrct2-ui/windows/ShortcutKeys.cpp | 2 +- src/openrct2-ui/windows/StaffList.cpp | 2 +- src/openrct2-ui/windows/Themes.cpp | 27 +++++++---------- src/openrct2-ui/windows/TrackList.cpp | 4 +-- src/openrct2/drawing/Drawing.h | 1 - src/openrct2/drawing/NewDrawing.cpp | 5 ---- 18 files changed, 51 insertions(+), 63 deletions(-) diff --git a/src/openrct2-ui/windows/EditorBottomToolbar.cpp b/src/openrct2-ui/windows/EditorBottomToolbar.cpp index ad021fcfea..10f0282b32 100644 --- a/src/openrct2-ui/windows/EditorBottomToolbar.cpp +++ b/src/openrct2-ui/windows/EditorBottomToolbar.cpp @@ -387,22 +387,21 @@ void window_editor_bottom_toolbar_paint(rct_window* w, rct_drawpixelinfo* dpi) if (!(gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER)) { + auto previousWidget = window_editor_bottom_toolbar_widgets[WIDX_PREVIOUS_IMAGE]; + auto nextWidget = window_editor_bottom_toolbar_widgets[WIDX_NEXT_IMAGE]; + if (drawPreviousButton) { - gfx_filter_rect( - dpi, window_editor_bottom_toolbar_widgets[WIDX_PREVIOUS_IMAGE].left + w->windowPos.x, - window_editor_bottom_toolbar_widgets[WIDX_PREVIOUS_IMAGE].top + w->windowPos.y, - window_editor_bottom_toolbar_widgets[WIDX_PREVIOUS_IMAGE].right + w->windowPos.x, - window_editor_bottom_toolbar_widgets[WIDX_PREVIOUS_IMAGE].bottom + w->windowPos.y, FilterPaletteID::Palette51); + auto leftTop = w->windowPos + ScreenCoordsXY{ previousWidget.left, previousWidget.top }; + auto rightBottom = w->windowPos + ScreenCoordsXY{ previousWidget.right, previousWidget.bottom }; + gfx_filter_rect(dpi, { leftTop, rightBottom }, FilterPaletteID::Palette51); } if ((drawPreviousButton || drawNextButton) && gEditorStep != EditorStep::RollercoasterDesigner) { - gfx_filter_rect( - dpi, window_editor_bottom_toolbar_widgets[WIDX_NEXT_IMAGE].left + w->windowPos.x, - window_editor_bottom_toolbar_widgets[WIDX_NEXT_IMAGE].top + w->windowPos.y, - window_editor_bottom_toolbar_widgets[WIDX_NEXT_IMAGE].right + w->windowPos.x, - window_editor_bottom_toolbar_widgets[WIDX_NEXT_IMAGE].bottom + w->windowPos.y, FilterPaletteID::Palette51); + auto leftTop = w->windowPos + ScreenCoordsXY{ nextWidget.left, nextWidget.top }; + auto rightBottom = w->windowPos + ScreenCoordsXY{ nextWidget.right, nextWidget.bottom }; + gfx_filter_rect(dpi, { leftTop, rightBottom }, FilterPaletteID::Palette51); } } diff --git a/src/openrct2-ui/windows/EditorInventionsList.cpp b/src/openrct2-ui/windows/EditorInventionsList.cpp index da3e0e5af9..a3d911b202 100644 --- a/src/openrct2-ui/windows/EditorInventionsList.cpp +++ b/src/openrct2-ui/windows/EditorInventionsList.cpp @@ -607,7 +607,7 @@ static void window_editor_inventions_list_scrollpaint(rct_window* w, rct_drawpix bottom = itemY; } - gfx_filter_rect(dpi, 0, top, boxWidth, bottom, FilterPaletteID::PaletteDarken1); + gfx_filter_rect(dpi, { 0, top, boxWidth, bottom }, FilterPaletteID::PaletteDarken1); } if (researchItem == _editorInventionsListDraggedItem) diff --git a/src/openrct2-ui/windows/EditorObjectSelection.cpp b/src/openrct2-ui/windows/EditorObjectSelection.cpp index d96ab1f713..c8c6815ba5 100644 --- a/src/openrct2-ui/windows/EditorObjectSelection.cpp +++ b/src/openrct2-ui/windows/EditorObjectSelection.cpp @@ -1228,7 +1228,7 @@ static void window_editor_object_selection_scrollpaint(rct_window* w, rct_drawpi if (highlighted) { auto bottom = screenCoords.y + (SCROLLABLE_ROW_HEIGHT - 1); - gfx_filter_rect(dpi, 0, screenCoords.y, w->width, bottom, FilterPaletteID::PaletteDarken1); + gfx_filter_rect(dpi, { 0, screenCoords.y, w->width, bottom }, FilterPaletteID::PaletteDarken1); } // Draw checkmark diff --git a/src/openrct2-ui/windows/EditorObjectiveOptions.cpp b/src/openrct2-ui/windows/EditorObjectiveOptions.cpp index d9234fc869..1afefb10ab 100644 --- a/src/openrct2-ui/windows/EditorObjectiveOptions.cpp +++ b/src/openrct2-ui/windows/EditorObjectiveOptions.cpp @@ -1095,7 +1095,7 @@ static void window_editor_objective_options_rides_scrollpaint(rct_window* w, rct if (i == w->selected_list_item) { stringId = STR_WINDOW_COLOUR_2_STRINGID; - gfx_filter_rect(dpi, 0, y, w->width, y + 11, FilterPaletteID::PaletteDarken1); + gfx_filter_rect(dpi, { 0, y, w->width, y + 11 }, FilterPaletteID::PaletteDarken1); } // Checkbox mark diff --git a/src/openrct2-ui/windows/GameBottomToolbar.cpp b/src/openrct2-ui/windows/GameBottomToolbar.cpp index 08cad14dd6..fcd2b87d7d 100644 --- a/src/openrct2-ui/windows/GameBottomToolbar.cpp +++ b/src/openrct2-ui/windows/GameBottomToolbar.cpp @@ -350,26 +350,25 @@ void window_game_bottom_toolbar_invalidate_news_item() */ static void window_game_bottom_toolbar_paint(rct_window* w, rct_drawpixelinfo* dpi) { + auto leftWidget = window_game_bottom_toolbar_widgets[WIDX_LEFT_OUTSET]; + auto rightWidget = window_game_bottom_toolbar_widgets[WIDX_RIGHT_OUTSET]; + auto middleWidget = window_game_bottom_toolbar_widgets[WIDX_MIDDLE_OUTSET]; + // Draw panel grey backgrounds - gfx_filter_rect( - dpi, w->windowPos.x + window_game_bottom_toolbar_widgets[WIDX_LEFT_OUTSET].left, - w->windowPos.y + window_game_bottom_toolbar_widgets[WIDX_LEFT_OUTSET].top, - w->windowPos.x + window_game_bottom_toolbar_widgets[WIDX_LEFT_OUTSET].right, - w->windowPos.y + window_game_bottom_toolbar_widgets[WIDX_LEFT_OUTSET].bottom, FilterPaletteID::Palette51); - gfx_filter_rect( - dpi, w->windowPos.x + window_game_bottom_toolbar_widgets[WIDX_RIGHT_OUTSET].left, - w->windowPos.y + window_game_bottom_toolbar_widgets[WIDX_RIGHT_OUTSET].top, - w->windowPos.x + window_game_bottom_toolbar_widgets[WIDX_RIGHT_OUTSET].right, - w->windowPos.y + window_game_bottom_toolbar_widgets[WIDX_RIGHT_OUTSET].bottom, FilterPaletteID::Palette51); + auto leftTop = w->windowPos + ScreenCoordsXY{ leftWidget.left, leftWidget.top }; + auto rightBottom = w->windowPos + ScreenCoordsXY{ leftWidget.right, leftWidget.bottom }; + gfx_filter_rect(dpi, { leftTop, rightBottom }, FilterPaletteID::Palette51); + + leftTop = w->windowPos + ScreenCoordsXY{ rightWidget.left, rightWidget.top }; + rightBottom = w->windowPos + ScreenCoordsXY{ rightWidget.right, rightWidget.bottom }; + gfx_filter_rect(dpi, { leftTop, rightBottom }, FilterPaletteID::Palette51); if (ThemeGetFlags() & UITHEME_FLAG_USE_FULL_BOTTOM_TOOLBAR) { // Draw grey background - gfx_filter_rect( - dpi, w->windowPos.x + window_game_bottom_toolbar_widgets[WIDX_MIDDLE_OUTSET].left, - w->windowPos.y + window_game_bottom_toolbar_widgets[WIDX_MIDDLE_OUTSET].top, - w->windowPos.x + window_game_bottom_toolbar_widgets[WIDX_MIDDLE_OUTSET].right, - w->windowPos.y + window_game_bottom_toolbar_widgets[WIDX_MIDDLE_OUTSET].bottom, FilterPaletteID::Palette51); + leftTop = w->windowPos + ScreenCoordsXY{ middleWidget.left, middleWidget.top }; + rightBottom = w->windowPos + ScreenCoordsXY{ middleWidget.right, middleWidget.bottom }; + gfx_filter_rect(dpi, { leftTop, rightBottom }, FilterPaletteID::Palette51); } WindowDrawWidgets(w, dpi); diff --git a/src/openrct2-ui/windows/Guest.cpp b/src/openrct2-ui/windows/Guest.cpp index 9b0941bcb0..03eca04d74 100644 --- a/src/openrct2-ui/windows/Guest.cpp +++ b/src/openrct2-ui/windows/Guest.cpp @@ -1636,7 +1636,7 @@ void window_guest_rides_scroll_paint(rct_window* w, rct_drawpixelinfo* dpi, int3 rct_string_id stringId = STR_BLACK_STRING; if (list_index == w->selected_list_item) { - gfx_filter_rect(dpi, 0, y, 800, y + 9, FilterPaletteID::PaletteDarken1); + gfx_filter_rect(dpi, { 0, y, 800, y + 9 }, FilterPaletteID::PaletteDarken1); stringId = STR_WINDOW_COLOUR_2_STRINGID; } diff --git a/src/openrct2-ui/windows/GuestList.cpp b/src/openrct2-ui/windows/GuestList.cpp index f514c424cc..6170b36a37 100644 --- a/src/openrct2-ui/windows/GuestList.cpp +++ b/src/openrct2-ui/windows/GuestList.cpp @@ -675,7 +675,7 @@ private: rct_string_id format = STR_BLACK_STRING; if (index == _highlightedIndex) { - gfx_filter_rect(&dpi, 0, y, 800, y + SCROLLABLE_ROW_HEIGHT - 1, FilterPaletteID::PaletteDarken1); + gfx_filter_rect(&dpi, { 0, y, 800, y + SCROLLABLE_ROW_HEIGHT - 1 }, FilterPaletteID::PaletteDarken1); format = STR_WINDOW_COLOUR_2_STRINGID; } @@ -745,7 +745,7 @@ private: rct_string_id format = STR_BLACK_STRING; if (index == _highlightedIndex) { - gfx_filter_rect(&dpi, 0, y, 800, y + SUMMARISED_GUEST_ROW_HEIGHT, FilterPaletteID::PaletteDarken1); + gfx_filter_rect(&dpi, { 0, y, 800, y + SUMMARISED_GUEST_ROW_HEIGHT }, FilterPaletteID::PaletteDarken1); format = STR_WINDOW_COLOUR_2_STRINGID; } diff --git a/src/openrct2-ui/windows/LoadSave.cpp b/src/openrct2-ui/windows/LoadSave.cpp index 4ec600b212..88a50c50d3 100644 --- a/src/openrct2-ui/windows/LoadSave.cpp +++ b/src/openrct2-ui/windows/LoadSave.cpp @@ -759,7 +759,7 @@ static void window_loadsave_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, i if (i == w->selected_list_item) { stringId = STR_WINDOW_COLOUR_2_STRINGID; - gfx_filter_rect(dpi, 0, y, listWidth, y + SCROLLABLE_ROW_HEIGHT, FilterPaletteID::PaletteDarken1); + gfx_filter_rect(dpi, { 0, y, listWidth, y + SCROLLABLE_ROW_HEIGHT }, FilterPaletteID::PaletteDarken1); } // display a marker next to the currently loaded game file if (_listItems[i].loaded) diff --git a/src/openrct2-ui/windows/Multiplayer.cpp b/src/openrct2-ui/windows/Multiplayer.cpp index 2c8e8b8b6b..319b78b949 100644 --- a/src/openrct2-ui/windows/Multiplayer.cpp +++ b/src/openrct2-ui/windows/Multiplayer.cpp @@ -603,7 +603,8 @@ static void window_multiplayer_players_scrollpaint(rct_window* w, rct_drawpixeli if (i == w->selected_list_item) { gfx_filter_rect( - dpi, 0, screenCoords.y, 800, screenCoords.y + SCROLLABLE_ROW_HEIGHT - 1, FilterPaletteID::PaletteDarken1); + dpi, { 0, screenCoords.y, 800, screenCoords.y + SCROLLABLE_ROW_HEIGHT - 1 }, + FilterPaletteID::PaletteDarken1); buffer += network_get_player_name(i); colour = w->colours[2]; } @@ -905,7 +906,7 @@ static void window_multiplayer_groups_scrollpaint(rct_window* w, rct_drawpixelin if (i == w->selected_list_item) { gfx_filter_rect( - dpi, 0, screenCoords.y, 800, screenCoords.y + SCROLLABLE_ROW_HEIGHT - 1, FilterPaletteID::PaletteDarken1); + dpi, { 0, screenCoords.y, 800, screenCoords.y + SCROLLABLE_ROW_HEIGHT - 1 }, FilterPaletteID::PaletteDarken1); } if (screenCoords.y > dpi->y + dpi->height) { diff --git a/src/openrct2-ui/windows/RideList.cpp b/src/openrct2-ui/windows/RideList.cpp index be837d8a6f..0769686996 100644 --- a/src/openrct2-ui/windows/RideList.cpp +++ b/src/openrct2-ui/windows/RideList.cpp @@ -578,7 +578,7 @@ static void window_ride_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, if (i == static_cast(w->selected_list_item)) { // Background highlight - gfx_filter_rect(dpi, 0, y, 800, y + SCROLLABLE_ROW_HEIGHT - 1, FilterPaletteID::PaletteDarken1); + gfx_filter_rect(dpi, { 0, y, 800, y + SCROLLABLE_ROW_HEIGHT - 1 }, FilterPaletteID::PaletteDarken1); format = (_quickDemolishMode ? STR_LIGHTPINK_STRINGID : STR_WINDOW_COLOUR_2_STRINGID); } diff --git a/src/openrct2-ui/windows/ScenarioSelect.cpp b/src/openrct2-ui/windows/ScenarioSelect.cpp index fe9d8b8812..5c219c7ea2 100644 --- a/src/openrct2-ui/windows/ScenarioSelect.cpp +++ b/src/openrct2-ui/windows/ScenarioSelect.cpp @@ -596,7 +596,7 @@ static void window_scenarioselect_scrollpaint(rct_window* w, rct_drawpixelinfo* bool isHighlighted = w->highlighted_scenario == scenario; if (isHighlighted) { - gfx_filter_rect(dpi, 0, y, w->width, y + scenarioItemHeight - 1, FilterPaletteID::PaletteDarken1); + gfx_filter_rect(dpi, { 0, y, w->width, y + scenarioItemHeight - 1 }, FilterPaletteID::PaletteDarken1); } bool isCompleted = scenario->highscore != nullptr; diff --git a/src/openrct2-ui/windows/ServerList.cpp b/src/openrct2-ui/windows/ServerList.cpp index 11a364eec5..d629bdbecb 100644 --- a/src/openrct2-ui/windows/ServerList.cpp +++ b/src/openrct2-ui/windows/ServerList.cpp @@ -439,7 +439,7 @@ static void window_server_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi // Draw hover highlight if (highlighted) { - gfx_filter_rect(dpi, 0, screenCoords.y, width, screenCoords.y + ITEM_HEIGHT, FilterPaletteID::PaletteDarken1); + gfx_filter_rect(dpi, { 0, screenCoords.y, width, screenCoords.y + ITEM_HEIGHT }, FilterPaletteID::PaletteDarken1); _version = serverDetails.Version; listWidget.tooltip = STR_NETWORK_VERSION_TIP; } diff --git a/src/openrct2-ui/windows/ShortcutKeys.cpp b/src/openrct2-ui/windows/ShortcutKeys.cpp index 7739f5420b..4a72589e58 100644 --- a/src/openrct2-ui/windows/ShortcutKeys.cpp +++ b/src/openrct2-ui/windows/ShortcutKeys.cpp @@ -509,7 +509,7 @@ private: if (isHighlighted) { format = STR_WINDOW_COLOUR_2_STRINGID; - gfx_filter_rect(&dpi, 0, y - 1, scrollWidth, y + (SCROLLABLE_ROW_HEIGHT - 2), FilterPaletteID::PaletteDarken1); + gfx_filter_rect(&dpi, { 0, y - 1, scrollWidth, y + (SCROLLABLE_ROW_HEIGHT - 2) }, FilterPaletteID::PaletteDarken1); } auto bindingOffset = (scrollWidth * 2) / 3; diff --git a/src/openrct2-ui/windows/StaffList.cpp b/src/openrct2-ui/windows/StaffList.cpp index 5e7dc4e899..5004cf4cac 100644 --- a/src/openrct2-ui/windows/StaffList.cpp +++ b/src/openrct2-ui/windows/StaffList.cpp @@ -401,7 +401,7 @@ public: if (i == _highlightedIndex) { - gfx_filter_rect(&dpi, 0, y, 800, y + (SCROLLABLE_ROW_HEIGHT - 1), FilterPaletteID::PaletteDarken1); + gfx_filter_rect(&dpi, { 0, y, 800, y + (SCROLLABLE_ROW_HEIGHT - 1) }, FilterPaletteID::PaletteDarken1); format = (_quickFireMode ? STR_LIGHTPINK_STRINGID : STR_WINDOW_COLOUR_2_STRINGID); } diff --git a/src/openrct2-ui/windows/Themes.cpp b/src/openrct2-ui/windows/Themes.cpp index cf2d5e0d72..e154e16e09 100644 --- a/src/openrct2-ui/windows/Themes.cpp +++ b/src/openrct2-ui/windows/Themes.cpp @@ -867,31 +867,26 @@ void window_themes_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32_t sc if (i + 1 < get_colour_scheme_tab_count()) { int32_t colour = w->colours[1]; + + auto leftTop = ScreenCoordsXY{ 0, screenCoords.y + _row_height - 2 }; + auto rightBottom = ScreenCoordsXY{ window_themes_widgets[WIDX_THEMES_LIST].right, + screenCoords.y + _row_height - 2 }; + auto yPixelOffset = ScreenCoordsXY{ 0, 1 }; + if (colour & COLOUR_FLAG_TRANSLUCENT) { translucent_window_palette windowPalette = TranslucentWindowPalettes[BASE_COLOUR(colour)]; - gfx_filter_rect( - dpi, 0, screenCoords.y + _row_height - 2, window_themes_widgets[WIDX_THEMES_LIST].right, - screenCoords.y + _row_height - 2, windowPalette.highlight); - gfx_filter_rect( - dpi, 0, screenCoords.y + _row_height - 1, window_themes_widgets[WIDX_THEMES_LIST].right, - screenCoords.y + _row_height - 1, windowPalette.shadow); + gfx_filter_rect(dpi, { leftTop, rightBottom }, windowPalette.highlight); + gfx_filter_rect(dpi, { leftTop + yPixelOffset, rightBottom + yPixelOffset }, windowPalette.shadow); } else { colour = ColourMapA[w->colours[1]].mid_dark; - gfx_fill_rect( - dpi, - { { 0, screenCoords.y + _row_height - 2 }, - { window_themes_widgets[WIDX_THEMES_LIST].right, screenCoords.y + _row_height - 2 } }, - colour); + gfx_fill_rect(dpi, { leftTop, rightBottom }, colour); + colour = ColourMapA[w->colours[1]].lightest; - gfx_fill_rect( - dpi, - { { 0, screenCoords.y + _row_height - 1 }, - { window_themes_widgets[WIDX_THEMES_LIST].right, screenCoords.y + _row_height - 1 } }, - colour); + gfx_fill_rect(dpi, { leftTop + yPixelOffset, rightBottom + yPixelOffset }, colour); } } diff --git a/src/openrct2-ui/windows/TrackList.cpp b/src/openrct2-ui/windows/TrackList.cpp index 6cdc7e4e29..53ece652db 100644 --- a/src/openrct2-ui/windows/TrackList.cpp +++ b/src/openrct2-ui/windows/TrackList.cpp @@ -690,7 +690,7 @@ public: { // Highlight gfx_filter_rect( - &dpi, screenCoords.x, screenCoords.y, width, screenCoords.y + SCROLLABLE_ROW_HEIGHT - 1, + &dpi, { screenCoords, { width, screenCoords.y + SCROLLABLE_ROW_HEIGHT - 1 } }, FilterPaletteID::PaletteDarken1); stringId = STR_WINDOW_COLOUR_2_STRINGID; } @@ -715,7 +715,7 @@ public: { // Highlight gfx_filter_rect( - &dpi, screenCoords.x, screenCoords.y, width, screenCoords.y + SCROLLABLE_ROW_HEIGHT - 1, + &dpi, { screenCoords, { width, screenCoords.y + SCROLLABLE_ROW_HEIGHT - 1 } }, FilterPaletteID::PaletteDarken1); stringId = STR_WINDOW_COLOUR_2_STRINGID; } diff --git a/src/openrct2/drawing/Drawing.h b/src/openrct2/drawing/Drawing.h index 2e66236126..940aa7a8c3 100644 --- a/src/openrct2/drawing/Drawing.h +++ b/src/openrct2/drawing/Drawing.h @@ -692,7 +692,6 @@ void gfx_draw_dashed_line( // rect void gfx_fill_rect(rct_drawpixelinfo* dpi, const ScreenRect& rect, int32_t colour); void gfx_fill_rect_inset(rct_drawpixelinfo* dpi, const ScreenRect& rect, int32_t colour, uint8_t flags); -void gfx_filter_rect(rct_drawpixelinfo* dpi, int32_t left, int32_t top, int32_t right, int32_t bottom, FilterPaletteID palette); void gfx_filter_rect(rct_drawpixelinfo* dpi, const ScreenRect& rect, FilterPaletteID palette); // sprite diff --git a/src/openrct2/drawing/NewDrawing.cpp b/src/openrct2/drawing/NewDrawing.cpp index ed5f8c4aee..01bb3b7bcf 100644 --- a/src/openrct2/drawing/NewDrawing.cpp +++ b/src/openrct2/drawing/NewDrawing.cpp @@ -180,11 +180,6 @@ void gfx_fill_rect(rct_drawpixelinfo* dpi, const ScreenRect& rect, int32_t colou } } -void gfx_filter_rect(rct_drawpixelinfo* dpi, int32_t left, int32_t top, int32_t right, int32_t bottom, FilterPaletteID palette) -{ - gfx_filter_rect(dpi, { left, top, right, bottom }, palette); -} - void gfx_filter_rect(rct_drawpixelinfo* dpi, const ScreenRect& rect, FilterPaletteID palette) { auto drawingEngine = dpi->DrawingEngine; From ebedf8317696da68888536b28bdfd8ccc4aee44d Mon Sep 17 00:00:00 2001 From: Sijmen Date: Thu, 21 Oct 2021 02:26:01 +0200 Subject: [PATCH 4/7] Format ServerList.cpp (#15625) --- src/openrct2-ui/windows/ServerList.cpp | 46 ++++++++++++++------------ 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/src/openrct2-ui/windows/ServerList.cpp b/src/openrct2-ui/windows/ServerList.cpp index d629bdbecb..90731a267f 100644 --- a/src/openrct2-ui/windows/ServerList.cpp +++ b/src/openrct2-ui/windows/ServerList.cpp @@ -40,8 +40,8 @@ static std::future, rct_string_id>> _fet static uint32_t _numPlayersOnline = 0; static rct_string_id _statusText = STR_SERVER_LIST_CONNECTING; -// clang-format off -enum { +enum +{ WIDX_BACKGROUND, WIDX_TITLE, WIDX_CLOSE, @@ -52,39 +52,42 @@ enum { WIDX_START_SERVER }; -enum { +enum +{ WIDX_LIST_REMOVE, WIDX_LIST_SPECTATE }; +// clang-format off static rct_widget window_server_list_widgets[] = { MakeWidget({ 0, 0}, {341, 91}, WindowWidgetType::Frame, WindowColour::Primary ), // panel / background - MakeWidget({ 1, 1}, {338, 14}, WindowWidgetType::Caption, WindowColour::Primary , STR_SERVER_LIST, STR_WINDOW_TITLE_TIP), // title bar - MakeWidget({327, 2}, { 11, 12}, WindowWidgetType::CloseBox, WindowColour::Primary , STR_CLOSE_X, STR_CLOSE_WINDOW_TIP), // close x button - MakeWidget({100, 20}, {245, 12}, WindowWidgetType::TextBox, WindowColour::Secondary ), // player name text box + MakeWidget({ 1, 1}, {338, 14}, WindowWidgetType::Caption, WindowColour::Primary, STR_SERVER_LIST, STR_WINDOW_TITLE_TIP), // title bar + MakeWidget({327, 2}, { 11, 12}, WindowWidgetType::CloseBox, WindowColour::Primary, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP), // close x button + MakeWidget({100, 20}, {245, 12}, WindowWidgetType::TextBox, WindowColour::Secondary ), // player name text box MakeWidget({ 6, 37}, {332, 14}, WindowWidgetType::Scroll, WindowColour::Secondary ), // server list MakeWidget({ 6, 53}, {101, 14}, WindowWidgetType::Button, WindowColour::Secondary, STR_FETCH_SERVERS ), // fetch servers button MakeWidget({112, 53}, {101, 14}, WindowWidgetType::Button, WindowColour::Secondary, STR_ADD_SERVER ), // add server button MakeWidget({218, 53}, {101, 14}, WindowWidgetType::Button, WindowColour::Secondary, STR_START_SERVER ), // start server button WIDGETS_END, }; +// clang-format on -static void window_server_list_close(rct_window *w); -static void window_server_list_mouseup(rct_window *w, rct_widgetindex widgetIndex); -static void window_server_list_resize(rct_window *w); -static void window_server_list_dropdown(rct_window *w, rct_widgetindex widgetIndex, int32_t dropdownIndex); -static void window_server_list_update(rct_window *w); -static void window_server_list_scroll_getsize(rct_window *w, int32_t scrollIndex, int32_t *width, int32_t *height); -static void window_server_list_scroll_mousedown(rct_window *w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords); -static void window_server_list_scroll_mouseover(rct_window *w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords); -static void window_server_list_textinput(rct_window *w, rct_widgetindex widgetIndex, char *text); -static OpenRCT2String window_server_list_tooltip(rct_window* const w, const rct_widgetindex widgetIndex, rct_string_id fallback); -static void window_server_list_invalidate(rct_window *w); -static void window_server_list_paint(rct_window *w, rct_drawpixelinfo *dpi); -static void window_server_list_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int32_t scrollIndex); +static void window_server_list_close(rct_window* w); +static void window_server_list_mouseup(rct_window* w, rct_widgetindex widgetIndex); +static void window_server_list_resize(rct_window* w); +static void window_server_list_dropdown(rct_window* w, rct_widgetindex widgetIndex, int32_t dropdownIndex); +static void window_server_list_update(rct_window* w); +static void window_server_list_scroll_getsize(rct_window* w, int32_t scrollIndex, int32_t* width, int32_t* height); +static void window_server_list_scroll_mousedown(rct_window* w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords); +static void window_server_list_scroll_mouseover(rct_window* w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords); +static void window_server_list_textinput(rct_window* w, rct_widgetindex widgetIndex, char* text); +static OpenRCT2String window_server_list_tooltip( + rct_window* const w, const rct_widgetindex widgetIndex, rct_string_id fallback); +static void window_server_list_invalidate(rct_window* w); +static void window_server_list_paint(rct_window* w, rct_drawpixelinfo* dpi); +static void window_server_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32_t scrollIndex); -static rct_window_event_list window_server_list_events([](auto& events) -{ +static rct_window_event_list window_server_list_events([](auto& events) { events.close = &window_server_list_close; events.mouse_up = &window_server_list_mouseup; events.resize = &window_server_list_resize; @@ -99,7 +102,6 @@ static rct_window_event_list window_server_list_events([](auto& events) events.paint = &window_server_list_paint; events.scroll_paint = &window_server_list_scrollpaint; }); -// clang-format on enum { From e13307a28d9de42713c352eefa25a872173be16d Mon Sep 17 00:00:00 2001 From: Duncan Date: Thu, 21 Oct 2021 03:51:06 +0100 Subject: [PATCH 5/7] Small cleanup of variables (#13655) Co-authored-by: Gymnasiast --- .../paint/tile_element/Paint.TileElement.cpp | 17 ++++++----------- test/testpaint/Compat.cpp | 7 +++++++ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/openrct2/paint/tile_element/Paint.TileElement.cpp b/src/openrct2/paint/tile_element/Paint.TileElement.cpp index bd3723be8d..8591e590b6 100644 --- a/src/openrct2/paint/tile_element/Paint.TileElement.cpp +++ b/src/openrct2/paint/tile_element/Paint.TileElement.cpp @@ -23,6 +23,7 @@ #include "../../world/Banner.h" #include "../../world/Entrance.h" #include "../../world/Footpath.h" +#include "../../world/Map.h" #include "../../world/Scenery.h" #include "../../world/Surface.h" #include "../Paint.h" @@ -146,27 +147,24 @@ static void sub_68B3FB(paint_session* session, int32_t x, int32_t y) } #endif // __TESTPAINT__ - int32_t dx = 0; switch (rotation) { case 0: - dx = x + y; break; case 1: x += 32; - dx = y - x; break; case 2: x += 32; y += 32; - dx = -(x + y); break; case 3: y += 32; - dx = x - y; break; } - dx >>= 1; + + int32_t screenMinY = translate_3d_to_2d_with_z(rotation, { x, y, 0 }).y; + // Display little yellow arrow when building footpaths? if ((gMapSelectFlags & MAP_SELECT_FLAG_ENABLE_ARROW) && session->MapPosition.x == gMapSelectArrowPosition.x && session->MapPosition.y == gMapSelectArrowPosition.y) @@ -182,9 +180,8 @@ static void sub_68B3FB(paint_session* session, int32_t x, int32_t y) PaintAddImageAsParent(session, imageId, { 0, 0, arrowZ }, { 32, 32, -1 }, { 0, 0, arrowZ + 18 }); } - int32_t bx = dx + 52; - if (bx <= dpi->y) + if (screenMinY + 52 <= dpi->y) return; const TileElement* element = tile_element; // push tile_element @@ -210,9 +207,7 @@ static void sub_68B3FB(paint_session* session, int32_t x, int32_t y) } #endif // __TESTPAINT__ - dx -= max_height + 32; - dx -= dpi->height; - if (dx >= dpi->y) + if (screenMinY - (max_height + 32) >= dpi->y + dpi->height) return; session->SpritePosition.x = x; diff --git a/test/testpaint/Compat.cpp b/test/testpaint/Compat.cpp index d0a62db3bf..4bd8633928 100644 --- a/test/testpaint/Compat.cpp +++ b/test/testpaint/Compat.cpp @@ -894,3 +894,10 @@ namespace OpenRCT2 return nullptr; } } // namespace OpenRCT2 + +ScreenCoordsXY translate_3d_to_2d_with_z(int32_t rotation, const CoordsXYZ& pos) +{ + auto rotated = pos.Rotate(rotation); + // Use right shift to avoid issues like #9301 + return ScreenCoordsXY{ rotated.y - rotated.x, ((rotated.x + rotated.y) >> 1) - pos.z }; +} From 14c5f13b1830de7ee34e2e044d8b05025d370be3 Mon Sep 17 00:00:00 2001 From: OpenRCT2 git bot Date: Thu, 21 Oct 2021 04:08:57 +0000 Subject: [PATCH 6/7] Merge Localisation/master into OpenRCT2/develop --- data/language/nl-NL.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/language/nl-NL.txt b/data/language/nl-NL.txt index 52f2d18e6a..6387dec8b5 100644 --- a/data/language/nl-NL.txt +++ b/data/language/nl-NL.txt @@ -2899,7 +2899,7 @@ STR_5626 :Overige parken STR_5627 :Scenariolijst groeperen op: STR_5628 :Oorsprong STR_5629 :Moeilijkheidsgraad -STR_5630 :Moeilijke scenario’s ontgrendelden met gemakkelijke +STR_5630 :Moeilijke scenario’s ontgrendelden met makkelijke STR_5631 :Originele DLC STR_5632 :Bouw je eigen… STR_5633 :CMD + From dd2a140d1f13202fdaf2e053cc4f1dfeea6f043b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Thu, 21 Oct 2021 16:44:56 +0300 Subject: [PATCH 7/7] Apply review suggestions --- src/openrct2/world/ConstructionClearance.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/openrct2/world/ConstructionClearance.h b/src/openrct2/world/ConstructionClearance.h index 8b6800098e..2f02de9d72 100644 --- a/src/openrct2/world/ConstructionClearance.h +++ b/src/openrct2/world/ConstructionClearance.h @@ -10,12 +10,16 @@ #pragma once #include "../actions/GameActionResult.h" -#include "Location.hpp" +#include "../common.h" #include "Map.h" -#include "TileElement.h" #include +struct TileElement; +struct CoordsXY; +struct CoordsXYRangedZ; +class QuarterTile; + using CLEAR_FUNC = int32_t (*)(TileElement** tile_element, const CoordsXY& coords, uint8_t flags, money32* price); int32_t map_place_non_scenery_clear_func(TileElement** tile_element, const CoordsXY& coords, uint8_t flags, money32* price);