diff --git a/src/openrct2/actions/FootpathLayoutPlaceAction.cpp b/src/openrct2/actions/FootpathLayoutPlaceAction.cpp index 576c18bd2656..15b1d594e38b 100644 --- a/src/openrct2/actions/FootpathLayoutPlaceAction.cpp +++ b/src/openrct2/actions/FootpathLayoutPlaceAction.cpp @@ -154,8 +154,7 @@ GameActions::Result FootpathLayoutPlaceAction::ElementInsertQuery(GameActions::R // Do not attempt to build a crossing with a queue or a sloped path. auto isQueue = _constructFlags & PathConstructFlag::IsQueue; - uint8_t crossingMode = isQueue || (_slope != kTileSlopeFlat) ? CREATE_CROSSING_MODE_NONE - : CREATE_CROSSING_MODE_PATH_OVER_TRACK; + auto crossingMode = isQueue || (_slope != kTileSlopeFlat) ? CreateCrossingMode::none : CreateCrossingMode::pathOverTrack; auto canBuild = MapCanConstructWithClearAt( { _loc, zLow, zHigh }, &MapPlaceNonSceneryClearFunc, quarterTile, GetFlags(), crossingMode); if (!entrancePath && canBuild.Error != GameActions::Status::Ok) @@ -225,8 +224,7 @@ GameActions::Result FootpathLayoutPlaceAction::ElementInsertExecute(GameActions: // Do not attempt to build a crossing with a queue or a sloped path. auto isQueue = _constructFlags & PathConstructFlag::IsQueue; - uint8_t crossingMode = isQueue || (_slope != kTileSlopeFlat) ? CREATE_CROSSING_MODE_NONE - : CREATE_CROSSING_MODE_PATH_OVER_TRACK; + auto crossingMode = isQueue || (_slope != kTileSlopeFlat) ? CreateCrossingMode::none : CreateCrossingMode::pathOverTrack; auto canBuild = MapCanConstructWithClearAt( { _loc, zLow, zHigh }, &MapPlaceNonSceneryClearFunc, quarterTile, GAME_COMMAND_FLAG_APPLY | GetFlags(), crossingMode); if (!entrancePath && canBuild.Error != GameActions::Status::Ok) diff --git a/src/openrct2/actions/FootpathPlaceAction.cpp b/src/openrct2/actions/FootpathPlaceAction.cpp index a027d6d6ffa3..b661c0b515f3 100644 --- a/src/openrct2/actions/FootpathPlaceAction.cpp +++ b/src/openrct2/actions/FootpathPlaceAction.cpp @@ -303,8 +303,7 @@ GameActions::Result FootpathPlaceAction::ElementInsertQuery(GameActions::Result // Do not attempt to build a crossing with a queue or a sloped path. auto isQueue = _constructFlags & PathConstructFlag::IsQueue; - uint8_t crossingMode = isQueue || (_slope != kTileSlopeFlat) ? CREATE_CROSSING_MODE_NONE - : CREATE_CROSSING_MODE_PATH_OVER_TRACK; + auto crossingMode = isQueue || (_slope != kTileSlopeFlat) ? CreateCrossingMode::none : CreateCrossingMode::pathOverTrack; auto canBuild = MapCanConstructWithClearAt( { _loc, zLow, zHigh }, &MapPlaceNonSceneryClearFunc, quarterTile, GetFlags(), crossingMode); if (!entrancePath && canBuild.Error != GameActions::Status::Ok) @@ -373,8 +372,7 @@ GameActions::Result FootpathPlaceAction::ElementInsertExecute(GameActions::Resul // Do not attempt to build a crossing with a queue or a sloped. auto isQueue = _constructFlags & PathConstructFlag::IsQueue; - uint8_t crossingMode = isQueue || (_slope != kTileSlopeFlat) ? CREATE_CROSSING_MODE_NONE - : CREATE_CROSSING_MODE_PATH_OVER_TRACK; + auto crossingMode = isQueue || (_slope != kTileSlopeFlat) ? CreateCrossingMode::none : CreateCrossingMode::pathOverTrack; auto canBuild = MapCanConstructWithClearAt( { _loc, zLow, zHigh }, &MapPlaceNonSceneryClearFunc, quarterTile, GAME_COMMAND_FLAG_APPLY | GetFlags(), crossingMode); if (!entrancePath && canBuild.Error != GameActions::Status::Ok) diff --git a/src/openrct2/actions/LandSetHeightAction.cpp b/src/openrct2/actions/LandSetHeightAction.cpp index c8bb9d8f322d..5b7f07fe1ba8 100644 --- a/src/openrct2/actions/LandSetHeightAction.cpp +++ b/src/openrct2/actions/LandSetHeightAction.cpp @@ -139,7 +139,7 @@ GameActions::Result LandSetHeightAction::Query() const auto clearResult = MapCanConstructWithClearAt( { _coords, _height * COORDS_Z_STEP, zCorner * COORDS_Z_STEP }, &MapSetLandHeightClearFunc, { 0b1111, 0 }, 0, - CREATE_CROSSING_MODE_NONE); + CreateCrossingMode::none); if (clearResult.Error != GameActions::Status::Ok) { clearResult.Error = GameActions::Status::Disallowed; diff --git a/src/openrct2/actions/LargeSceneryPlaceAction.cpp b/src/openrct2/actions/LargeSceneryPlaceAction.cpp index 19a37fa4b010..cadc81488d46 100644 --- a/src/openrct2/actions/LargeSceneryPlaceAction.cpp +++ b/src/openrct2/actions/LargeSceneryPlaceAction.cpp @@ -135,7 +135,7 @@ GameActions::Result LargeSceneryPlaceAction::Query() const QuarterTile quarterTile = QuarterTile{ static_cast(tile->flags >> 12), 0 }.Rotate(_loc.direction); const auto isTree = (sceneryEntry->flags & LARGE_SCENERY_FLAG_IS_TREE) != 0; auto canBuild = MapCanConstructWithClearAt( - { curTile, zLow, zHigh }, &MapPlaceSceneryClearFunc, quarterTile, GetFlags(), CREATE_CROSSING_MODE_NONE, isTree); + { curTile, zLow, zHigh }, &MapPlaceSceneryClearFunc, quarterTile, GetFlags(), CreateCrossingMode::none, isTree); if (canBuild.Error != GameActions::Status::Ok) { canBuild.ErrorTitle = STR_CANT_POSITION_THIS_HERE; @@ -273,7 +273,7 @@ GameActions::Result LargeSceneryPlaceAction::Execute() const QuarterTile quarterTile = QuarterTile{ static_cast(tile->flags >> 12), 0 }.Rotate(_loc.direction); const auto isTree = (sceneryEntry->flags & LARGE_SCENERY_FLAG_IS_TREE) != 0; auto canBuild = MapCanConstructWithClearAt( - { curTile, zLow, zHigh }, &MapPlaceSceneryClearFunc, quarterTile, GetFlags(), CREATE_CROSSING_MODE_NONE, isTree); + { curTile, zLow, zHigh }, &MapPlaceSceneryClearFunc, quarterTile, GetFlags(), CreateCrossingMode::none, isTree); if (canBuild.Error != GameActions::Status::Ok) { if (banner != nullptr) diff --git a/src/openrct2/actions/SmallSceneryPlaceAction.cpp b/src/openrct2/actions/SmallSceneryPlaceAction.cpp index 03a379c03037..43e7316ec131 100644 --- a/src/openrct2/actions/SmallSceneryPlaceAction.cpp +++ b/src/openrct2/actions/SmallSceneryPlaceAction.cpp @@ -271,7 +271,7 @@ GameActions::Result SmallSceneryPlaceAction::Query() const QuarterTile quarterTile = QuarterTile{ collisionQuadrants, supports }.Rotate(quadRotation); const auto isTree = sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_IS_TREE); auto canBuild = MapCanConstructWithClearAt( - { _loc, zLow, zHigh }, &MapPlaceSceneryClearFunc, quarterTile, GetFlags(), CREATE_CROSSING_MODE_NONE, isTree); + { _loc, zLow, zHigh }, &MapPlaceSceneryClearFunc, quarterTile, GetFlags(), CreateCrossingMode::none, isTree); if (canBuild.Error != GameActions::Status::Ok) { canBuild.ErrorTitle = STR_CANT_POSITION_THIS_HERE; @@ -411,7 +411,7 @@ GameActions::Result SmallSceneryPlaceAction::Execute() const const auto isTree = sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_IS_TREE); auto canBuild = MapCanConstructWithClearAt( { _loc, zLow, zHigh }, &MapPlaceSceneryClearFunc, quarterTile, GetFlags() | GAME_COMMAND_FLAG_APPLY, - CREATE_CROSSING_MODE_NONE, isTree); + CreateCrossingMode::none, isTree); if (canBuild.Error != GameActions::Status::Ok) { canBuild.ErrorTitle = STR_CANT_POSITION_THIS_HERE; diff --git a/src/openrct2/actions/TrackPlaceAction.cpp b/src/openrct2/actions/TrackPlaceAction.cpp index 7e2d3f7c0aed..03bbddaff084 100644 --- a/src/openrct2/actions/TrackPlaceAction.cpp +++ b/src/openrct2/actions/TrackPlaceAction.cpp @@ -261,10 +261,10 @@ GameActions::Result TrackPlaceAction::Query() const GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_TOO_HIGH); } - uint8_t crossingMode = (ride->GetRideTypeDescriptor().HasFlag(RIDE_TYPE_FLAG_SUPPORTS_LEVEL_CROSSINGS) - && _trackType == TrackElemType::Flat) - ? CREATE_CROSSING_MODE_TRACK_OVER_PATH - : CREATE_CROSSING_MODE_NONE; + auto crossingMode = (ride->GetRideTypeDescriptor().HasFlag(RIDE_TYPE_FLAG_SUPPORTS_LEVEL_CROSSINGS) + && _trackType == TrackElemType::Flat) + ? CreateCrossingMode::trackOverPath + : CreateCrossingMode::none; auto canBuild = MapCanConstructWithClearAt( { mapLoc, baseZ, clearanceZ }, &MapPlaceNonSceneryClearFunc, quarterTile, GetFlags(), crossingMode); if (canBuild.Error != GameActions::Status::Ok) @@ -477,10 +477,10 @@ GameActions::Result TrackPlaceAction::Execute() const clearanceZ = Floor2(clearanceZ, COORDS_Z_STEP) + baseZ; const auto mapLocWithClearance = CoordsXYRangedZ(mapLoc, baseZ, clearanceZ); - uint8_t crossingMode = (ride->GetRideTypeDescriptor().HasFlag(RIDE_TYPE_FLAG_SUPPORTS_LEVEL_CROSSINGS) - && _trackType == TrackElemType::Flat) - ? CREATE_CROSSING_MODE_TRACK_OVER_PATH - : CREATE_CROSSING_MODE_NONE; + auto crossingMode = (ride->GetRideTypeDescriptor().HasFlag(RIDE_TYPE_FLAG_SUPPORTS_LEVEL_CROSSINGS) + && _trackType == TrackElemType::Flat) + ? CreateCrossingMode::trackOverPath + : CreateCrossingMode::none; auto canBuild = MapCanConstructWithClearAt( mapLocWithClearance, &MapPlaceNonSceneryClearFunc, quarterTile, GetFlags() | GAME_COMMAND_FLAG_APPLY, crossingMode); if (canBuild.Error != GameActions::Status::Ok) @@ -491,7 +491,7 @@ GameActions::Result TrackPlaceAction::Execute() const costs += canBuild.Cost; // When building a level crossing, remove any pre-existing path furniture. - if (crossingMode == CREATE_CROSSING_MODE_TRACK_OVER_PATH && !(GetFlags() & GAME_COMMAND_FLAG_GHOST)) + if (crossingMode == CreateCrossingMode::trackOverPath && !(GetFlags() & GAME_COMMAND_FLAG_GHOST)) { auto footpathElement = MapGetFootpathElement(mapLoc); if (footpathElement != nullptr && footpathElement->HasAddition()) diff --git a/src/openrct2/world/ConstructionClearance.cpp b/src/openrct2/world/ConstructionClearance.cpp index b5b07f8dab95..65f8b5337f51 100644 --- a/src/openrct2/world/ConstructionClearance.cpp +++ b/src/openrct2/world/ConstructionClearance.cpp @@ -80,7 +80,7 @@ int32_t MapPlaceNonSceneryClearFunc(TileElement** tile_element, const CoordsXY& static bool MapLoc68BABCShouldContinue( TileElement** tileElementPtr, const CoordsXYRangedZ& pos, CLEAR_FUNC clearFunc, uint8_t flags, money64& price, - uint8_t crossingMode, bool canBuildCrossing) + CreateCrossingMode crossingMode, bool canBuildCrossing) { if (clearFunc != nullptr) { @@ -90,17 +90,16 @@ static bool MapLoc68BABCShouldContinue( } } - // Crossing mode 1: building track over path auto tileElement = *tileElementPtr; - if (crossingMode == 1 && canBuildCrossing && tileElement->GetType() == TileElementType::Path + if (crossingMode == CreateCrossingMode::trackOverPath && canBuildCrossing && tileElement->GetType() == TileElementType::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() == TileElementType::Track - && tileElement->GetBaseZ() == pos.baseZ && tileElement->AsTrack()->GetTrackType() == TrackElemType::Flat) + crossingMode == CreateCrossingMode::pathOverTrack && canBuildCrossing + && tileElement->GetType() == TileElementType::Track && tileElement->GetBaseZ() == pos.baseZ + && tileElement->AsTrack()->GetTrackType() == TrackElemType::Flat) { auto ride = GetRide(tileElement->AsTrack()->GetRideIndex()); if (ride != nullptr && ride->GetRideTypeDescriptor().HasFlag(RIDE_TYPE_FLAG_SUPPORTS_LEVEL_CROSSINGS)) @@ -123,7 +122,8 @@ static bool MapLoc68BABCShouldContinue( * bl = bl */ GameActions::Result MapCanConstructWithClearAt( - const CoordsXYRangedZ& pos, CLEAR_FUNC clearFunc, QuarterTile quarterTile, uint8_t flags, uint8_t crossingMode, bool isTree) + const CoordsXYRangedZ& pos, CLEAR_FUNC clearFunc, QuarterTile quarterTile, uint8_t flags, CreateCrossingMode crossingMode, + bool isTree) { auto res = GameActions::Result(); diff --git a/src/openrct2/world/ConstructionClearance.h b/src/openrct2/world/ConstructionClearance.h index 241a590c143d..d7b0c62a68c1 100644 --- a/src/openrct2/world/ConstructionClearance.h +++ b/src/openrct2/world/ConstructionClearance.h @@ -22,6 +22,16 @@ class QuarterTile; using CLEAR_FUNC = int32_t (*)(TileElement** tile_element, const CoordsXY& coords, uint8_t flags, money64* price); +// Used when calling MapCanConstructWithClearAt(); +// This assumes that the caller has already done the check on the element it wants to place, +// as this function can only check the element the player wants to build through. +enum class CreateCrossingMode +{ + none, + trackOverPath, + pathOverTrack, +}; + int32_t MapPlaceNonSceneryClearFunc(TileElement** tile_element, const CoordsXY& coords, uint8_t flags, money64* price); int32_t MapPlaceSceneryClearFunc(TileElement** tile_element, const CoordsXY& coords, uint8_t flags, money64* price); @@ -32,7 +42,7 @@ struct ConstructClearResult [[nodiscard]] GameActions::Result MapCanConstructWithClearAt( const CoordsXYRangedZ& pos, CLEAR_FUNC clearFunc, QuarterTile quarterTile, uint8_t flags, - uint8_t crossingMode = CREATE_CROSSING_MODE_NONE, bool isTree = false); + CreateCrossingMode crossingMode = CreateCrossingMode::none, bool isTree = false); [[nodiscard]] GameActions::Result MapCanConstructAt(const CoordsXYRangedZ& pos, QuarterTile bl); diff --git a/src/openrct2/world/Map.h b/src/openrct2/world/Map.h index 8b4ccafb0e91..ab9ac02c85fd 100644 --- a/src/openrct2/world/Map.h +++ b/src/openrct2/world/Map.h @@ -91,16 +91,6 @@ enum MAP_SELECT_TYPE_EDGE_3, }; -// Used when calling MapCanConstructWithClearAt(); -// This assumes that the caller has already done the check on the element it wants to place, -// as this function can only check the element the player wants to build through. -enum -{ - CREATE_CROSSING_MODE_NONE, - CREATE_CROSSING_MODE_TRACK_OVER_PATH, - CREATE_CROSSING_MODE_PATH_OVER_TRACK, -}; - extern const std::array CoordsDirectionDelta; extern const TileCoordsXY TileDirectionDelta[];