From 31239e39413f9e0dfa770b133c9a7bf0bc577752 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 19:17:03 +0300 Subject: [PATCH 1/2] Refactor result passing on ConstructClearResult --- src/openrct2/actions/FootpathPlaceAction.cpp | 9 ++++++--- .../actions/FootpathPlaceFromTrackAction.cpp | 10 +++++++--- src/openrct2/actions/GameActionResult.h | 6 ------ .../actions/LargeSceneryPlaceAction.cpp | 9 ++++++--- src/openrct2/actions/MazePlaceTrackAction.cpp | 5 +++-- src/openrct2/actions/MazeSetTrackAction.cpp | 5 +++-- .../actions/RideEntranceExitPlaceAction.cpp | 6 ++++-- .../actions/SmallSceneryPlaceAction.cpp | 6 ++++-- src/openrct2/actions/TrackPlaceAction.cpp | 10 ++++++---- src/openrct2/world/ConstructionClearance.cpp | 17 ++++++++++------- src/openrct2/world/ConstructionClearance.h | 9 +++++++-- 11 files changed, 56 insertions(+), 36 deletions(-) diff --git a/src/openrct2/actions/FootpathPlaceAction.cpp b/src/openrct2/actions/FootpathPlaceAction.cpp index b83e5062f7..20374cff65 100644 --- a/src/openrct2/actions/FootpathPlaceAction.cpp +++ b/src/openrct2/actions/FootpathPlaceAction.cpp @@ -308,8 +308,10 @@ GameActions::Result::Ptr FootpathPlaceAction::ElementInsertQuery(GameActions::Re } res->Cost += canBuild->Cost; - gFootpathGroundFlags = canBuild->GroundFlags; - if (!gCheatsDisableClearanceChecks && (canBuild->GroundFlags & ELEMENT_IS_UNDERWATER)) + const auto clearanceData = canBuild->GetData(); + + gFootpathGroundFlags = clearanceData.GroundFlags; + if (!gCheatsDisableClearanceChecks && (clearanceData.GroundFlags & ELEMENT_IS_UNDERWATER)) { return MakeResult(GameActions::Status::Disallowed, STR_CANT_BUILD_FOOTPATH_HERE, STR_CANT_BUILD_THIS_UNDERWATER); } @@ -375,7 +377,8 @@ GameActions::Result::Ptr FootpathPlaceAction::ElementInsertExecute(GameActions:: } res->Cost += canBuild->Cost; - gFootpathGroundFlags = canBuild->GroundFlags; + const auto clearanceData = canBuild->GetData(); + gFootpathGroundFlags = clearanceData.GroundFlags; auto surfaceElement = map_get_surface_element_at(_loc); if (surfaceElement == nullptr) diff --git a/src/openrct2/actions/FootpathPlaceFromTrackAction.cpp b/src/openrct2/actions/FootpathPlaceFromTrackAction.cpp index 295e05e166..e10498e574 100644 --- a/src/openrct2/actions/FootpathPlaceFromTrackAction.cpp +++ b/src/openrct2/actions/FootpathPlaceFromTrackAction.cpp @@ -145,9 +145,11 @@ GameActions::Result::Ptr FootpathPlaceFromTrackAction::ElementInsertQuery(GameAc return canBuild; } res->Cost += canBuild->Cost; - gFootpathGroundFlags = canBuild->GroundFlags; - if (!gCheatsDisableClearanceChecks && (canBuild->GroundFlags & ELEMENT_IS_UNDERWATER)) + const auto clearanceData = canBuild->GetData(); + gFootpathGroundFlags = clearanceData.GroundFlags; + + if (!gCheatsDisableClearanceChecks && (clearanceData.GroundFlags & ELEMENT_IS_UNDERWATER)) { return MakeResult( GameActions::Status::Disallowed, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_CANT_BUILD_THIS_UNDERWATER); @@ -213,7 +215,9 @@ GameActions::Result::Ptr FootpathPlaceFromTrackAction::ElementInsertExecute(Game return canBuild; } res->Cost += canBuild->Cost; - gFootpathGroundFlags = canBuild->GroundFlags; + + const auto clearanceData = canBuild->GetData(); + gFootpathGroundFlags = clearanceData.GroundFlags; auto surfaceElement = map_get_surface_element_at(_loc); if (surfaceElement == nullptr) diff --git a/src/openrct2/actions/GameActionResult.h b/src/openrct2/actions/GameActionResult.h index e50e756ba7..41afbf97fa 100644 --- a/src/openrct2/actions/GameActionResult.h +++ b/src/openrct2/actions/GameActionResult.h @@ -101,10 +101,4 @@ namespace GameActions # pragma GCC diagnostic pop #endif - class ConstructClearResult final : public Result - { - public: - uint8_t GroundFlags{ 0 }; - }; - } // namespace GameActions diff --git a/src/openrct2/actions/LargeSceneryPlaceAction.cpp b/src/openrct2/actions/LargeSceneryPlaceAction.cpp index 8fc746df28..b82c43b4e8 100644 --- a/src/openrct2/actions/LargeSceneryPlaceAction.cpp +++ b/src/openrct2/actions/LargeSceneryPlaceAction.cpp @@ -125,10 +125,11 @@ GameActions::Result::Ptr LargeSceneryPlaceAction::Query() const supportsCost += canBuild->Cost; - int32_t tempSceneryGroundFlags = canBuild->GroundFlags & (ELEMENT_IS_ABOVE_GROUND | ELEMENT_IS_UNDERGROUND); + const auto clearanceData = canBuild->GetData(); + int32_t tempSceneryGroundFlags = clearanceData.GroundFlags & (ELEMENT_IS_ABOVE_GROUND | ELEMENT_IS_UNDERGROUND); if (!gCheatsDisableClearanceChecks) { - if ((canBuild->GroundFlags & ELEMENT_IS_UNDERWATER) || (canBuild->GroundFlags & ELEMENT_IS_UNDERGROUND)) + if ((clearanceData.GroundFlags & ELEMENT_IS_UNDERWATER) || (clearanceData.GroundFlags & ELEMENT_IS_UNDERGROUND)) { return MakeResult(GameActions::Status::Disallowed, STR_CANT_POSITION_THIS_HERE, STR_CANT_BUILD_THIS_UNDERWATER); } @@ -261,7 +262,9 @@ GameActions::Result::Ptr LargeSceneryPlaceAction::Execute() const } supportsCost += canBuild->Cost; - resultData.GroundFlags = canBuild->GroundFlags & (ELEMENT_IS_ABOVE_GROUND | ELEMENT_IS_UNDERGROUND); + + const auto clearanceData = canBuild->GetData(); + resultData.GroundFlags = clearanceData.GroundFlags & (ELEMENT_IS_ABOVE_GROUND | ELEMENT_IS_UNDERGROUND); if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST)) { diff --git a/src/openrct2/actions/MazePlaceTrackAction.cpp b/src/openrct2/actions/MazePlaceTrackAction.cpp index ed7da150e9..2515746381 100644 --- a/src/openrct2/actions/MazePlaceTrackAction.cpp +++ b/src/openrct2/actions/MazePlaceTrackAction.cpp @@ -94,14 +94,15 @@ GameActions::Result::Ptr MazePlaceTrackAction::Query() const return canBuild; } - if (canBuild->GroundFlags & ELEMENT_IS_UNDERWATER) + const auto clearanceData = canBuild->GetData(); + if (clearanceData.GroundFlags & ELEMENT_IS_UNDERWATER) { res->Error = GameActions::Status::NoClearance; res->ErrorMessage = STR_RIDE_CANT_BUILD_THIS_UNDERWATER; return res; } - if (canBuild->GroundFlags & ELEMENT_IS_UNDERGROUND) + if (clearanceData.GroundFlags & ELEMENT_IS_UNDERGROUND) { res->Error = GameActions::Status::NoClearance; res->ErrorMessage = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; diff --git a/src/openrct2/actions/MazeSetTrackAction.cpp b/src/openrct2/actions/MazeSetTrackAction.cpp index 8f47f6eb49..c9376787e0 100644 --- a/src/openrct2/actions/MazeSetTrackAction.cpp +++ b/src/openrct2/actions/MazeSetTrackAction.cpp @@ -114,14 +114,15 @@ GameActions::Result::Ptr MazeSetTrackAction::Query() const return constructResult; } - if (constructResult->GroundFlags & ELEMENT_IS_UNDERWATER) + const auto clearanceData = constructResult->GetData(); + if (clearanceData.GroundFlags & ELEMENT_IS_UNDERWATER) { res->Error = GameActions::Status::NoClearance; res->ErrorMessage = STR_RIDE_CANT_BUILD_THIS_UNDERWATER; return res; } - if (constructResult->GroundFlags & ELEMENT_IS_UNDERGROUND) + if (clearanceData.GroundFlags & ELEMENT_IS_UNDERGROUND) { res->Error = GameActions::Status::NoClearance; res->ErrorMessage = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; diff --git a/src/openrct2/actions/RideEntranceExitPlaceAction.cpp b/src/openrct2/actions/RideEntranceExitPlaceAction.cpp index c98366ea6a..7b8bc2cbed 100644 --- a/src/openrct2/actions/RideEntranceExitPlaceAction.cpp +++ b/src/openrct2/actions/RideEntranceExitPlaceAction.cpp @@ -108,7 +108,8 @@ GameActions::Result::Ptr RideEntranceExitPlaceAction::Query() const return canBuild; } - if (canBuild->GroundFlags & ELEMENT_IS_UNDERWATER) + const auto clearanceData = canBuild->GetData(); + if (clearanceData.GroundFlags & ELEMENT_IS_UNDERWATER) { return MakeResult(GameActions::Status::Disallowed, errorTitle, STR_RIDE_CANT_BUILD_THIS_UNDERWATER); } @@ -237,7 +238,8 @@ GameActions::Result::Ptr RideEntranceExitPlaceAction::TrackPlaceQuery(const Coor return canBuild; } - if (canBuild->GroundFlags & ELEMENT_IS_UNDERWATER) + const auto clearanceData = canBuild->GetData(); + if (clearanceData.GroundFlags & ELEMENT_IS_UNDERWATER) { return MakeResult(GameActions::Status::Disallowed, errorTitle, STR_RIDE_CANT_BUILD_THIS_UNDERWATER); } diff --git a/src/openrct2/actions/SmallSceneryPlaceAction.cpp b/src/openrct2/actions/SmallSceneryPlaceAction.cpp index 92a819ec11..bc6dfec98e 100644 --- a/src/openrct2/actions/SmallSceneryPlaceAction.cpp +++ b/src/openrct2/actions/SmallSceneryPlaceAction.cpp @@ -258,7 +258,8 @@ GameActions::Result::Ptr SmallSceneryPlaceAction::Query() const return canBuild; } - const uint8_t groundFlags = canBuild->GroundFlags & (ELEMENT_IS_ABOVE_GROUND | ELEMENT_IS_UNDERGROUND); + const auto clearanceData = canBuild->GetData(); + const uint8_t groundFlags = clearanceData.GroundFlags & (ELEMENT_IS_ABOVE_GROUND | ELEMENT_IS_UNDERGROUND); res->SetData(SmallSceneryPlaceActionResult{ groundFlags, 0, 0 }); res->Expenditure = ExpenditureType::Landscaping; @@ -418,7 +419,8 @@ GameActions::Result::Ptr SmallSceneryPlaceAction::Execute() const sceneryElement->SetNeedsSupports(); } - const uint8_t groundFlags = canBuild->GroundFlags & (ELEMENT_IS_ABOVE_GROUND | ELEMENT_IS_UNDERGROUND); + const auto clearanceData = canBuild->GetData(); + const uint8_t groundFlags = clearanceData.GroundFlags & (ELEMENT_IS_ABOVE_GROUND | ELEMENT_IS_UNDERGROUND); res->SetData( SmallSceneryPlaceActionResult{ groundFlags, sceneryElement->GetBaseZ(), sceneryElement->GetSceneryQuadrant() }); diff --git a/src/openrct2/actions/TrackPlaceAction.cpp b/src/openrct2/actions/TrackPlaceAction.cpp index e8ad36a7c0..8f5a6eb1cd 100644 --- a/src/openrct2/actions/TrackPlaceAction.cpp +++ b/src/openrct2/actions/TrackPlaceAction.cpp @@ -251,7 +251,8 @@ GameActions::Result::Ptr TrackPlaceAction::Query() const } } - uint8_t mapGroundFlags = canBuild->GroundFlags & (ELEMENT_IS_ABOVE_GROUND | ELEMENT_IS_UNDERGROUND); + const auto clearanceData = canBuild->GetData(); + uint8_t mapGroundFlags = clearanceData.GroundFlags & (ELEMENT_IS_ABOVE_GROUND | ELEMENT_IS_UNDERGROUND); if (resultData.GroundFlags != 0 && (resultData.GroundFlags & mapGroundFlags) == 0) { return MakeResult( @@ -272,7 +273,7 @@ GameActions::Result::Ptr TrackPlaceAction::Query() const if (ted.Flags & TRACK_ELEM_FLAG_ONLY_UNDERWATER) { // No element has this flag - if (canBuild->GroundFlags & ELEMENT_IS_UNDERWATER) + if (clearanceData.GroundFlags & ELEMENT_IS_UNDERWATER) { return MakeResult( GameActions::Status::Disallowed, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, @@ -280,7 +281,7 @@ GameActions::Result::Ptr TrackPlaceAction::Query() const } } - if (canBuild->GroundFlags & ELEMENT_IS_UNDERWATER && !gCheatsDisableClearanceChecks) + if (clearanceData.GroundFlags & ELEMENT_IS_UNDERWATER && !gCheatsDisableClearanceChecks) { return MakeResult( GameActions::Status::Disallowed, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, @@ -476,7 +477,8 @@ GameActions::Result::Ptr TrackPlaceAction::Execute() const } } - uint8_t mapGroundFlags = canBuild->GroundFlags & (ELEMENT_IS_ABOVE_GROUND | ELEMENT_IS_UNDERGROUND); + const auto clearanceData = canBuild->GetData(); + uint8_t mapGroundFlags = clearanceData.GroundFlags & (ELEMENT_IS_ABOVE_GROUND | ELEMENT_IS_UNDERGROUND); if (resultData.GroundFlags != 0 && (resultData.GroundFlags & mapGroundFlags) == 0) { return MakeResult( diff --git a/src/openrct2/world/ConstructionClearance.cpp b/src/openrct2/world/ConstructionClearance.cpp index af78a35a25..c25d21448a 100644 --- a/src/openrct2/world/ConstructionClearance.cpp +++ b/src/openrct2/world/ConstructionClearance.cpp @@ -113,15 +113,15 @@ static bool MapLoc68BABCShouldContinue( * ebp = clearFunc * bl = bl */ -std::unique_ptr MapCanConstructWithClearAt( +GameActions::Result::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(); + auto res = std::make_unique(); uint8_t slope = 0; - res->GroundFlags = ELEMENT_IS_ABOVE_GROUND; + uint8_t groundFlags = ELEMENT_IS_ABOVE_GROUND; bool canBuildCrossing = false; if (map_is_edge(pos)) { @@ -170,7 +170,7 @@ std::unique_ptr MapCanConstructWithClearAt( water_height = tileElement->AsSurface()->GetWaterHeight(); if (water_height && water_height > pos.baseZ && tileElement->GetBaseZ() < pos.clearanceZ) { - res->GroundFlags |= ELEMENT_IS_UNDERWATER; + groundFlags |= ELEMENT_IS_UNDERWATER; if (water_height < pos.clearanceZ) { bool returnError = true; @@ -217,8 +217,8 @@ std::unique_ptr MapCanConstructWithClearAt( if (tileElement->GetBaseZ() >= pos.clearanceZ) { // loc_68BA81 - res->GroundFlags |= ELEMENT_IS_UNDERGROUND; - res->GroundFlags &= ~ELEMENT_IS_ABOVE_GROUND; + groundFlags |= ELEMENT_IS_UNDERGROUND; + groundFlags &= ~ELEMENT_IS_ABOVE_GROUND; } else { @@ -278,10 +278,13 @@ std::unique_ptr MapCanConstructWithClearAt( } } } while (!(tileElement++)->IsLastForTile()); + + res->SetData(ConstructClearResult{ groundFlags }); + return res; } -std::unique_ptr MapCanConstructAt(const CoordsXYRangedZ& pos, QuarterTile bl) +GameActions::Result::Ptr MapCanConstructAt(const CoordsXYRangedZ& pos, QuarterTile bl) { return MapCanConstructWithClearAt(pos, nullptr, bl, 0); } diff --git a/src/openrct2/world/ConstructionClearance.h b/src/openrct2/world/ConstructionClearance.h index 2f02de9d72..557bada5b5 100644 --- a/src/openrct2/world/ConstructionClearance.h +++ b/src/openrct2/world/ConstructionClearance.h @@ -25,10 +25,15 @@ using CLEAR_FUNC = int32_t (*)(TileElement** tile_element, const CoordsXY& coord 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( +struct ConstructClearResult +{ + uint8_t GroundFlags{ 0 }; +}; + +[[nodiscard]] GameActions::Result::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); +[[nodiscard]] GameActions::Result::Ptr MapCanConstructAt(const CoordsXYRangedZ& pos, QuarterTile bl); void map_obstruction_set_error_text(TileElement* tileElement, GameActions::Result& res); From bdc439351767dbae8491676161b21e3996b33437 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Mon, 25 Oct 2021 16:14:31 +0300 Subject: [PATCH 2/2] Cleanup MapCanConstructWithClearAt --- src/openrct2/world/ConstructionClearance.cpp | 73 ++++++++------------ 1 file changed, 27 insertions(+), 46 deletions(-) diff --git a/src/openrct2/world/ConstructionClearance.cpp b/src/openrct2/world/ConstructionClearance.cpp index c25d21448a..b573d62664 100644 --- a/src/openrct2/world/ConstructionClearance.cpp +++ b/src/openrct2/world/ConstructionClearance.cpp @@ -116,10 +116,7 @@ static bool MapLoc68BABCShouldContinue( GameActions::Result::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; uint8_t groundFlags = ELEMENT_IS_ABOVE_GROUND; bool canBuildCrossing = false; @@ -132,6 +129,7 @@ GameActions::Result::Ptr MapCanConstructWithClearAt( if (gCheatsDisableClearanceChecks) { + res->SetData(ConstructClearResult{ groundFlags }); return res; } @@ -142,6 +140,7 @@ GameActions::Result::Ptr MapCanConstructWithClearAt( res->ErrorMessage = STR_NONE; return res; } + do { if (tileElement->GetType() != TILE_ELEMENT_TYPE_SURFACE) @@ -157,37 +156,24 @@ GameActions::Result::Ptr MapCanConstructWithClearAt( continue; } - if (tileElement != nullptr) - { - map_obstruction_set_error_text(tileElement, *res); - res->Error = GameActions::Status::NoClearance; - } + 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) + + const auto waterHeight = tileElement->AsSurface()->GetWaterHeight(); + if (waterHeight && waterHeight > pos.baseZ && tileElement->GetBaseZ() < pos.clearanceZ) { groundFlags |= ELEMENT_IS_UNDERWATER; - if (water_height < pos.clearanceZ) + if (waterHeight < pos.clearanceZ) { - bool returnError = true; - if (clearFunc != nullptr) + if (clearFunc != nullptr && clearFunc(&tileElement, pos, flags, &res->Cost)) { - 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; - } + res->Error = GameActions::Status::NoClearance; + res->ErrorMessage = STR_CANNOT_BUILD_PARTLY_ABOVE_AND_PARTLY_BELOW_WATER; return res; } } @@ -195,7 +181,7 @@ GameActions::Result::Ptr MapCanConstructWithClearAt( if (gParkFlags & PARK_FLAGS_FORBID_HIGH_CONSTRUCTION && !isTree) { - auto heightFromGround = pos.clearanceZ - tileElement->GetBaseZ(); + const auto heightFromGround = pos.clearanceZ - tileElement->GetBaseZ(); if (heightFromGround > (18 * COORDS_Z_STEP)) { @@ -222,11 +208,11 @@ GameActions::Result::Ptr MapCanConstructWithClearAt( } else { - northZ = tileElement->GetBaseZ(); - eastZ = northZ; - southZ = northZ; - westZ = northZ; - slope = tileElement->AsSurface()->GetSlope(); + auto northZ = tileElement->GetBaseZ(); + auto eastZ = northZ; + auto southZ = northZ; + auto westZ = northZ; + const auto slope = tileElement->AsSurface()->GetSlope(); if (slope & TILE_ELEMENT_SLOPE_N_CORNER_UP) { northZ += LAND_HEIGHT_STEP; @@ -251,17 +237,15 @@ GameActions::Result::Ptr MapCanConstructWithClearAt( if (slope == (TILE_ELEMENT_SLOPE_E_CORNER_DN | TILE_ELEMENT_SLOPE_DOUBLE_HEIGHT)) westZ += LAND_HEIGHT_STEP; } - baseHeight = pos.baseZ + (4 * COORDS_Z_STEP); + const auto baseHeight = pos.baseZ + (4 * COORDS_Z_STEP); + const auto baseQuarter = quarterTile.GetBaseQuarterOccupied(); + const 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))) { - 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; - } + continue; } if (MapLoc68BABCShouldContinue(tileElement, pos, clearFunc, flags, res->Cost, crossingMode, canBuildCrossing)) @@ -269,11 +253,8 @@ GameActions::Result::Ptr MapCanConstructWithClearAt( continue; } - if (tileElement != nullptr) - { - map_obstruction_set_error_text(tileElement, *res); - res->Error = GameActions::Status::NoClearance; - } + map_obstruction_set_error_text(tileElement, *res); + res->Error = GameActions::Status::NoClearance; return res; } }