From 9ed5c6385724bae0c42ffe97173bcfa473943076 Mon Sep 17 00:00:00 2001 From: mrmbernardi Date: Fri, 26 Jul 2024 18:23:25 +1000 Subject: [PATCH] Rename Location.hpp constants (#22385) --- .../interface/ViewportInteraction.cpp | 2 +- src/openrct2-ui/ride/VehicleSounds.cpp | 4 +- src/openrct2-ui/windows/Footpath.cpp | 2 +- src/openrct2-ui/windows/Guest.cpp | 2 +- src/openrct2-ui/windows/LandRights.cpp | 8 +- src/openrct2-ui/windows/Map.cpp | 24 +++--- src/openrct2-ui/windows/RideConstruction.cpp | 10 +-- src/openrct2-ui/windows/Staff.cpp | 2 +- src/openrct2-ui/windows/StaffList.cpp | 2 +- src/openrct2-ui/windows/TopToolbar.cpp | 16 ++-- src/openrct2-ui/windows/TrackDesignPlace.cpp | 4 +- src/openrct2/Editor.cpp | 4 +- src/openrct2/actions/BannerPlaceAction.cpp | 2 +- src/openrct2/actions/CheatSetAction.cpp | 8 +- src/openrct2/actions/ClearAction.cpp | 4 +- src/openrct2/actions/FootpathPlaceAction.cpp | 12 +-- src/openrct2/actions/GameActionResult.h | 2 +- src/openrct2/actions/LandBuyRightsAction.cpp | 4 +- src/openrct2/actions/LandLowerAction.cpp | 4 +- src/openrct2/actions/LandRaiseAction.cpp | 4 +- src/openrct2/actions/LandSetHeightAction.cpp | 6 +- src/openrct2/actions/LandSetRightsAction.cpp | 4 +- src/openrct2/actions/LandSmoothAction.cpp | 4 +- src/openrct2/actions/MazePlaceTrackAction.cpp | 2 +- src/openrct2/actions/MazeSetTrackAction.cpp | 2 +- .../actions/ParkEntrancePlaceAction.cpp | 12 +-- .../actions/SmallSceneryPlaceAction.cpp | 2 +- .../actions/StaffSetPatrolAreaAction.cpp | 4 +- .../actions/SurfaceSetStyleAction.cpp | 8 +- src/openrct2/actions/TrackPlaceAction.cpp | 18 ++--- src/openrct2/actions/WallPlaceAction.cpp | 4 +- src/openrct2/actions/WaterLowerAction.cpp | 12 +-- src/openrct2/actions/WaterRaiseAction.cpp | 14 ++-- src/openrct2/actions/WaterSetHeightAction.cpp | 8 +- src/openrct2/drawing/LightFX.cpp | 2 +- src/openrct2/entity/Balloon.cpp | 2 +- src/openrct2/entity/EntityBase.cpp | 2 +- src/openrct2/entity/EntityRegistry.cpp | 16 ++-- src/openrct2/entity/Fountain.cpp | 28 +++---- src/openrct2/entity/Guest.cpp | 76 +++++++++---------- src/openrct2/entity/Peep.cpp | 10 +-- src/openrct2/entity/Peep.h | 2 +- src/openrct2/entity/Staff.cpp | 26 +++---- src/openrct2/interface/InteractiveConsole.cpp | 6 +- src/openrct2/interface/Screenshot.cpp | 6 +- src/openrct2/interface/Viewport.cpp | 6 +- src/openrct2/management/NewsItem.cpp | 2 +- src/openrct2/network/NetworkBase.cpp | 2 +- src/openrct2/network/NetworkPlayer.h | 2 +- src/openrct2/paint/Paint.Entity.cpp | 6 +- src/openrct2/paint/Paint.cpp | 4 +- src/openrct2/paint/VirtualFloor.cpp | 8 +- src/openrct2/paint/support/MetalSupports.cpp | 4 +- .../paint/tile_element/Paint.Path.cpp | 2 +- .../paint/tile_element/Paint.Surface.cpp | 32 ++++---- .../paint/tile_element/Paint.TileElement.cpp | 10 +-- src/openrct2/peep/GuestPathfinding.cpp | 4 +- src/openrct2/rct1/S4Importer.cpp | 3 +- src/openrct2/rct2/S6Importer.cpp | 13 ++-- src/openrct2/ride/CableLift.cpp | 2 +- src/openrct2/ride/Ride.cpp | 14 ++-- src/openrct2/ride/Ride.h | 4 +- src/openrct2/ride/RideConstruction.cpp | 8 +- src/openrct2/ride/RideData.h | 14 ++-- src/openrct2/ride/RideRatings.cpp | 4 +- src/openrct2/ride/Station.cpp | 4 +- src/openrct2/ride/Track.cpp | 6 +- src/openrct2/ride/Track.h | 2 +- src/openrct2/ride/TrackDesign.cpp | 22 +++--- src/openrct2/ride/Vehicle.cpp | 46 +++++------ src/openrct2/ride/VehicleSubpositionData.cpp | 6 +- src/openrct2/ride/gentle/Maze.cpp | 2 +- .../scripting/bindings/entity/ScStaff.cpp | 4 +- .../scripting/bindings/world/ScPark.cpp | 2 +- .../scripting/bindings/world/ScTile.cpp | 4 +- src/openrct2/world/Banner.cpp | 18 ++--- src/openrct2/world/ConstructionClearance.cpp | 4 +- src/openrct2/world/Entrance.h | 8 +- src/openrct2/world/Footpath.cpp | 4 +- src/openrct2/world/Footpath.h | 8 +- src/openrct2/world/Location.hpp | 44 +++++------ src/openrct2/world/Map.cpp | 46 +++++------ src/openrct2/world/Map.h | 12 +-- src/openrct2/world/MapGen.cpp | 14 ++-- src/openrct2/world/Park.cpp | 16 ++-- src/openrct2/world/TileElementBase.cpp | 8 +- src/openrct2/world/TileInspector.cpp | 8 +- 87 files changed, 413 insertions(+), 415 deletions(-) diff --git a/src/openrct2-ui/interface/ViewportInteraction.cpp b/src/openrct2-ui/interface/ViewportInteraction.cpp index d1946bf489..4a44fb10b9 100644 --- a/src/openrct2-ui/interface/ViewportInteraction.cpp +++ b/src/openrct2-ui/interface/ViewportInteraction.cpp @@ -723,7 +723,7 @@ static PeepDistance GetClosestPeep( { for (auto peep : EntityList()) { - if (peep->x == LOCATION_NULL) + if (peep->x == kLocationNull) continue; auto screenCoords = Translate3DTo2DWithZ(rotation, peep->GetLocation()); diff --git a/src/openrct2-ui/ride/VehicleSounds.cpp b/src/openrct2-ui/ride/VehicleSounds.cpp index 5b05dc43cb..a12152fac4 100644 --- a/src/openrct2-ui/ride/VehicleSounds.cpp +++ b/src/openrct2-ui/ride/VehicleSounds.cpp @@ -107,7 +107,7 @@ namespace OpenRCT2::Audio if (vehicle.sound1_id == SoundId::Null && vehicle.sound2_id == SoundId::Null) return false; - if (vehicle.x == LOCATION_NULL) + if (vehicle.x == kLocationNull) return false; if (g_music_tracking_viewport == nullptr) @@ -213,7 +213,7 @@ namespace OpenRCT2::Audio param.id = vehicle.Id.ToUnderlying(); param.volume = 0; - if (vehicle.x != LOCATION_NULL) + if (vehicle.x != kLocationNull) { auto surfaceElement = MapGetSurfaceElementAt(CoordsXY{ vehicle.x, vehicle.y }); diff --git a/src/openrct2-ui/windows/Footpath.cpp b/src/openrct2-ui/windows/Footpath.cpp index deb9cc92bb..d54ea6d080 100644 --- a/src/openrct2-ui/windows/Footpath.cpp +++ b/src/openrct2-ui/windows/Footpath.cpp @@ -1145,7 +1145,7 @@ static constexpr uint8_t ConstructionPreviewImages[][4] = { return nullptr; } - z = std::min(255 * COORDS_Z_STEP, gFootpathConstructFromPosition.z); + z = std::min(255 * kCoordsZStep, gFootpathConstructFromPosition.z); zLow = z - PATH_HEIGHT_STEP; tileElement = MapGetFirstElementAt(gFootpathConstructFromPosition); diff --git a/src/openrct2-ui/windows/Guest.cpp b/src/openrct2-ui/windows/Guest.cpp index 04c2dfcff1..840ec7df94 100644 --- a/src/openrct2-ui/windows/Guest.cpp +++ b/src/openrct2-ui/windows/Guest.cpp @@ -185,7 +185,7 @@ static_assert(_guestWindowPageWidgets.size() == WINDOW_GUEST_PAGE_COUNT); uint16_t _marqueePosition = 0; uint16_t _beingWatchedTimer = 0; uint16_t _guestAnimationFrame = 0; - int16_t _pickedPeepX = LOCATION_NULL; // entity->x gets set to 0x8000 on pickup, this is the old value + int16_t _pickedPeepX = kLocationNull; // entity->x gets set to 0x8000 on pickup, this is the old value std::vector _riddenRides; public: diff --git a/src/openrct2-ui/windows/LandRights.cpp b/src/openrct2-ui/windows/LandRights.cpp index c471da4ba6..5d32fb6198 100644 --- a/src/openrct2-ui/windows/LandRights.cpp +++ b/src/openrct2-ui/windows/LandRights.cpp @@ -337,7 +337,7 @@ static Widget window_land_rights_widgets[] = { { if (_landRightsMode == LAND_RIGHTS_MODE_BUY_LAND) { - if (screenCoords.x != LOCATION_NULL) + if (screenCoords.x != kLocationNull) { auto landBuyRightsAction = LandBuyRightsAction( { gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y }, @@ -347,7 +347,7 @@ static Widget window_land_rights_widgets[] = { } else { - if (screenCoords.x != LOCATION_NULL) + if (screenCoords.x != kLocationNull) { auto landBuyRightsAction = LandBuyRightsAction( { gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y }, @@ -361,7 +361,7 @@ static Widget window_land_rights_widgets[] = { { if (_landRightsMode == LAND_RIGHTS_MODE_BUY_LAND) { - if (screenCoords.x != LOCATION_NULL) + if (screenCoords.x != kLocationNull) { auto landBuyRightsAction = LandBuyRightsAction( { gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y }, @@ -371,7 +371,7 @@ static Widget window_land_rights_widgets[] = { } else { - if (screenCoords.x != LOCATION_NULL) + if (screenCoords.x != kLocationNull) { auto landBuyRightsAction = LandBuyRightsAction( { gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y }, diff --git a/src/openrct2-ui/windows/Map.cpp b/src/openrct2-ui/windows/Map.cpp index 79c468faf4..b0959c9015 100644 --- a/src/openrct2-ui/windows/Map.cpp +++ b/src/openrct2-ui/windows/Map.cpp @@ -61,11 +61,11 @@ namespace OpenRCT2::Ui::Windows } static int32_t getTechnicalMapSizeBig() { - return getTechnicalMapSize() * COORDS_XY_STEP; + return getTechnicalMapSize() * kCoordsXYStep; } static int32_t getMaxTileStartXY() { - return getTechnicalMapSizeBig() - COORDS_XY_STEP; + return getTechnicalMapSizeBig() - kCoordsXYStep; } static int32_t getMiniMapWidth() { @@ -1136,27 +1136,27 @@ static Widget window_map_widgets[] = { switch (GetCurrentRotation()) { case 0: - x = _currentLine * COORDS_XY_STEP; + x = _currentLine * kCoordsXYStep; y = 0; dx = 0; - dy = COORDS_XY_STEP; + dy = kCoordsXYStep; break; case 1: x = getMaxTileStartXY(); - y = _currentLine * COORDS_XY_STEP; - dx = -COORDS_XY_STEP; + y = _currentLine * kCoordsXYStep; + dx = -kCoordsXYStep; dy = 0; break; case 2: - x = getTechnicalMapSizeBig() - ((_currentLine + 1) * COORDS_XY_STEP); + x = getTechnicalMapSizeBig() - ((_currentLine + 1) * kCoordsXYStep); y = getMaxTileStartXY(); dx = 0; - dy = -COORDS_XY_STEP; + dy = -kCoordsXYStep; break; case 3: x = 0; - y = getTechnicalMapSizeBig() - ((_currentLine + 1) * COORDS_XY_STEP); - dx = COORDS_XY_STEP; + y = getTechnicalMapSizeBig() - ((_currentLine + 1) * kCoordsXYStep); + dx = kCoordsXYStep; dy = 0; break; } @@ -1309,7 +1309,7 @@ static Widget window_map_widgets[] = { void DrawMapPeepPixel(Peep* peep, const uint8_t flashColour, DrawPixelInfo& dpi, const ScreenCoordsXY& offset) { - if (peep->x == LOCATION_NULL) + if (peep->x == kLocationNull) return; MapCoordsXY c = TransformToMapCoords({ peep->x, peep->y }); @@ -1359,7 +1359,7 @@ static Widget window_map_widgets[] = { { for (Vehicle* vehicle = train; vehicle != nullptr; vehicle = GetEntity(vehicle->next_vehicle_on_train)) { - if (vehicle->x == LOCATION_NULL) + if (vehicle->x == kLocationNull) continue; auto mapCoord = TransformToMapCoords({ vehicle->x, vehicle->y }); diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index 4626c0455a..4154b73339 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -2671,7 +2671,7 @@ static Widget _rideConstructionWidgets[] = { CoordsXY coords = originCoords + offsets.Rotate(trackDirection); int32_t baseZ = originZ + trackBlock->z; - int32_t clearanceZ = trackBlock->ClearanceZ + clearanceHeight + baseZ + (4 * COORDS_Z_STEP); + int32_t clearanceZ = trackBlock->ClearanceZ + clearanceHeight + baseZ + (4 * kCoordsZStep); auto centreTileCoords = TileCoordsXY{ coords }; auto eastTileCoords = centreTileCoords + TileDirectionDelta[TILE_ELEMENT_DIRECTION_EAST]; @@ -3021,7 +3021,7 @@ static Widget _rideConstructionWidgets[] = { _trackPlaceZ = std::max(mapZ, 16); } - if (mapCoords.x == LOCATION_NULL) + if (mapCoords.x == kLocationNull) return std::nullopt; return mapCoords.ToTileStart(); @@ -3313,7 +3313,7 @@ static Widget _rideConstructionWidgets[] = { _previousTrackPiece = _currentTrackBegin; // search for appropriate z value for ghost, up to max ride height - int numAttempts = (z <= MAX_TRACK_HEIGHT ? ((MAX_TRACK_HEIGHT - z) / COORDS_Z_STEP + 1) : 2); + int numAttempts = (z <= MAX_TRACK_HEIGHT ? ((MAX_TRACK_HEIGHT - z) / kCoordsZStep + 1) : 2); if (rtd.HasFlag(RIDE_TYPE_FLAG_IS_MAZE)) { @@ -3550,7 +3550,7 @@ static Widget _rideConstructionWidgets[] = { } // search for z value to build at, up to max ride height - int numAttempts = (z <= MAX_TRACK_HEIGHT ? ((MAX_TRACK_HEIGHT - z) / COORDS_Z_STEP + 1) : 2); + int numAttempts = (z <= MAX_TRACK_HEIGHT ? ((MAX_TRACK_HEIGHT - z) / kCoordsZStep + 1) : 2); const auto& rtd = ride->GetRideTypeDescriptor(); if (rtd.HasFlag(RIDE_TYPE_FLAG_IS_MAZE)) @@ -4561,7 +4561,7 @@ static Widget _rideConstructionWidgets[] = { { if (_gotoStartPlacementMode) { - _currentTrackBegin.z = Floor2(piecePos.z, COORDS_Z_STEP); + _currentTrackBegin.z = Floor2(piecePos.z, kCoordsZStep); _rideConstructionState = RideConstructionState::Front; _currentTrackSelectionFlags = 0; _currentTrackPieceDirection = piecePos.direction & 3; diff --git a/src/openrct2-ui/windows/Staff.cpp b/src/openrct2-ui/windows/Staff.cpp index 50240b7e4c..e85733bffc 100644 --- a/src/openrct2-ui/windows/Staff.cpp +++ b/src/openrct2-ui/windows/Staff.cpp @@ -129,7 +129,7 @@ static Widget _staffOptionsWidgets[] = { private: EntertainerCostume _availableCostumes[EnumValue(EntertainerCostume::Count)]{}; uint16_t _tabAnimationOffset = 0; - int32_t _pickedPeepOldX = LOCATION_NULL; + int32_t _pickedPeepOldX = kLocationNull; public: void Initialise(EntityId entityId) diff --git a/src/openrct2-ui/windows/StaffList.cpp b/src/openrct2-ui/windows/StaffList.cpp index 5271cd8f23..3e23909430 100644 --- a/src/openrct2-ui/windows/StaffList.cpp +++ b/src/openrct2-ui/windows/StaffList.cpp @@ -668,7 +668,7 @@ static Widget _staffListWidgets[] = { } } - if (peep->x == LOCATION_NULL) + if (peep->x == kLocationNull) { continue; } diff --git a/src/openrct2-ui/windows/TopToolbar.cpp b/src/openrct2-ui/windows/TopToolbar.cpp index 0c782f9746..5cfeacedd1 100644 --- a/src/openrct2-ui/windows/TopToolbar.cpp +++ b/src/openrct2-ui/windows/TopToolbar.cpp @@ -807,7 +807,7 @@ namespace OpenRCT2::Ui::Windows } uint16_t tool_size = std::max(1, gLandToolSize); - uint16_t tool_length = (tool_size - 1) * COORDS_XY_STEP; + uint16_t tool_length = (tool_size - 1) * kCoordsXYStep; // Move to tool bottom left mapTile.x -= tool_length / 2; @@ -913,15 +913,15 @@ namespace OpenRCT2::Ui::Windows gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; if (gWindowSceneryScatterEnabled) { - uint16_t cluster_size = (gWindowSceneryScatterSize - 1) * COORDS_XY_STEP; + uint16_t cluster_size = (gWindowSceneryScatterSize - 1) * kCoordsXYStep; gMapSelectPositionA.x = mapTile.x - cluster_size / 2; gMapSelectPositionA.y = mapTile.y - cluster_size / 2; gMapSelectPositionB.x = mapTile.x + cluster_size / 2; gMapSelectPositionB.y = mapTile.y + cluster_size / 2; if (gWindowSceneryScatterSize % 2 == 0) { - gMapSelectPositionB.x += COORDS_XY_STEP; - gMapSelectPositionB.y += COORDS_XY_STEP; + gMapSelectPositionB.x += kCoordsXYStep; + gMapSelectPositionB.y += kCoordsXYStep; } } else @@ -1126,7 +1126,7 @@ namespace OpenRCT2::Ui::Windows if (cost != kMoney64Undefined) break; - gSceneryPlaceZ += COORDS_Z_STEP; + gSceneryPlaceZ += kCoordsZStep; } gSceneryPlaceCost = cost; @@ -2157,7 +2157,7 @@ namespace OpenRCT2::Ui::Windows { if (rotation != DirectionReverse(info.Element->AsPath()->GetSlopeDirection())) { - z += (2 * COORDS_Z_STEP); + z += (2 * kCoordsZStep); } } @@ -2250,8 +2250,8 @@ namespace OpenRCT2::Ui::Windows grid_x_offset += 1; grid_y_offset += 1; } - cur_grid_x += grid_x_offset * COORDS_XY_STEP; - cur_grid_y += grid_y_offset * COORDS_XY_STEP; + cur_grid_x += grid_x_offset * kCoordsXYStep; + cur_grid_y += grid_y_offset * kCoordsXYStep; if (!sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_ROTATABLE)) { diff --git a/src/openrct2-ui/windows/TrackDesignPlace.cpp b/src/openrct2-ui/windows/TrackDesignPlace.cpp index 38e842020c..0eb0c95198 100644 --- a/src/openrct2-ui/windows/TrackDesignPlace.cpp +++ b/src/openrct2-ui/windows/TrackDesignPlace.cpp @@ -361,8 +361,8 @@ static Widget _trackPlaceWidgets[] = { CoordsXY origin = { 0, 0 }; if (pass == 1) { - origin.x -= ((max.x + min.x) >> 6) * COORDS_XY_STEP; - origin.y -= ((max.y + min.y) >> 6) * COORDS_XY_STEP; + origin.x -= ((max.x + min.x) >> 6) * kCoordsXYStep; + origin.y -= ((max.y + min.y) >> 6) * kCoordsXYStep; } const auto& rtd = GetRideTypeDescriptor(td.trackAndVehicle.rtdIndex); diff --git a/src/openrct2/Editor.cpp b/src/openrct2/Editor.cpp index b78808aae6..d4882b6f24 100644 --- a/src/openrct2/Editor.cpp +++ b/src/openrct2/Editor.cpp @@ -213,8 +213,8 @@ namespace OpenRCT2::Editor static void SetAllLandOwned() { auto& gameState = GetGameState(); - MapRange range = { 2 * COORDS_XY_STEP, 2 * COORDS_XY_STEP, (gameState.MapSize.x - 3) * COORDS_XY_STEP, - (gameState.MapSize.y - 3) * COORDS_XY_STEP }; + MapRange range = { 2 * kCoordsXYStep, 2 * kCoordsXYStep, (gameState.MapSize.x - 3) * kCoordsXYStep, + (gameState.MapSize.y - 3) * kCoordsXYStep }; auto landSetRightsAction = LandSetRightsAction(range, LandSetRightSetting::SetForSale); landSetRightsAction.SetFlags(GAME_COMMAND_FLAG_NO_SPEND); GameActions::Execute(&landSetRightsAction); diff --git a/src/openrct2/actions/BannerPlaceAction.cpp b/src/openrct2/actions/BannerPlaceAction.cpp index 990f943b8b..cf1002f4d9 100644 --- a/src/openrct2/actions/BannerPlaceAction.cpp +++ b/src/openrct2/actions/BannerPlaceAction.cpp @@ -148,7 +148,7 @@ GameActions::Result BannerPlaceAction::Execute() const banner->position = TileCoordsXY(_loc); res.SetData(BannerPlaceActionResult{ banner->id }); - auto* bannerElement = TileElementInsert({ _loc, _loc.z + (2 * COORDS_Z_STEP) }, 0b0000); + auto* bannerElement = TileElementInsert({ _loc, _loc.z + (2 * kCoordsZStep) }, 0b0000); Guard::Assert(bannerElement != nullptr); bannerElement->SetClearanceZ(_loc.z + PATH_CLEARANCE); diff --git a/src/openrct2/actions/CheatSetAction.cpp b/src/openrct2/actions/CheatSetAction.cpp index 1a7cd80cc8..5e05aa1bff 100644 --- a/src/openrct2/actions/CheatSetAction.cpp +++ b/src/openrct2/actions/CheatSetAction.cpp @@ -758,12 +758,12 @@ void CheatSetAction::SetStaffSpeed(uint8_t value) const void CheatSetAction::OwnAllLand() const { - const auto min = CoordsXY{ COORDS_XY_STEP, COORDS_XY_STEP }; - const auto max = GetMapSizeUnits() - CoordsXY{ COORDS_XY_STEP, COORDS_XY_STEP }; + const auto min = CoordsXY{ kCoordsXYStep, kCoordsXYStep }; + const auto max = GetMapSizeUnits() - CoordsXY{ kCoordsXYStep, kCoordsXYStep }; - for (CoordsXY coords = min; coords.y <= max.y; coords.y += COORDS_XY_STEP) + for (CoordsXY coords = min; coords.y <= max.y; coords.y += kCoordsXYStep) { - for (coords.x = min.x; coords.x <= max.x; coords.x += COORDS_XY_STEP) + for (coords.x = min.x; coords.x <= max.x; coords.x += kCoordsXYStep) { auto* surfaceElement = MapGetSurfaceElementAt(coords); if (surfaceElement == nullptr) diff --git a/src/openrct2/actions/ClearAction.cpp b/src/openrct2/actions/ClearAction.cpp index a334aae4ee..23eb22e688 100644 --- a/src/openrct2/actions/ClearAction.cpp +++ b/src/openrct2/actions/ClearAction.cpp @@ -82,9 +82,9 @@ GameActions::Result ClearAction::QueryExecute(bool executing) const money64 totalCost = 0; auto validRange = ClampRangeWithinMap(_range); - for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += COORDS_XY_STEP) + for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += kCoordsXYStep) { - for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += COORDS_XY_STEP) + for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += kCoordsXYStep) { if (LocationValid({ x, y }) && MapCanClearAt({ x, y })) { diff --git a/src/openrct2/actions/FootpathPlaceAction.cpp b/src/openrct2/actions/FootpathPlaceAction.cpp index e64331f7e1..eaf33b9943 100644 --- a/src/openrct2/actions/FootpathPlaceAction.cpp +++ b/src/openrct2/actions/FootpathPlaceAction.cpp @@ -463,16 +463,16 @@ void FootpathPlaceAction::AutomaticallySetPeepSpawn() const { auto mapSizeUnits = GetMapSizeUnits(); uint8_t direction = 0; - if (_loc.x != COORDS_XY_STEP) + if (_loc.x != kCoordsXYStep) { direction++; - if (_loc.y != mapSizeUnits.y - COORDS_XY_STEP) + if (_loc.y != mapSizeUnits.y - kCoordsXYStep) { direction++; - if (_loc.x != mapSizeUnits.x - COORDS_XY_STEP) + if (_loc.x != mapSizeUnits.x - kCoordsXYStep) { direction++; - if (_loc.y != COORDS_XY_STEP) + if (_loc.y != kCoordsXYStep) return; } } @@ -496,8 +496,8 @@ void FootpathPlaceAction::RemoveIntersectingWalls(PathElement* pathElement) cons { auto direction = pathElement->GetSlopeDirection(); int32_t z = pathElement->GetBaseZ(); - WallRemoveIntersectingWalls({ _loc, z, z + (6 * COORDS_Z_STEP) }, DirectionReverse(direction)); - WallRemoveIntersectingWalls({ _loc, z, z + (6 * COORDS_Z_STEP) }, direction); + WallRemoveIntersectingWalls({ _loc, z, z + (6 * kCoordsZStep) }, DirectionReverse(direction)); + WallRemoveIntersectingWalls({ _loc, z, z + (6 * kCoordsZStep) }, direction); // Removing walls may have made the pointer invalid, so find it again pathElement = MapGetFootpathElement(CoordsXYZ(_loc, z)); if (pathElement == nullptr) diff --git a/src/openrct2/actions/GameActionResult.h b/src/openrct2/actions/GameActionResult.h index cfe5e68c80..2fad9f8538 100644 --- a/src/openrct2/actions/GameActionResult.h +++ b/src/openrct2/actions/GameActionResult.h @@ -60,7 +60,7 @@ namespace OpenRCT2::GameActions StringVariant ErrorTitle = STR_NONE; StringVariant ErrorMessage = STR_NONE; std::array ErrorMessageArgs{}; - CoordsXYZ Position = { LOCATION_NULL, LOCATION_NULL, LOCATION_NULL }; + CoordsXYZ Position = { kLocationNull, kLocationNull, kLocationNull }; money64 Cost = 0; ExpenditureType Expenditure = ExpenditureType::Count; diff --git a/src/openrct2/actions/LandBuyRightsAction.cpp b/src/openrct2/actions/LandBuyRightsAction.cpp index a169040d16..9c16f882d8 100644 --- a/src/openrct2/actions/LandBuyRightsAction.cpp +++ b/src/openrct2/actions/LandBuyRightsAction.cpp @@ -89,9 +89,9 @@ GameActions::Result LandBuyRightsAction::QueryExecute(bool isExecuting) const res.Expenditure = ExpenditureType::LandPurchase; // Game command modified to accept selection size - for (auto y = validRange.GetTop(); y <= validRange.GetBottom(); y += COORDS_XY_STEP) + for (auto y = validRange.GetTop(); y <= validRange.GetBottom(); y += kCoordsXYStep) { - for (auto x = validRange.GetLeft(); x <= validRange.GetRight(); x += COORDS_XY_STEP) + for (auto x = validRange.GetLeft(); x <= validRange.GetRight(); x += kCoordsXYStep) { if (!LocationValid({ x, y })) continue; diff --git a/src/openrct2/actions/LandLowerAction.cpp b/src/openrct2/actions/LandLowerAction.cpp index cae96d4096..56a28e20bf 100644 --- a/src/openrct2/actions/LandLowerAction.cpp +++ b/src/openrct2/actions/LandLowerAction.cpp @@ -86,9 +86,9 @@ GameActions::Result LandLowerAction::QueryExecute(bool isExecuting) const uint8_t maxHeight = MapGetHighestLandHeight(validRange); bool withinOwnership = false; - for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += COORDS_XY_STEP) + for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += kCoordsXYStep) { - for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += COORDS_XY_STEP) + for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += kCoordsXYStep) { if (!LocationValid({ x, y })) continue; diff --git a/src/openrct2/actions/LandRaiseAction.cpp b/src/openrct2/actions/LandRaiseAction.cpp index b0c3efa34b..429db39de0 100644 --- a/src/openrct2/actions/LandRaiseAction.cpp +++ b/src/openrct2/actions/LandRaiseAction.cpp @@ -87,9 +87,9 @@ GameActions::Result LandRaiseAction::QueryExecute(bool isExecuting) const uint8_t minHeight = MapGetLowestLandHeight(validRange); bool withinOwnership = false; - for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += COORDS_XY_STEP) + for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += kCoordsXYStep) { - for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += COORDS_XY_STEP) + for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += kCoordsXYStep) { if (!LocationValid({ x, y })) continue; diff --git a/src/openrct2/actions/LandSetHeightAction.cpp b/src/openrct2/actions/LandSetHeightAction.cpp index 09989a76a4..44800f0dc9 100644 --- a/src/openrct2/actions/LandSetHeightAction.cpp +++ b/src/openrct2/actions/LandSetHeightAction.cpp @@ -137,7 +137,7 @@ GameActions::Result LandSetHeightAction::Query() const } auto clearResult = MapCanConstructWithClearAt( - { _coords, _height * COORDS_Z_STEP, zCorner * COORDS_Z_STEP }, &MapSetLandHeightClearFunc, { 0b1111, 0 }, 0, + { _coords, _height * kCoordsZStep, zCorner * kCoordsZStep }, &MapSetLandHeightClearFunc, { 0b1111, 0 }, 0, CreateCrossingMode::none); if (clearResult.Error != GameActions::Status::Ok) { @@ -310,7 +310,7 @@ TileElement* LandSetHeightAction::CheckFloatingStructures(TileElement* surfaceEl zCorner += 2; } } - if (zCorner > (waterHeight / COORDS_Z_STEP) - 2) + if (zCorner > (waterHeight / kCoordsZStep) - 2) { return ++surfaceElement; } @@ -336,7 +336,7 @@ void LandSetHeightAction::SetSurfaceHeight(TileElement* surfaceElement) const surfaceElement->BaseHeight = _height; surfaceElement->ClearanceHeight = _height; surfaceElement->AsSurface()->SetSlope(_style); - int32_t waterHeight = surfaceElement->AsSurface()->GetWaterHeight() / COORDS_Z_STEP; + int32_t waterHeight = surfaceElement->AsSurface()->GetWaterHeight() / kCoordsZStep; if (waterHeight != 0 && waterHeight <= _height) { surfaceElement->AsSurface()->SetWaterHeight(0); diff --git a/src/openrct2/actions/LandSetRightsAction.cpp b/src/openrct2/actions/LandSetRightsAction.cpp index 5f093ff72a..08f9e2dc11 100644 --- a/src/openrct2/actions/LandSetRightsAction.cpp +++ b/src/openrct2/actions/LandSetRightsAction.cpp @@ -89,9 +89,9 @@ GameActions::Result LandSetRightsAction::QueryExecute(bool isExecuting) const } // Game command modified to accept selection size - for (auto y = validRange.GetTop(); y <= validRange.GetBottom(); y += COORDS_XY_STEP) + for (auto y = validRange.GetTop(); y <= validRange.GetBottom(); y += kCoordsXYStep) { - for (auto x = validRange.GetLeft(); x <= validRange.GetRight(); x += COORDS_XY_STEP) + for (auto x = validRange.GetLeft(); x <= validRange.GetRight(); x += kCoordsXYStep) { if (!LocationValid({ x, y })) continue; diff --git a/src/openrct2/actions/LandSmoothAction.cpp b/src/openrct2/actions/LandSmoothAction.cpp index 7871f48f1b..e711144e77 100644 --- a/src/openrct2/actions/LandSmoothAction.cpp +++ b/src/openrct2/actions/LandSmoothAction.cpp @@ -402,7 +402,7 @@ GameActions::Result LandSmoothAction::SmoothLand(bool isExecuting) const // Smooth the edges int32_t z1, z2; - for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += COORDS_XY_STEP) + for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += kCoordsXYStep) { auto surfaceElement = MapGetSurfaceElementAt(CoordsXY{ validRange.GetLeft(), y }); if (surfaceElement != nullptr) @@ -421,7 +421,7 @@ GameActions::Result LandSmoothAction::SmoothLand(bool isExecuting) const } } - for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += COORDS_XY_STEP) + for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += kCoordsXYStep) { auto surfaceElement = MapGetSurfaceElementAt(CoordsXY{ x, validRange.GetTop() }); if (surfaceElement != nullptr) diff --git a/src/openrct2/actions/MazePlaceTrackAction.cpp b/src/openrct2/actions/MazePlaceTrackAction.cpp index 9cf4e20d89..3bad5ea0c5 100644 --- a/src/openrct2/actions/MazePlaceTrackAction.cpp +++ b/src/openrct2/actions/MazePlaceTrackAction.cpp @@ -87,7 +87,7 @@ GameActions::Result MazePlaceTrackAction::Query() const auto heightDifference = baseHeight - surfaceElement->GetBaseZ(); if (heightDifference >= 0 && !OpenRCT2::GetGameState().Cheats.DisableSupportLimits) { - heightDifference /= COORDS_Z_PER_TINY_Z; + heightDifference /= kCoordsZPerTinyZ; auto* ride = GetRide(_rideIndex); const auto& rtd = ride->GetRideTypeDescriptor(); diff --git a/src/openrct2/actions/MazeSetTrackAction.cpp b/src/openrct2/actions/MazeSetTrackAction.cpp index e8cfd8945d..77e0875772 100644 --- a/src/openrct2/actions/MazeSetTrackAction.cpp +++ b/src/openrct2/actions/MazeSetTrackAction.cpp @@ -124,7 +124,7 @@ GameActions::Result MazeSetTrackAction::Query() const auto heightDifference = baseHeight - surfaceElement->GetBaseZ(); if (heightDifference >= 0 && !OpenRCT2::GetGameState().Cheats.DisableSupportLimits) { - heightDifference /= COORDS_Z_PER_TINY_Z; + heightDifference /= kCoordsZPerTinyZ; auto* ride = GetRide(_rideIndex); const auto& rtd = ride->GetRideTypeDescriptor(); diff --git a/src/openrct2/actions/ParkEntrancePlaceAction.cpp b/src/openrct2/actions/ParkEntrancePlaceAction.cpp index 504d5cbd65..fc56bf0b4d 100644 --- a/src/openrct2/actions/ParkEntrancePlaceAction.cpp +++ b/src/openrct2/actions/ParkEntrancePlaceAction.cpp @@ -60,8 +60,8 @@ GameActions::Result ParkEntrancePlaceAction::Query() const res.Expenditure = ExpenditureType::LandPurchase; res.Position = { _loc.x, _loc.y, _loc.z }; - auto mapSizeUnits = GetMapSizeUnits() - CoordsXY{ COORDS_XY_STEP, COORDS_XY_STEP }; - if (!LocationValid(_loc) || _loc.x <= COORDS_XY_STEP || _loc.y <= COORDS_XY_STEP || _loc.x >= mapSizeUnits.x + auto mapSizeUnits = GetMapSizeUnits() - CoordsXY{ kCoordsXYStep, kCoordsXYStep }; + if (!LocationValid(_loc) || _loc.x <= kCoordsXYStep || _loc.y <= kCoordsXYStep || _loc.x >= mapSizeUnits.x || _loc.y >= mapSizeUnits.y) { return GameActions::Result( @@ -171,10 +171,10 @@ GameActions::Result ParkEntrancePlaceAction::Execute() const } Park::UpdateFences(entranceLoc); - Park::UpdateFences({ entranceLoc.x - COORDS_XY_STEP, entranceLoc.y }); - Park::UpdateFences({ entranceLoc.x + COORDS_XY_STEP, entranceLoc.y }); - Park::UpdateFences({ entranceLoc.x, entranceLoc.y - COORDS_XY_STEP }); - Park::UpdateFences({ entranceLoc.x, entranceLoc.y + COORDS_XY_STEP }); + Park::UpdateFences({ entranceLoc.x - kCoordsXYStep, entranceLoc.y }); + Park::UpdateFences({ entranceLoc.x + kCoordsXYStep, entranceLoc.y }); + Park::UpdateFences({ entranceLoc.x, entranceLoc.y - kCoordsXYStep }); + Park::UpdateFences({ entranceLoc.x, entranceLoc.y + kCoordsXYStep }); MapInvalidateTile({ entranceLoc, entranceElement->GetBaseZ(), entranceElement->GetClearanceZ() }); diff --git a/src/openrct2/actions/SmallSceneryPlaceAction.cpp b/src/openrct2/actions/SmallSceneryPlaceAction.cpp index 6a74047bf3..a1658fc490 100644 --- a/src/openrct2/actions/SmallSceneryPlaceAction.cpp +++ b/src/openrct2/actions/SmallSceneryPlaceAction.cpp @@ -232,7 +232,7 @@ GameActions::Result SmallSceneryPlaceAction::Query() const } int32_t zLow = targetHeight; - int32_t zHigh = zLow + Ceil2(sceneryEntry->height, COORDS_Z_STEP); + int32_t zHigh = zLow + Ceil2(sceneryEntry->height, kCoordsZStep); uint8_t collisionQuadrants = 0b1111; auto quadRotation{ 0 }; if (!(sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_FULL_TILE))) diff --git a/src/openrct2/actions/StaffSetPatrolAreaAction.cpp b/src/openrct2/actions/StaffSetPatrolAreaAction.cpp index ac28607d5c..6d19583797 100644 --- a/src/openrct2/actions/StaffSetPatrolAreaAction.cpp +++ b/src/openrct2/actions/StaffSetPatrolAreaAction.cpp @@ -68,9 +68,9 @@ GameActions::Result StaffSetPatrolAreaAction::QueryExecute(bool executing) const } auto validRange = ClampRangeWithinMap(_range); - for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += COORDS_XY_STEP) + for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += kCoordsXYStep) { - for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += COORDS_XY_STEP) + for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += kCoordsXYStep) { if (!LocationValid({ x, y })) { diff --git a/src/openrct2/actions/SurfaceSetStyleAction.cpp b/src/openrct2/actions/SurfaceSetStyleAction.cpp index 731c30f5d8..a4f92cfa78 100644 --- a/src/openrct2/actions/SurfaceSetStyleAction.cpp +++ b/src/openrct2/actions/SurfaceSetStyleAction.cpp @@ -96,9 +96,9 @@ GameActions::Result SurfaceSetStyleAction::Query() const money64 surfaceCost = 0; money64 edgeCost = 0; for (CoordsXY coords = { validRange.GetLeft(), validRange.GetTop() }; coords.x <= validRange.GetRight(); - coords.x += COORDS_XY_STEP) + coords.x += kCoordsXYStep) { - for (coords.y = validRange.GetTop(); coords.y <= validRange.GetBottom(); coords.y += COORDS_XY_STEP) + for (coords.y = validRange.GetTop(); coords.y <= validRange.GetBottom(); coords.y += kCoordsXYStep) { if (!LocationValid(coords)) continue; @@ -164,9 +164,9 @@ GameActions::Result SurfaceSetStyleAction::Execute() const money64 surfaceCost = 0; money64 edgeCost = 0; for (CoordsXY coords = { validRange.GetLeft(), validRange.GetTop() }; coords.x <= validRange.GetRight(); - coords.x += COORDS_XY_STEP) + coords.x += kCoordsXYStep) { - for (coords.y = validRange.GetTop(); coords.y <= validRange.GetBottom(); coords.y += COORDS_XY_STEP) + for (coords.y = validRange.GetTop(); coords.y <= validRange.GetBottom(); coords.y += kCoordsXYStep) { if (!LocationValid(coords)) continue; diff --git a/src/openrct2/actions/TrackPlaceAction.cpp b/src/openrct2/actions/TrackPlaceAction.cpp index 2b8072c1b8..6d16d5592a 100644 --- a/src/openrct2/actions/TrackPlaceAction.cpp +++ b/src/openrct2/actions/TrackPlaceAction.cpp @@ -242,7 +242,7 @@ GameActions::Result TrackPlaceAction::Query() const GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_TOO_LOW); } - int32_t baseZ = Floor2(mapLoc.z, COORDS_Z_STEP); + int32_t baseZ = Floor2(mapLoc.z, kCoordsZStep); int32_t clearanceZ = trackBlock->ClearanceZ; if (trackBlock->flags & RCT_PREVIEW_TRACK_FLAG_IS_VERTICAL && clearanceHeight > 24) @@ -254,7 +254,7 @@ GameActions::Result TrackPlaceAction::Query() const clearanceZ += clearanceHeight; } - clearanceZ = Floor2(clearanceZ, COORDS_Z_STEP) + baseZ; + clearanceZ = Floor2(clearanceZ, kCoordsZStep) + baseZ; if (clearanceZ > MAX_TRACK_HEIGHT) { @@ -391,7 +391,7 @@ GameActions::Result TrackPlaceAction::Query() const maxHeight = ride->GetRideTypeDescriptor().Heights.MaxHeight; } - ride_height /= COORDS_Z_PER_TINY_Z; + ride_height /= kCoordsZPerTinyZ; if (ride_height > maxHeight && !_trackDesignDrawingPreview) { return GameActions::Result( @@ -404,10 +404,10 @@ GameActions::Result TrackPlaceAction::Query() const int32_t supportHeight = baseZ - surfaceElement->GetBaseZ(); if (supportHeight < 0) { - supportHeight = (10 * COORDS_Z_STEP); + supportHeight = (10 * kCoordsZStep); } - supportCosts += ((supportHeight / (2 * COORDS_Z_STEP)) * ride->GetRideTypeDescriptor().BuildCosts.SupportPrice); + supportCosts += ((supportHeight / (2 * kCoordsZStep)) * ride->GetRideTypeDescriptor().BuildCosts.SupportPrice); } money64 price = ride->GetRideTypeDescriptor().BuildCosts.TrackPrice; @@ -464,7 +464,7 @@ GameActions::Result TrackPlaceAction::Execute() const auto quarterTile = trackBlock->var_08.Rotate(_origin.direction); - int32_t baseZ = Floor2(mapLoc.z, COORDS_Z_STEP); + int32_t baseZ = Floor2(mapLoc.z, kCoordsZStep); int32_t clearanceZ = trackBlock->ClearanceZ; if (trackBlock->flags & RCT_PREVIEW_TRACK_FLAG_IS_VERTICAL && clearanceHeight > 24) { @@ -475,7 +475,7 @@ GameActions::Result TrackPlaceAction::Execute() const clearanceZ += clearanceHeight; } - clearanceZ = Floor2(clearanceZ, COORDS_Z_STEP) + baseZ; + clearanceZ = Floor2(clearanceZ, kCoordsZStep) + baseZ; const auto mapLocWithClearance = CoordsXYRangedZ(mapLoc, baseZ, clearanceZ); auto crossingMode = (ride->GetRideTypeDescriptor().HasFlag(RIDE_TYPE_FLAG_SUPPORTS_LEVEL_CROSSINGS) @@ -550,10 +550,10 @@ GameActions::Result TrackPlaceAction::Execute() const int32_t supportHeight = baseZ - surfaceElement->GetBaseZ(); if (supportHeight < 0) { - supportHeight = (10 * COORDS_Z_STEP); + supportHeight = (10 * kCoordsZStep); } - supportCosts += (supportHeight / (2 * COORDS_Z_STEP)) * ride->GetRideTypeDescriptor().BuildCosts.SupportPrice; + supportCosts += (supportHeight / (2 * kCoordsZStep)) * ride->GetRideTypeDescriptor().BuildCosts.SupportPrice; int32_t entranceDirections = 0; if (!ride->overall_view.IsNull()) diff --git a/src/openrct2/actions/WallPlaceAction.cpp b/src/openrct2/actions/WallPlaceAction.cpp index 26e6234f35..44a3c5c46e 100644 --- a/src/openrct2/actions/WallPlaceAction.cpp +++ b/src/openrct2/actions/WallPlaceAction.cpp @@ -326,7 +326,7 @@ GameActions::Result WallPlaceAction::Execute() const return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_BUILD_THIS_HERE, STR_UNKNOWN_OBJECT_TYPE); } - uint8_t clearanceHeight = targetHeight / COORDS_Z_STEP; + uint8_t clearanceHeight = targetHeight / kCoordsZStep; if (edgeSlope & (EDGE_SLOPE_UPWARDS | EDGE_SLOPE_DOWNWARDS)) { clearanceHeight += 2; @@ -336,7 +336,7 @@ GameActions::Result WallPlaceAction::Execute() const bool wallAcrossTrack = false; if (!(GetFlags() & GAME_COMMAND_FLAG_TRACK_DESIGN) && !gameState.Cheats.DisableClearanceChecks) { - auto result = WallCheckObstruction(wallEntry, targetHeight / COORDS_Z_STEP, clearanceHeight, &wallAcrossTrack); + auto result = WallCheckObstruction(wallEntry, targetHeight / kCoordsZStep, clearanceHeight, &wallAcrossTrack); if (result.Error != GameActions::Status::Ok) { return result; diff --git a/src/openrct2/actions/WaterLowerAction.cpp b/src/openrct2/actions/WaterLowerAction.cpp index 7d76cace73..d547ea6c3e 100644 --- a/src/openrct2/actions/WaterLowerAction.cpp +++ b/src/openrct2/actions/WaterLowerAction.cpp @@ -68,9 +68,9 @@ GameActions::Result WaterLowerAction::QueryExecute(bool isExecuting) const uint8_t minHeight = GetLowestHeight(validRange); bool hasChanged = false; bool withinOwnership = false; - for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += COORDS_XY_STEP) + for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += kCoordsXYStep) { - for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += COORDS_XY_STEP) + for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += kCoordsXYStep) { if (!LocationValid({ x, y })) continue; @@ -88,7 +88,7 @@ GameActions::Result WaterLowerAction::QueryExecute(bool isExecuting) const } withinOwnership = true; - uint8_t height = surfaceElement->GetWaterHeight() / COORDS_Z_STEP; + uint8_t height = surfaceElement->GetWaterHeight() / kCoordsZStep; if (height == 0) continue; @@ -134,9 +134,9 @@ uint8_t WaterLowerAction::GetLowestHeight(const MapRange& validRange) const { // The lowest height to lower the water to is the highest water level in the selection uint8_t minHeight{ 0 }; - for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += COORDS_XY_STEP) + for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += kCoordsXYStep) { - for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += COORDS_XY_STEP) + for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += kCoordsXYStep) { if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !GetGameState().Cheats.SandboxMode) { @@ -150,7 +150,7 @@ uint8_t WaterLowerAction::GetLowestHeight(const MapRange& validRange) const if (surfaceElement == nullptr) continue; - uint8_t height = surfaceElement->GetWaterHeight() / COORDS_Z_STEP; + uint8_t height = surfaceElement->GetWaterHeight() / kCoordsZStep; if (height == 0) continue; diff --git a/src/openrct2/actions/WaterRaiseAction.cpp b/src/openrct2/actions/WaterRaiseAction.cpp index 79adb81efc..33084aa463 100644 --- a/src/openrct2/actions/WaterRaiseAction.cpp +++ b/src/openrct2/actions/WaterRaiseAction.cpp @@ -65,12 +65,12 @@ GameActions::Result WaterRaiseAction::QueryExecute(bool isExecuting) const res.Position.z = z; res.Expenditure = ExpenditureType::Landscaping; - auto maxHeight = GetHighestHeight(validRange) / COORDS_Z_STEP; + auto maxHeight = GetHighestHeight(validRange) / kCoordsZStep; bool hasChanged = false; bool withinOwnership = false; - for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += COORDS_XY_STEP) + for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += kCoordsXYStep) { - for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += COORDS_XY_STEP) + for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += kCoordsXYStep) { if (!LocationValid({ x, y })) continue; @@ -88,7 +88,7 @@ GameActions::Result WaterRaiseAction::QueryExecute(bool isExecuting) const } withinOwnership = true; - uint8_t height = surfaceElement->GetWaterHeight() / COORDS_Z_STEP; + uint8_t height = surfaceElement->GetWaterHeight() / kCoordsZStep; if (surfaceElement->BaseHeight > maxHeight) continue; @@ -146,10 +146,10 @@ GameActions::Result WaterRaiseAction::QueryExecute(bool isExecuting) const uint16_t WaterRaiseAction::GetHighestHeight(const MapRange& validRange) const { // The highest height to raise the water to is the lowest water level in the selection - uint16_t maxHeight = 255 * COORDS_Z_STEP; - for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += COORDS_XY_STEP) + uint16_t maxHeight = 255 * kCoordsZStep; + for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += kCoordsXYStep) { - for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += COORDS_XY_STEP) + for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += kCoordsXYStep) { if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !OpenRCT2::GetGameState().Cheats.SandboxMode) { diff --git a/src/openrct2/actions/WaterSetHeightAction.cpp b/src/openrct2/actions/WaterSetHeightAction.cpp index 819565eb6d..8e2e5f9e5e 100644 --- a/src/openrct2/actions/WaterSetHeightAction.cpp +++ b/src/openrct2/actions/WaterSetHeightAction.cpp @@ -47,7 +47,7 @@ GameActions::Result WaterSetHeightAction::Query() const { auto res = GameActions::Result(); res.Expenditure = ExpenditureType::Landscaping; - res.Position = { _coords, _height * COORDS_Z_STEP }; + res.Position = { _coords, _height * kCoordsZStep }; if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !GetGameState().Cheats.SandboxMode && GetGameState().Park.Flags & PARK_FLAGS_FORBID_LANDSCAPE_CHANGES) @@ -83,7 +83,7 @@ GameActions::Result WaterSetHeightAction::Query() const } int32_t zHigh = surfaceElement->GetBaseZ(); - int32_t zLow = _height * COORDS_Z_STEP; + int32_t zLow = _height * kCoordsZStep; if (surfaceElement->GetWaterHeight() > 0) { zHigh = surfaceElement->GetWaterHeight(); @@ -114,7 +114,7 @@ GameActions::Result WaterSetHeightAction::Execute() const { auto res = GameActions::Result(); res.Expenditure = ExpenditureType::Landscaping; - res.Position = { _coords, _height * COORDS_Z_STEP }; + res.Position = { _coords, _height * kCoordsZStep }; int32_t surfaceHeight = TileElementHeight(_coords); FootpathRemoveLitter({ _coords, surfaceHeight }); @@ -131,7 +131,7 @@ GameActions::Result WaterSetHeightAction::Execute() const if (_height > surfaceElement->BaseHeight) { - surfaceElement->SetWaterHeight(_height * COORDS_Z_STEP); + surfaceElement->SetWaterHeight(_height * kCoordsZStep); } else { diff --git a/src/openrct2/drawing/LightFX.cpp b/src/openrct2/drawing/LightFX.cpp index a563b96b5a..c45433976e 100644 --- a/src/openrct2/drawing/LightFX.cpp +++ b/src/openrct2/drawing/LightFX.cpp @@ -321,7 +321,7 @@ void LightFXPrepareLightList() } int32_t minDist = 0; - int32_t baseHeight = (-999) * COORDS_Z_STEP; + int32_t baseHeight = (-999) * kCoordsZStep; if (interactionType != ViewportInteractionItem::Entity && tileElement != nullptr) { diff --git a/src/openrct2/entity/Balloon.cpp b/src/openrct2/entity/Balloon.cpp index 69735beccf..b12cd067a0 100644 --- a/src/openrct2/entity/Balloon.cpp +++ b/src/openrct2/entity/Balloon.cpp @@ -141,7 +141,7 @@ bool Balloon::Collides() const do { // the balloon has height so we add some padding to prevent it clipping through things. - int32_t balloon_top = z + COORDS_Z_STEP * 2; + int32_t balloon_top = z + kCoordsZStep * 2; if (balloon_top == tileElement->GetBaseZ()) { return true; diff --git a/src/openrct2/entity/EntityBase.cpp b/src/openrct2/entity/EntityBase.cpp index 8402fb3388..235c57577a 100644 --- a/src/openrct2/entity/EntityBase.cpp +++ b/src/openrct2/entity/EntityBase.cpp @@ -33,7 +33,7 @@ void EntityBase::SetLocation(const CoordsXYZ& newLocation) void EntityBase::Invalidate() { - if (x == LOCATION_NULL) + if (x == kLocationNull) return; ZoomLevel maxZoom{ 0 }; diff --git a/src/openrct2/entity/EntityRegistry.cpp b/src/openrct2/entity/EntityRegistry.cpp index fdaf368b92..9f2bb828c9 100644 --- a/src/openrct2/entity/EntityRegistry.cpp +++ b/src/openrct2/entity/EntityRegistry.cpp @@ -58,8 +58,8 @@ static constexpr size_t GetSpatialIndexOffset(const CoordsXY& loc) return SPATIAL_INDEX_LOCATION_NULL; // NOTE: The input coordinate is rotated and can have negative components. - const auto tileX = std::abs(loc.x) / COORDS_XY_STEP; - const auto tileY = std::abs(loc.y) / COORDS_XY_STEP; + const auto tileX = std::abs(loc.x) / kCoordsXYStep; + const auto tileY = std::abs(loc.y) / kCoordsXYStep; if (tileX >= kMaximumMapSizeTechnical || tileY >= kMaximumMapSizeTechnical) return SPATIAL_INDEX_LOCATION_NULL; @@ -314,15 +314,15 @@ static void PrepareNewEntity(EntityBase* base, const EntityType type) base->Type = type; AddToEntityList(base); - base->x = LOCATION_NULL; - base->y = LOCATION_NULL; + base->x = kLocationNull; + base->y = kLocationNull; base->z = 0; base->SpriteData.Width = 0x10; base->SpriteData.HeightMin = 0x14; base->SpriteData.HeightMax = 0x8; base->SpriteData.SpriteRect = {}; - EntitySpatialInsert(base, { LOCATION_NULL, 0 }); + EntitySpatialInsert(base, { kLocationNull, 0 }); } EntityBase* CreateEntity(EntityType type) @@ -449,7 +449,7 @@ static void EntitySpatialMove(EntityBase* entity, const CoordsXY& newLoc) void EntityBase::MoveTo(const CoordsXYZ& newLocation) { - if (x != LOCATION_NULL) + if (x != kLocationNull) { // Invalidate old position. Invalidate(); @@ -458,12 +458,12 @@ void EntityBase::MoveTo(const CoordsXYZ& newLocation) auto loc = newLocation; if (!MapIsLocationValid(loc)) { - loc.x = LOCATION_NULL; + loc.x = kLocationNull; } EntitySpatialMove(this, loc); - if (loc.x == LOCATION_NULL) + if (loc.x == kLocationNull) { x = loc.x; y = loc.y; diff --git a/src/openrct2/entity/Fountain.cpp b/src/openrct2/entity/Fountain.cpp index 4a7d6eeae3..d8e8ebc302 100644 --- a/src/openrct2/entity/Fountain.cpp +++ b/src/openrct2/entity/Fountain.cpp @@ -37,25 +37,25 @@ enum class PATTERN }; static constexpr std::array _fountainDirectionsNegative = { - CoordsXY{ -COORDS_XY_STEP, 0 }, - CoordsXY{ -COORDS_XY_STEP, -COORDS_XY_STEP }, + CoordsXY{ -kCoordsXYStep, 0 }, + CoordsXY{ -kCoordsXYStep, -kCoordsXYStep }, CoordsXY{ 0, 0 }, - CoordsXY{ -COORDS_XY_STEP, 0 }, + CoordsXY{ -kCoordsXYStep, 0 }, CoordsXY{ 0, 0 }, - CoordsXY{ 0, -COORDS_XY_STEP }, - CoordsXY{ 0, -COORDS_XY_STEP }, - CoordsXY{ -COORDS_XY_STEP, -COORDS_XY_STEP }, + CoordsXY{ 0, -kCoordsXYStep }, + CoordsXY{ 0, -kCoordsXYStep }, + CoordsXY{ -kCoordsXYStep, -kCoordsXYStep }, }; static constexpr std::array _fountainDirectionsPositive = { - CoordsXY{ COORDS_XY_STEP, 0 }, + CoordsXY{ kCoordsXYStep, 0 }, CoordsXY{ 0, 0 }, - CoordsXY{ 0, COORDS_XY_STEP }, - CoordsXY{ COORDS_XY_STEP, COORDS_XY_STEP }, - CoordsXY{ COORDS_XY_STEP, COORDS_XY_STEP }, - CoordsXY{ COORDS_XY_STEP, 0 }, + CoordsXY{ 0, kCoordsXYStep }, + CoordsXY{ kCoordsXYStep, kCoordsXYStep }, + CoordsXY{ kCoordsXYStep, kCoordsXYStep }, + CoordsXY{ kCoordsXYStep, 0 }, CoordsXY{ 0, 0 }, - CoordsXY{ 0, COORDS_XY_STEP }, + CoordsXY{ 0, kCoordsXYStep }, }; constexpr auto _FountainChanceOfStoppingEdgeMode = 0x3333; // 0.200 constexpr auto _FountainChanceOfStoppingRandomMode = 0x2000; // 0.125 @@ -435,11 +435,11 @@ void JumpingFountain::Paint(PaintSession& session, int32_t imageDirection) const : JumpingFountainWaterBaseImage; auto imageId = ImageId(baseImageId + imageDirection * 16 + frame); constexpr std::array antiClockWiseBoundingBoxes = { - CoordsXY{ -COORDS_XY_STEP, -3 }, + CoordsXY{ -kCoordsXYStep, -3 }, CoordsXY{ 0, -3 }, }; constexpr std::array clockWiseBoundingBoxes = { - CoordsXY{ -COORDS_XY_STEP, 3 }, + CoordsXY{ -kCoordsXYStep, 3 }, CoordsXY{ 0, 3 }, }; diff --git a/src/openrct2/entity/Guest.cpp b/src/openrct2/entity/Guest.cpp index 763042796c..754363d5a9 100644 --- a/src/openrct2/entity/Guest.cpp +++ b/src/openrct2/entity/Guest.cpp @@ -455,7 +455,7 @@ template<> bool EntityBase::Is() const static bool IsValidLocation(const CoordsXYZ& coords) { - if (coords.x != LOCATION_NULL) + if (coords.x != kLocationNull) { if (MapIsLocationValid(coords)) { @@ -919,7 +919,7 @@ void Guest::Tick128UpdateGuest(uint32_t index) } } - if (PeepFlags & PEEP_FLAGS_EXPLODE && x != LOCATION_NULL) + if (PeepFlags & PEEP_FLAGS_EXPLODE && x != kLocationNull) { if (State == PeepState::Walking || State == PeepState::Sitting) { @@ -968,7 +968,7 @@ void Guest::Tick128UpdateGuest(uint32_t index) if (SurroundingsThoughtTimeout >= 18) { SurroundingsThoughtTimeout = 0; - if (x != LOCATION_NULL) + if (x != kLocationNull) { PeepThoughtType thought_type = PeepAssessSurroundings(x & 0xFFE0, y & 0xFFE0, z); @@ -1828,7 +1828,7 @@ void Guest::PickRideToGoOn() return; if (HasFoodOrDrink()) return; - if (x == LOCATION_NULL) + if (x == kLocationNull) return; auto ride = FindBestRideToGoOn(); @@ -1897,9 +1897,9 @@ OpenRCT2::BitSet Guest::FindRidesToGoOn() constexpr auto radius = 10 * 32; int32_t cx = Floor2(x, 32); int32_t cy = Floor2(y, 32); - for (int32_t tileX = cx - radius; tileX <= cx + radius; tileX += COORDS_XY_STEP) + for (int32_t tileX = cx - radius; tileX <= cx + radius; tileX += kCoordsXYStep) { - for (int32_t tileY = cy - radius; tileY <= cy + radius; tileY += COORDS_XY_STEP) + for (int32_t tileY = cy - radius; tileY <= cy + radius; tileY += kCoordsXYStep) { auto location = CoordsXY{ tileX, tileY }; if (!MapIsLocationValid(location)) @@ -2935,9 +2935,9 @@ static PeepThoughtType PeepAssessSurroundings(int16_t centre_x, int16_t centre_y int16_t final_x = std::min(centre_x + 160, MAXIMUM_MAP_SIZE_BIG); int16_t final_y = std::min(centre_y + 160, MAXIMUM_MAP_SIZE_BIG); - for (int16_t x = initial_x; x < final_x; x += COORDS_XY_STEP) + for (int16_t x = initial_x; x < final_x; x += kCoordsXYStep) { - for (int16_t y = initial_y; y < final_y; y += COORDS_XY_STEP) + for (int16_t y = initial_y; y < final_y; y += kCoordsXYStep) { for (auto* tileElement : TileElementsView(CoordsXY{ x, y })) { @@ -3142,7 +3142,7 @@ template static void PeepHeadForNearestRide(Guest* peep, bool consid } if (peep->PeepFlags & PEEP_FLAGS_LEAVING_PARK) return; - if (peep->x == LOCATION_NULL) + if (peep->x == kLocationNull) return; if (!peep->GuestHeadingToRideId.IsNull()) { @@ -3171,9 +3171,9 @@ template static void PeepHeadForNearestRide(Guest* peep, bool consid constexpr auto searchRadius = 10 * 32; int32_t cx = Floor2(peep->x, 32); int32_t cy = Floor2(peep->y, 32); - for (auto x = cx - searchRadius; x <= cx + searchRadius; x += COORDS_XY_STEP) + for (auto x = cx - searchRadius; x <= cx + searchRadius; x += kCoordsXYStep) { - for (auto y = cy - searchRadius; y <= cy + searchRadius; y += COORDS_XY_STEP) + for (auto y = cy - searchRadius; y <= cy + searchRadius; y += kCoordsXYStep) { auto location = CoordsXY{ x, y }; if (!MapIsLocationValid(location)) @@ -4085,7 +4085,7 @@ void Guest::UpdateRideEnterVehicle() ride->cur_num_customers++; vehicle->ApplyMass(seatedGuest->Mass); - seatedGuest->MoveTo({ LOCATION_NULL, 0, 0 }); + seatedGuest->MoveTo({ kLocationNull, 0, 0 }); seatedGuest->SetState(PeepState::OnRide); seatedGuest->GuestTimeOnRide = 0; seatedGuest->RideSubState = PeepRideSubState::OnRide; @@ -4099,7 +4099,7 @@ void Guest::UpdateRideEnterVehicle() vehicle->ApplyMass(Mass); vehicle->Invalidate(); - MoveTo({ LOCATION_NULL, 0, 0 }); + MoveTo({ kLocationNull, 0, 0 }); SetState(PeepState::OnRide); @@ -4659,7 +4659,7 @@ void Guest::UpdateRideApproachSpiralSlide() SubState = 15; SetDestination({ 0, 0 }); Var37 = (Var37 / 4) & 0xC; - MoveTo({ LOCATION_NULL, y, z }); + MoveTo({ kLocationNull, y, z }); return; } @@ -6248,7 +6248,7 @@ static void PeepUpdateWalkingBreakScenery(Guest* peep) if (inner_peep->AssignedStaffType != StaffType::Security) continue; - if (inner_peep->x == LOCATION_NULL) + if (inner_peep->x == kLocationNull) continue; int32_t x_diff = abs(inner_peep->x - peep->x); @@ -6339,7 +6339,7 @@ bool Loc690FD0(Peep* peep, RideId* rideToView, uint8_t* rideSeatToView, TileElem *rideSeatToView = 1; if (ride->status != RideStatus::Open) { - if (tileElement->GetClearanceZ() > peep->NextLoc.z + (8 * COORDS_Z_STEP)) + if (tileElement->GetClearanceZ() > peep->NextLoc.z + (8 * kCoordsZStep)) { *rideSeatToView |= (1 << 1); } @@ -6352,7 +6352,7 @@ bool Loc690FD0(Peep* peep, RideId* rideToView, uint8_t* rideSeatToView, TileElem *rideSeatToView = 0; if (ride->status == RideStatus::Open && !(ride->lifecycle_flags & RIDE_LIFECYCLE_BROKEN_DOWN)) { - if (tileElement->GetClearanceZ() > peep->NextLoc.z + (8 * COORDS_Z_STEP)) + if (tileElement->GetClearanceZ() > peep->NextLoc.z + (8 * kCoordsZStep)) { *rideSeatToView = 0x02; } @@ -6402,9 +6402,9 @@ static bool PeepFindRideToLookAt(Peep* peep, uint8_t edge, RideId* rideToView, u auto wallEntry = tileElement->AsWall()->GetEntry(); if (wallEntry == nullptr || (wallEntry->flags2 & WALL_SCENERY_2_IS_OPAQUE)) continue; - if (peep->NextLoc.z + (4 * COORDS_Z_STEP) <= tileElement->GetBaseZ()) + if (peep->NextLoc.z + (4 * kCoordsZStep) <= tileElement->GetBaseZ()) continue; - if (peep->NextLoc.z + (1 * COORDS_Z_STEP) >= tileElement->GetClearanceZ()) + if (peep->NextLoc.z + (1 * kCoordsZStep) >= tileElement->GetClearanceZ()) continue; return false; @@ -6442,9 +6442,9 @@ static bool PeepFindRideToLookAt(Peep* peep, uint8_t edge, RideId* rideToView, u if (wallEntry == nullptr || (wallEntry->flags2 & WALL_SCENERY_2_IS_OPAQUE)) continue; // TODO: Check whether this shouldn't be <=, as the other loops use. If so, also extract as loop A. - if (peep->NextLoc.z + (4 * COORDS_Z_STEP) >= tileElement->GetBaseZ()) + if (peep->NextLoc.z + (4 * kCoordsZStep) >= tileElement->GetBaseZ()) continue; - if (peep->NextLoc.z + (1 * COORDS_Z_STEP) >= tileElement->GetClearanceZ()) + if (peep->NextLoc.z + (1 * kCoordsZStep) >= tileElement->GetClearanceZ()) continue; return false; @@ -6462,9 +6462,9 @@ static bool PeepFindRideToLookAt(Peep* peep, uint8_t edge, RideId* rideToView, u continue; } - if (tileElement->GetClearanceZ() + (1 * COORDS_Z_STEP) < peep->NextLoc.z) + if (tileElement->GetClearanceZ() + (1 * kCoordsZStep) < peep->NextLoc.z) continue; - if (peep->NextLoc.z + (6 * COORDS_Z_STEP) < tileElement->GetBaseZ()) + if (peep->NextLoc.z + (6 * kCoordsZStep) < tileElement->GetBaseZ()) continue; if (tileElement->GetType() == TileElementType::Track) @@ -6484,7 +6484,7 @@ static bool PeepFindRideToLookAt(Peep* peep, uint8_t edge, RideId* rideToView, u } *rideSeatToView = 0; - if (tileElement->GetClearanceZ() >= peep->NextLoc.z + (8 * COORDS_Z_STEP)) + if (tileElement->GetClearanceZ() >= peep->NextLoc.z + (8 * kCoordsZStep)) { *rideSeatToView = 0x02; } @@ -6506,9 +6506,9 @@ static bool PeepFindRideToLookAt(Peep* peep, uint8_t edge, RideId* rideToView, u if (tileElement->IsGhost()) continue; } - if (tileElement->GetClearanceZ() + (1 * COORDS_Z_STEP) < peep->NextLoc.z) + if (tileElement->GetClearanceZ() + (1 * kCoordsZStep) < peep->NextLoc.z) continue; - if (peep->NextLoc.z + (6 * COORDS_Z_STEP) < tileElement->GetBaseZ()) + if (peep->NextLoc.z + (6 * kCoordsZStep) < tileElement->GetBaseZ()) continue; if (tileElement->GetType() == TileElementType::Surface) continue; @@ -6560,7 +6560,7 @@ static bool PeepFindRideToLookAt(Peep* peep, uint8_t edge, RideId* rideToView, u auto wallEntry = tileElement->AsWall()->GetEntry(); if (wallEntry == nullptr || (wallEntry->flags2 & WALL_SCENERY_2_IS_OPAQUE)) continue; - if (peep->NextLoc.z + (6 * COORDS_Z_STEP) <= tileElement->GetBaseZ()) + if (peep->NextLoc.z + (6 * kCoordsZStep) <= tileElement->GetBaseZ()) continue; if (peep->NextLoc.z >= tileElement->GetClearanceZ()) continue; @@ -6579,9 +6579,9 @@ static bool PeepFindRideToLookAt(Peep* peep, uint8_t edge, RideId* rideToView, u if (tileElement->IsGhost()) continue; } - if (tileElement->GetClearanceZ() + (1 * COORDS_Z_STEP) < peep->NextLoc.z) + if (tileElement->GetClearanceZ() + (1 * kCoordsZStep) < peep->NextLoc.z) continue; - if (peep->NextLoc.z + (8 * COORDS_Z_STEP) < tileElement->GetBaseZ()) + if (peep->NextLoc.z + (8 * kCoordsZStep) < tileElement->GetBaseZ()) continue; if (tileElement->GetType() == TileElementType::Track) @@ -6601,7 +6601,7 @@ static bool PeepFindRideToLookAt(Peep* peep, uint8_t edge, RideId* rideToView, u } *rideSeatToView = 0; - if (tileElement->GetClearanceZ() >= peep->NextLoc.z + (8 * COORDS_Z_STEP)) + if (tileElement->GetClearanceZ() >= peep->NextLoc.z + (8 * kCoordsZStep)) { *rideSeatToView = 0x02; } @@ -6623,9 +6623,9 @@ static bool PeepFindRideToLookAt(Peep* peep, uint8_t edge, RideId* rideToView, u if (tileElement->IsGhost()) continue; } - if (tileElement->GetClearanceZ() + (1 * COORDS_Z_STEP) < peep->NextLoc.z) + if (tileElement->GetClearanceZ() + (1 * kCoordsZStep) < peep->NextLoc.z) continue; - if (peep->NextLoc.z + (8 * COORDS_Z_STEP) < tileElement->GetBaseZ()) + if (peep->NextLoc.z + (8 * kCoordsZStep) < tileElement->GetBaseZ()) continue; if (tileElement->GetType() == TileElementType::Surface) continue; @@ -6676,7 +6676,7 @@ static bool PeepFindRideToLookAt(Peep* peep, uint8_t edge, RideId* rideToView, u auto wallEntry = tileElement->AsWall()->GetEntry(); if (wallEntry == nullptr || (wallEntry->flags2 & WALL_SCENERY_2_IS_OPAQUE)) continue; - if (peep->NextLoc.z + (8 * COORDS_Z_STEP) <= tileElement->GetBaseZ()) + if (peep->NextLoc.z + (8 * kCoordsZStep) <= tileElement->GetBaseZ()) continue; if (peep->NextLoc.z >= tileElement->GetClearanceZ()) continue; @@ -6695,9 +6695,9 @@ static bool PeepFindRideToLookAt(Peep* peep, uint8_t edge, RideId* rideToView, u if (tileElement->IsGhost()) continue; } - if (tileElement->GetClearanceZ() + (1 * COORDS_Z_STEP) < peep->NextLoc.z) + if (tileElement->GetClearanceZ() + (1 * kCoordsZStep) < peep->NextLoc.z) continue; - if (peep->NextLoc.z + (10 * COORDS_Z_STEP) < tileElement->GetBaseZ()) + if (peep->NextLoc.z + (10 * kCoordsZStep) < tileElement->GetBaseZ()) continue; if (tileElement->GetType() == TileElementType::Track) @@ -6717,7 +6717,7 @@ static bool PeepFindRideToLookAt(Peep* peep, uint8_t edge, RideId* rideToView, u } *rideSeatToView = 0; - if (tileElement->GetClearanceZ() >= peep->NextLoc.z + (8 * COORDS_Z_STEP)) + if (tileElement->GetClearanceZ() >= peep->NextLoc.z + (8 * kCoordsZStep)) { *rideSeatToView = 0x02; } @@ -6819,7 +6819,7 @@ void Guest::UpdateSpriteType() if (SpriteType == PeepSpriteType::Balloon && (ScenarioRand() & 0xFFFF) <= 327) { bool isBalloonPopped = false; - if (x != LOCATION_NULL) + if (x != kLocationNull) { if ((ScenarioRand() & 0xFFFF) <= 13107) { @@ -6833,7 +6833,7 @@ void Guest::UpdateSpriteType() } const bool isPrecipitating = ClimateIsRaining() || ClimateIsSnowingHeavily(); - if (isPrecipitating && (HasItem(ShopItem::Umbrella)) && x != LOCATION_NULL) + if (isPrecipitating && (HasItem(ShopItem::Umbrella)) && x != kLocationNull) { CoordsXY loc = { x, y }; if (MapIsLocationValid(loc.ToTileStart())) diff --git a/src/openrct2/entity/Peep.cpp b/src/openrct2/entity/Peep.cpp index 62fda0d5eb..3d0a192b09 100644 --- a/src/openrct2/entity/Peep.cpp +++ b/src/openrct2/entity/Peep.cpp @@ -603,7 +603,7 @@ void Peep::Pickup() { guest->RemoveFromRide(); } - MoveTo({ LOCATION_NULL, y, z }); + MoveTo({ kLocationNull, y, z }); SetState(PeepState::Picked); SubState = 0; } @@ -615,7 +615,7 @@ void Peep::PickupAbort(int32_t old_x) MoveTo({ old_x, y, z + 8 }); - if (x != LOCATION_NULL) + if (x != kLocationNull) { SetState(PeepState::Falling); Action = PeepActionType::Walking; @@ -1308,7 +1308,7 @@ void PeepUpdateCrowdNoise() for (auto peep : EntityList()) { - if (peep->x == LOCATION_NULL) + if (peep->x == kLocationNull) continue; if (viewport->viewPos.x > peep->SpriteData.SpriteRect.GetRight()) continue; @@ -2570,7 +2570,7 @@ void Peep::PerformNextAction(uint8_t& pathing_result, TileElement*& tile_result) */ int32_t Peep::GetZOnSlope(int32_t tile_x, int32_t tile_y) { - if (tile_x == LOCATION_NULL) + if (tile_x == kLocationNull) return 0; if (GetNextIsSurface()) @@ -2730,7 +2730,7 @@ static void GuestReleaseBalloon(Guest* peep, int16_t spawn_height) { peep->RemoveItem(ShopItem::Balloon); - if (peep->SpriteType == PeepSpriteType::Balloon && peep->x != LOCATION_NULL) + if (peep->SpriteType == PeepSpriteType::Balloon && peep->x != kLocationNull) { Balloon::Create({ peep->x, peep->y, spawn_height }, peep->BalloonColour, false); peep->WindowInvalidateFlags |= PEEP_INVALIDATE_PEEP_INVENTORY; diff --git a/src/openrct2/entity/Peep.h b/src/openrct2/entity/Peep.h index 2689e8338a..23402d6d45 100644 --- a/src/openrct2/entity/Peep.h +++ b/src/openrct2/entity/Peep.h @@ -24,7 +24,7 @@ constexpr uint8_t kPeepMinEnergy = 32; constexpr uint8_t kPeepMaxEnergy = 128; constexpr uint8_t kPeepMaxEnergyTarget = 255; // Oddly, this differs from max energy! -constexpr auto PEEP_CLEARANCE_HEIGHT = 4 * COORDS_Z_STEP; +constexpr auto PEEP_CLEARANCE_HEIGHT = 4 * kCoordsZStep; class Formatter; struct TileElement; diff --git a/src/openrct2/entity/Staff.cpp b/src/openrct2/entity/Staff.cpp index 2f587f4928..fa2477f7b1 100644 --- a/src/openrct2/entity/Staff.cpp +++ b/src/openrct2/entity/Staff.cpp @@ -69,7 +69,7 @@ const StringId StaffCostumeNames[] = { // clang-format on // Maximum manhattan distance that litter can be for a handyman to seek to it -const uint16_t MAX_LITTER_DISTANCE = 3 * COORDS_XY_STEP; +const uint16_t MAX_LITTER_DISTANCE = 3 * kCoordsXYStep; template<> bool EntityBase::Is() const { @@ -183,7 +183,7 @@ bool Staff::CanIgnoreWideFlag(const CoordsXYZ& staffPos, TileElement* path) cons } /* test_element is a path */ - if (!PathFinding::IsValidPathZAndDirection(test_element, adjacPos.z / COORDS_Z_STEP, adjac_dir)) + if (!PathFinding::IsValidPathZAndDirection(test_element, adjacPos.z / kCoordsZStep, adjac_dir)) continue; /* test_element is a connected path */ @@ -228,22 +228,22 @@ uint8_t Staff::GetValidPatrolDirections(const CoordsXY& loc) const { uint8_t directions = 0; - if (IsLocationInPatrol({ loc.x - COORDS_XY_STEP, loc.y })) + if (IsLocationInPatrol({ loc.x - kCoordsXYStep, loc.y })) { directions |= (1 << 0); } - if (IsLocationInPatrol({ loc.x, loc.y + COORDS_XY_STEP })) + if (IsLocationInPatrol({ loc.x, loc.y + kCoordsXYStep })) { directions |= (1 << 1); } - if (IsLocationInPatrol({ loc.x + COORDS_XY_STEP, loc.y })) + if (IsLocationInPatrol({ loc.x + kCoordsXYStep, loc.y })) { directions |= (1 << 2); } - if (IsLocationInPatrol({ loc.x, loc.y - COORDS_XY_STEP })) + if (IsLocationInPatrol({ loc.x, loc.y - kCoordsXYStep })) { directions |= (1 << 3); } @@ -303,9 +303,9 @@ void Staff::SetPatrolArea(const CoordsXY& coords, bool value) void Staff::SetPatrolArea(const MapRange& range, bool value) { - for (int32_t yy = range.GetTop(); yy <= range.GetBottom(); yy += COORDS_XY_STEP) + for (int32_t yy = range.GetTop(); yy <= range.GetBottom(); yy += kCoordsXYStep) { - for (int32_t xx = range.GetLeft(); xx <= range.GetRight(); xx += COORDS_XY_STEP) + for (int32_t xx = range.GetLeft(); xx <= range.GetRight(); xx += kCoordsXYStep) { SetPatrolArea({ xx, yy }, value); } @@ -360,7 +360,7 @@ Direction Staff::HandymanDirectionToNearestLitter() const CoordsXY nextTile = litterTile.ToTileStart() - CoordsDirectionDelta[nextDirection]; - int16_t nextZ = ((z + COORDS_Z_STEP) & 0xFFF0) / COORDS_Z_STEP; + int16_t nextZ = ((z + kCoordsZStep) & 0xFFF0) / kCoordsZStep; TileElement* tileElement = MapGetFirstElementAt(nextTile); if (tileElement == nullptr) @@ -436,7 +436,7 @@ uint8_t Staff::HandymanDirectionToUncutGrass(uint8_t valid_directions) const auto surfaceElement = MapGetSurfaceElementAt(chosenTile); if (surfaceElement != nullptr) { - if (std::abs(surfaceElement->GetBaseZ() - NextLoc.z) <= 2 * COORDS_Z_STEP) + if (std::abs(surfaceElement->GetBaseZ() - NextLoc.z) <= 2 * kCoordsZStep) { if (surfaceElement->CanGrassGrow() && (surfaceElement->GetGrassLength() & 0x7) >= GRASS_LENGTH_CLEAR_1) { @@ -878,7 +878,7 @@ void Staff::EntertainerUpdateNearbyPeeps() const { for (auto guest : EntityList()) { - if (guest->x == LOCATION_NULL) + if (guest->x == kLocationNull) continue; int16_t z_dist = abs(z - guest->z); @@ -1139,7 +1139,7 @@ void Staff::UpdateWatering() if (tile_element->GetType() != TileElementType::SmallScenery) continue; - if (abs(NextLoc.z - tile_element->GetBaseZ()) > 4 * COORDS_Z_STEP) + if (abs(NextLoc.z - tile_element->GetBaseZ()) > 4 * kCoordsZStep) continue; const auto* sceneryEntry = tile_element->AsSmallScenery()->GetEntry(); @@ -1526,7 +1526,7 @@ bool Staff::UpdatePatrollingFindWatering() auto z_diff = abs(NextLoc.z - tile_element->GetBaseZ()); - if (z_diff >= 4 * COORDS_Z_STEP) + if (z_diff >= 4 * kCoordsZStep) { continue; } diff --git a/src/openrct2/interface/InteractiveConsole.cpp b/src/openrct2/interface/InteractiveConsole.cpp index c14b94a147..406992cb3b 100644 --- a/src/openrct2/interface/InteractiveConsole.cpp +++ b/src/openrct2/interface/InteractiveConsole.cpp @@ -1933,9 +1933,9 @@ static int32_t ConsoleSpawnBalloon(InteractiveConsole& console, const arguments_ console.WriteLineError("Need arguments: "); return 1; } - int32_t x = COORDS_XY_STEP * atof(argv[0].c_str()); - int32_t y = COORDS_XY_STEP * atof(argv[1].c_str()); - int32_t z = COORDS_Z_STEP * atof(argv[2].c_str()); + int32_t x = kCoordsXYStep * atof(argv[0].c_str()); + int32_t y = kCoordsXYStep * atof(argv[1].c_str()); + int32_t z = kCoordsZStep * atof(argv[2].c_str()); int32_t col = 28; if (argv.size() > 3) col = atoi(argv[3].c_str()); diff --git a/src/openrct2/interface/Screenshot.cpp b/src/openrct2/interface/Screenshot.cpp index 46f8ad2b96..3e785120b1 100644 --- a/src/openrct2/interface/Screenshot.cpp +++ b/src/openrct2/interface/Screenshot.cpp @@ -228,7 +228,7 @@ static int32_t GetHighestBaseClearanceZ(const CoordsXY& location, const bool use { do { - if (useViewClipping && (element->GetBaseZ() > gClipHeight * COORDS_Z_STEP)) + if (useViewClipping && (element->GetBaseZ() > gClipHeight * kCoordsZStep)) { continue; } @@ -535,8 +535,8 @@ int32_t CommandLineForScreenshot(const char** argv, int32_t argc, ScreenshotOpti const auto& mapSize = GetGameState().MapSize; if (resolutionWidth == 0 || resolutionHeight == 0) { - resolutionWidth = (mapSize.x * COORDS_XY_STEP * 2) >> customZoom; - resolutionHeight = (mapSize.y * COORDS_XY_STEP * 1) >> customZoom; + resolutionWidth = (mapSize.x * kCoordsXYStep * 2) >> customZoom; + resolutionHeight = (mapSize.y * kCoordsXYStep * 1) >> customZoom; resolutionWidth += 8; resolutionHeight += 128; diff --git a/src/openrct2/interface/Viewport.cpp b/src/openrct2/interface/Viewport.cpp index e8c293fdc5..fcb4f1e3b6 100644 --- a/src/openrct2/interface/Viewport.cpp +++ b/src/openrct2/interface/Viewport.cpp @@ -799,7 +799,7 @@ void ViewportUpdateSmartFollowGuest(WindowBase* window, const Guest& peep) bool overallFocus = true; if (peep.State == PeepState::OnRide || peep.State == PeepState::EnteringRide - || (peep.State == PeepState::LeavingRide && peep.x == LOCATION_NULL)) + || (peep.State == PeepState::LeavingRide && peep.x == kLocationNull)) { auto ride = GetRide(peep.CurrentRide); if (ride != nullptr && (ride->lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK)) @@ -818,7 +818,7 @@ void ViewportUpdateSmartFollowGuest(WindowBase* window, const Guest& peep) } } - if (peep.x == LOCATION_NULL && overallFocus) + if (peep.x == kLocationNull && overallFocus) { auto ride = GetRide(peep.CurrentRide); if (ride != nullptr) @@ -827,7 +827,7 @@ void ViewportUpdateSmartFollowGuest(WindowBase* window, const Guest& peep) CoordsXYZ coordFocus; coordFocus.x = xy.x; coordFocus.y = xy.y; - coordFocus.z = TileElementHeight(xy) + (4 * COORDS_Z_STEP); + coordFocus.z = TileElementHeight(xy) + (4 * kCoordsZStep); focus = Focus(coordFocus); window->viewport_target_sprite = EntityId::GetNull(); } diff --git a/src/openrct2/management/NewsItem.cpp b/src/openrct2/management/NewsItem.cpp index 6609edc647..85614b46a4 100644 --- a/src/openrct2/management/NewsItem.cpp +++ b/src/openrct2/management/NewsItem.cpp @@ -235,7 +235,7 @@ std::optional News::GetSubjectLocation(News::ItemType type, int32_t s break; subjectLoc = peep->GetLocation(); - if (subjectLoc->x != LOCATION_NULL) + if (subjectLoc->x != kLocationNull) break; if (peep->State != PeepState::OnRide && peep->State != PeepState::EnteringRide) diff --git a/src/openrct2/network/NetworkBase.cpp b/src/openrct2/network/NetworkBase.cpp index cc4c4f8187..5d2bfdca9f 100644 --- a/src/openrct2/network/NetworkBase.cpp +++ b/src/openrct2/network/NetworkBase.cpp @@ -54,7 +54,7 @@ constexpr uint8_t kNetworkStreamVersion = 0; const std::string kNetworkStreamID = std::string(OPENRCT2_VERSION) + "-" + std::to_string(kNetworkStreamVersion); static Peep* _pickup_peep = nullptr; -static int32_t _pickup_peep_old_x = LOCATION_NULL; +static int32_t _pickup_peep_old_x = kLocationNull; #ifndef DISABLE_NETWORK diff --git a/src/openrct2/network/NetworkPlayer.h b/src/openrct2/network/NetworkPlayer.h index 94e75fdcc8..6a816283ae 100644 --- a/src/openrct2/network/NetworkPlayer.h +++ b/src/openrct2/network/NetworkPlayer.h @@ -33,7 +33,7 @@ public: uint32_t LastActionTime = 0; CoordsXYZ LastActionCoord = {}; Peep* PickupPeep = nullptr; - int32_t PickupPeepOldX = LOCATION_NULL; + int32_t PickupPeepOldX = kLocationNull; std::string KeyHash; uint32_t LastDemolishRideTime = 0; uint32_t LastPlaceSceneryTime = 0; diff --git a/src/openrct2/paint/Paint.Entity.cpp b/src/openrct2/paint/Paint.Entity.cpp index cfb86ea057..b0e80ce84f 100644 --- a/src/openrct2/paint/Paint.Entity.cpp +++ b/src/openrct2/paint/Paint.Entity.cpp @@ -82,15 +82,15 @@ void EntityPaintSetup(PaintSession& session, const CoordsXY& pos) // height of the slope element, and consequently clipped. if ((session.ViewFlags & VIEWPORT_FLAG_CLIP_VIEW)) { - if (entityPos.z > (gClipHeight * COORDS_Z_STEP)) + if (entityPos.z > (gClipHeight * kCoordsZStep)) { continue; } - if (entityPos.x < gClipSelectionA.x || entityPos.x > (gClipSelectionB.x + COORDS_XY_STEP - 1)) + if (entityPos.x < gClipSelectionA.x || entityPos.x > (gClipSelectionB.x + kCoordsXYStep - 1)) { continue; } - if (entityPos.y < gClipSelectionA.y || entityPos.y > (gClipSelectionB.y + COORDS_XY_STEP - 1)) + if (entityPos.y < gClipSelectionA.y || entityPos.y > (gClipSelectionB.y + kCoordsXYStep - 1)) { continue; } diff --git a/src/openrct2/paint/Paint.cpp b/src/openrct2/paint/Paint.cpp index f3497c9a4a..14d89f612b 100644 --- a/src/openrct2/paint/Paint.cpp +++ b/src/openrct2/paint/Paint.cpp @@ -62,7 +62,7 @@ static ImageId PaintPSColourifyImage(const PaintStruct* ps, ImageId imageId, uin static int32_t RemapPositionToQuadrant(const PaintStruct& ps, uint8_t rotation) { - constexpr auto MapRangeMax = MaxPaintQuadrants * COORDS_XY_STEP; + constexpr auto MapRangeMax = MaxPaintQuadrants * kCoordsXYStep; constexpr auto MapRangeCenter = MapRangeMax / 2; const auto x = ps.Bounds.x; @@ -91,7 +91,7 @@ static void PaintSessionAddPSToQuadrant(PaintSession& session, PaintStruct* ps) const auto positionHash = RemapPositionToQuadrant(*ps, session.CurrentRotation); // Values below zero or above MaxPaintQuadrants are void, corners also share the same quadrant as void. - const uint32_t paintQuadrantIndex = std::clamp(positionHash / COORDS_XY_STEP, 0, MaxPaintQuadrants - 1); + const uint32_t paintQuadrantIndex = std::clamp(positionHash / kCoordsXYStep, 0, MaxPaintQuadrants - 1); ps->QuadrantIndex = paintQuadrantIndex; ps->NextQuadrantEntry = session.Quadrants[paintQuadrantIndex]; diff --git a/src/openrct2/paint/VirtualFloor.cpp b/src/openrct2/paint/VirtualFloor.cpp index 484242d44b..da9cecdf96 100644 --- a/src/openrct2/paint/VirtualFloor.cpp +++ b/src/openrct2/paint/VirtualFloor.cpp @@ -301,10 +301,10 @@ void VirtualFloorPaint(PaintSession& session) PROFILED_FUNCTION(); static constexpr CoordsXY scenery_half_tile_offsets[4] = { - { -COORDS_XY_STEP, 0 }, - { 0, COORDS_XY_STEP }, - { COORDS_XY_STEP, 0 }, - { 0, -COORDS_XY_STEP }, + { -kCoordsXYStep, 0 }, + { 0, kCoordsXYStep }, + { kCoordsXYStep, 0 }, + { 0, -kCoordsXYStep }, }; if (_virtualFloorHeight < kMinimumLandHeight) diff --git a/src/openrct2/paint/support/MetalSupports.cpp b/src/openrct2/paint/support/MetalSupports.cpp index ae146b5cf9..0ada6ae3fd 100644 --- a/src/openrct2/paint/support/MetalSupports.cpp +++ b/src/openrct2/paint/support/MetalSupports.cpp @@ -780,11 +780,11 @@ bool PathPoleSupportsPaintSetup( if (isSloped) { - int16_t si = baseHeight + COORDS_Z_STEP; + int16_t si = baseHeight + kCoordsZStep; while (true) { - int16_t z = baseHeight + (2 * COORDS_Z_STEP); + int16_t z = baseHeight + (2 * kCoordsZStep); if (z > si) { z = si; diff --git a/src/openrct2/paint/tile_element/Paint.Path.cpp b/src/openrct2/paint/tile_element/Paint.Path.cpp index a1397aaa1b..c4f8635a68 100644 --- a/src/openrct2/paint/tile_element/Paint.Path.cpp +++ b/src/openrct2/paint/tile_element/Paint.Path.cpp @@ -124,7 +124,7 @@ static void PathPaintQueueBanner( if (pathElement.IsSloped()) { if (pathElement.GetSlopeDirection() == direction) - height += COORDS_Z_STEP * 2; + height += kCoordsZStep * 2; } direction += session.CurrentRotation; direction &= 3; diff --git a/src/openrct2/paint/tile_element/Paint.Surface.cpp b/src/openrct2/paint/tile_element/Paint.Surface.cpp index f057f00b2b..a883ab0306 100644 --- a/src/openrct2/paint/tile_element/Paint.Surface.cpp +++ b/src/openrct2/paint/tile_element/Paint.Surface.cpp @@ -481,7 +481,7 @@ static bool TileIsInsideClipView(const TileDescriptor& tile) if (tile.tile_element == nullptr) return false; - if (tile.tile_element->GetBaseZ() > gClipHeight * COORDS_Z_STEP) + if (tile.tile_element->GetBaseZ() > gClipHeight * kCoordsZStep) return false; auto coords = tile.tile_coords.ToCoordsXY(); @@ -500,7 +500,7 @@ static void ViewportSurfaceDrawTileSideBottom( PROFILED_FUNCTION(); // From big Z to tiny Z - height /= COORDS_Z_PER_TINY_Z; + height /= kCoordsZPerTinyZ; int16_t cornerHeight1, neighbourCornerHeight1, cornerHeight2, neighbourCornerHeight2; CoordsXY offset = { 0, 0 }; @@ -556,7 +556,7 @@ static void ViewportSurfaceDrawTileSideBottom( if (isWater && neighbour.tile_element != nullptr) { - auto waterHeight = neighbour.tile_element->AsSurface()->GetWaterHeight() / (COORDS_Z_STEP * 2); + auto waterHeight = neighbour.tile_element->AsSurface()->GetWaterHeight() / (kCoordsZStep * 2); if (waterHeight == height && !neighbourIsClippedAway) { // Don't draw the edge when the neighbour's water level is the same @@ -598,7 +598,7 @@ static void ViewportSurfaceDrawTileSideBottom( if (curHeight != cornerHeight1 && curHeight != cornerHeight2) { auto imageId = baseImageId.WithIndexOffset(image_offset); - PaintAddImageAsParent(session, imageId, { offset, curHeight * COORDS_Z_PER_TINY_Z }, { bounds, 15 }); + PaintAddImageAsParent(session, imageId, { offset, curHeight * kCoordsZPerTinyZ }, { bounds, 15 }); curHeight++; } } @@ -622,7 +622,7 @@ static void ViewportSurfaceDrawTileSideBottom( } auto imageId = baseImageId.WithIndexOffset(image_offset); - PaintAddImageAsParent(session, imageId, { offset, curHeight * COORDS_Z_PER_TINY_Z }, { bounds, 15 }); + PaintAddImageAsParent(session, imageId, { offset, curHeight * kCoordsZPerTinyZ }, { bounds, 15 }); return; } @@ -637,7 +637,7 @@ static void ViewportSurfaceDrawTileSideBottom( if (isWater || curHeight != tunnelArray[tunnelIndex].height) { - PaintAddImageAsParent(session, baseImageId, { offset, curHeight * COORDS_Z_PER_TINY_Z }, { bounds, 15 }); + PaintAddImageAsParent(session, baseImageId, { offset, curHeight * kCoordsZPerTinyZ }, { bounds, 15 }); curHeight++; continue; @@ -671,7 +671,7 @@ static void ViewportSurfaceDrawTileSideBottom( PaintAddImageAsParent( session, imageId, { offset, zOffset }, { { 0, 0, boundBoxOffsetZ }, { tunnelBounds, boundBoxLength - 1 } }); - boundBoxOffsetZ = curHeight * COORDS_Z_PER_TINY_Z; + boundBoxOffsetZ = curHeight * kCoordsZPerTinyZ; boundBoxLength = td.boundBoxLength * 16; boundBoxOffsetZ += td.boundBoxZOffset; if (boundBoxOffsetZ == 0) @@ -682,7 +682,7 @@ static void ViewportSurfaceDrawTileSideBottom( imageId = GetTunnelImage(edgeObject, tunnelType, edge).WithIndexOffset(1); PaintAddImageAsParent( - session, imageId, { offset, curHeight * COORDS_Z_PER_TINY_Z }, + session, imageId, { offset, curHeight * kCoordsZPerTinyZ }, { { tunnelTopBoundBoxOffset, boundBoxOffsetZ }, { tunnelBounds, boundBoxLength - 1 } }); curHeight += td.height; @@ -697,7 +697,7 @@ static void ViewportSurfaceDrawTileSideTop( PROFILED_FUNCTION(); // From big Z to tiny Z - height /= COORDS_Z_PER_TINY_Z; + height /= kCoordsZPerTinyZ; int16_t cornerHeight1, neighbourCornerHeight1, cornerHeight2, neighbourCornerHeight2; @@ -742,7 +742,7 @@ static void ViewportSurfaceDrawTileSideTop( { if (isWater) { - auto waterHeight = neighbour.tile_element->AsSurface()->GetWaterHeight() / (COORDS_Z_STEP * 2); + auto waterHeight = neighbour.tile_element->AsSurface()->GetWaterHeight() / (kCoordsZStep * 2); if (height == waterHeight) { return; @@ -774,7 +774,7 @@ static void ViewportSurfaceDrawTileSideTop( { const uint8_t incline = (cornerHeight2 - cornerHeight1) + 1; const auto imageId = GetEdgeImage(edgeObject, 3).WithIndexOffset((edge == EDGE_TOPLEFT ? 3 : 0) + incline); - const int16_t y = (height - cornerHeight1) * COORDS_Z_PER_TINY_Z; + const int16_t y = (height - cornerHeight1) * kCoordsZPerTinyZ; PaintAttachToPreviousPS(session, imageId, 0, y); return; } @@ -795,7 +795,7 @@ static void ViewportSurfaceDrawTileSideTop( { auto imageId = baseImageId.WithIndexOffset(image_offset); PaintAddImageAsParent( - session, imageId, { offset.x, offset.y, cur_height * COORDS_Z_PER_TINY_Z }, { bounds.x, bounds.y, 15 }); + session, imageId, { offset.x, offset.y, cur_height * kCoordsZPerTinyZ }, { bounds.x, bounds.y, 15 }); cur_height++; } } @@ -810,7 +810,7 @@ static void ViewportSurfaceDrawTileSideTop( while (cur_height < cornerHeight1 && cur_height < neighbourCornerHeight1) { - PaintAddImageAsParent(session, baseImageId, { offset, cur_height * COORDS_Z_PER_TINY_Z }, { bounds, 15 }); + PaintAddImageAsParent(session, baseImageId, { offset, cur_height * kCoordsZPerTinyZ }, { bounds, 15 }); cur_height++; } @@ -826,7 +826,7 @@ static void ViewportSurfaceDrawTileSideTop( } auto imageId = baseImageId.WithIndexOffset(image_offset); - PaintAddImageAsParent(session, imageId, { offset, cur_height * COORDS_Z_PER_TINY_Z }, { bounds, 15 }); + PaintAddImageAsParent(session, imageId, { offset, cur_height * kCoordsZPerTinyZ }, { bounds, 15 }); } static std::pair SurfaceGetHeightAboveWater( @@ -1060,7 +1060,7 @@ void PaintSurface(PaintSession& session, uint8_t direction, uint16_t height, con } bool has_surface = false; - if (session.VerticalTunnelHeight * COORDS_Z_PER_TINY_Z == height) + if (session.VerticalTunnelHeight * kCoordsZPerTinyZ == height) { // Vertical tunnels PaintAddImageAsParent(session, ImageId(1575), { 0, 0, height }, { { -2, 1, height - 40 }, { 1, 30, 39 } }); @@ -1279,7 +1279,7 @@ void PaintSurface(PaintSession& session, uint8_t direction, uint16_t height, con } const uint16_t waterHeight = tileElement.GetWaterHeight(); - const bool waterGetsClipped = (session.ViewFlags & VIEWPORT_FLAG_CLIP_VIEW) && (waterHeight > gClipHeight * COORDS_Z_STEP); + const bool waterGetsClipped = (session.ViewFlags & VIEWPORT_FLAG_CLIP_VIEW) && (waterHeight > gClipHeight * kCoordsZStep); if (waterHeight > 0 && !gTrackDesignSaveMode && !waterGetsClipped) { diff --git a/src/openrct2/paint/tile_element/Paint.TileElement.cpp b/src/openrct2/paint/tile_element/Paint.TileElement.cpp index 2aa9ec2600..aa6386c00c 100644 --- a/src/openrct2/paint/tile_element/Paint.TileElement.cpp +++ b/src/openrct2/paint/tile_element/Paint.TileElement.cpp @@ -149,14 +149,14 @@ static void PaintTileElementBase(PaintSession& session, const CoordsXY& origCoor case 0: break; case 1: - coords.x += COORDS_XY_STEP; + coords.x += kCoordsXYStep; break; case 2: - coords.x += COORDS_XY_STEP; - coords.y += COORDS_XY_STEP; + coords.x += kCoordsXYStep; + coords.y += kCoordsXYStep; break; case 3: - coords.y += COORDS_XY_STEP; + coords.y += kCoordsXYStep; break; } @@ -219,7 +219,7 @@ static void PaintTileElementBase(PaintSession& session, const CoordsXY& origCoor } // Only paint tile_elements below the clip height. - if ((session.ViewFlags & VIEWPORT_FLAG_CLIP_VIEW) && (tile_element->GetBaseZ() > gClipHeight * COORDS_Z_STEP)) + if ((session.ViewFlags & VIEWPORT_FLAG_CLIP_VIEW) && (tile_element->GetBaseZ() > gClipHeight * kCoordsZStep)) continue; Direction direction = tile_element->GetDirectionWithOffset(rotation); diff --git a/src/openrct2/peep/GuestPathfinding.cpp b/src/openrct2/peep/GuestPathfinding.cpp index 93df66f3b2..bca06f148f 100644 --- a/src/openrct2/peep/GuestPathfinding.cpp +++ b/src/openrct2/peep/GuestPathfinding.cpp @@ -217,14 +217,14 @@ namespace OpenRCT2::PathFinding if (direction == 0 || direction == 2) { // Peep is moving along X, so apply the offset to the X position of the destination and clamp their current Y - const int32_t centreLine = (peep.y & 0xFFE0) + COORDS_XY_HALF_TILE; + const int32_t centreLine = (peep.y & 0xFFE0) + kCoordsXYHalfTile; newTile.x += offset; newTile.y = std::clamp(peep.y, centreLine - 3, centreLine + 3); } else { // Peep is moving along Y, so apply the offset to the Y position of the destination and clamp their current X - const int32_t centreLine = (peep.x & 0xFFE0) + COORDS_XY_HALF_TILE; + const int32_t centreLine = (peep.x & 0xFFE0) + kCoordsXYHalfTile; newTile.x = std::clamp(peep.x, centreLine - 3, centreLine + 3); newTile.y += offset; } diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 47c8dceff1..f8a2063313 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -1390,8 +1390,7 @@ namespace OpenRCT2::RCT1 x <<= 7; int32_t y = val & 0x3E0; y <<= 2; - staffmember->SetPatrolArea( - MapRange(x, y, x + (4 * COORDS_XY_STEP) - 1, y + (4 * COORDS_XY_STEP) - 1), true); + staffmember->SetPatrolArea(MapRange(x, y, x + (4 * kCoordsXYStep) - 1, y + (4 * kCoordsXYStep) - 1), true); } } } diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index 982edd97f0..31069ae466 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -416,7 +416,7 @@ namespace OpenRCT2::RCT2 gameState.Park.Entrances.clear(); for (uint8_t i = 0; i < Limits::kMaxParkEntrances; i++) { - if (_s6.ParkEntranceX[i] != LOCATION_NULL) + if (_s6.ParkEntranceX[i] != kLocationNull) { CoordsXYZD entrance; entrance.x = _s6.ParkEntranceX[i]; @@ -1599,7 +1599,7 @@ namespace OpenRCT2::RCT2 dst->totalAirTime = src->TotalAirTime; dst->current_test_station = StationIndex::FromUnderlying(src->CurrentTestStation); dst->num_circuits = src->NumCircuits; - dst->CableLiftLoc = { src->CableLiftX, src->CableLiftY, src->CableLiftZ * COORDS_Z_STEP }; + dst->CableLiftLoc = { src->CableLiftX, src->CableLiftY, src->CableLiftZ * kCoordsZStep }; // Pad1FD; dst->cable_lift = EntityId::FromUnderlying(src->CableLift); @@ -1869,8 +1869,8 @@ namespace OpenRCT2::RCT2 const auto rct12Type = src->GetType(); dst->ClearAs(ToOpenRCT2TileElementType(rct12Type)); dst->SetDirection(src->GetDirection()); - dst->SetBaseZ(src->BaseHeight * COORDS_Z_STEP); - dst->SetClearanceZ(src->ClearanceHeight * COORDS_Z_STEP); + dst->SetBaseZ(src->BaseHeight * kCoordsZStep); + dst->SetClearanceZ(src->ClearanceHeight * kCoordsZStep); // All saved in "flags" dst->SetOccupiedQuadrants(src->GetOccupiedQuadrants()); @@ -2204,8 +2204,7 @@ namespace OpenRCT2::RCT2 x <<= 7; int32_t y = val & 0xFC0; y <<= 1; - staffmember->SetPatrolArea( - MapRange(x, y, x + (4 * COORDS_XY_STEP) - 1, y + (4 * COORDS_XY_STEP) - 1), true); + staffmember->SetPatrolArea(MapRange(x, y, x + (4 * kCoordsXYStep) - 1, y + (4 * kCoordsXYStep) - 1), true); } } } @@ -2236,7 +2235,7 @@ namespace OpenRCT2::RCT2 { dst->SetName(GetUserString(src->NameStringIdx)); } - dst->NextLoc = { src->NextX, src->NextY, src->NextZ * COORDS_Z_STEP }; + dst->NextLoc = { src->NextX, src->NextY, src->NextZ * kCoordsZStep }; dst->NextFlags = src->NextFlags; dst->State = static_cast(src->State); dst->SubState = src->SubState; diff --git a/src/openrct2/ride/CableLift.cpp b/src/openrct2/ride/CableLift.cpp index 1009616a17..9c2fdde27e 100644 --- a/src/openrct2/ride/CableLift.cpp +++ b/src/openrct2/ride/CableLift.cpp @@ -65,7 +65,7 @@ Vehicle* CableLiftSegmentCreate( current->TrackSubposition = VehicleTrackSubposition::Default; current->Orientation = direction << 3; - z = z * COORDS_Z_STEP; + z = z * kCoordsZStep; current->TrackLocation = { x, y, z }; z += ride.GetRideTypeDescriptor().Heights.VehicleZOffset; diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index 8bc709aa93..646c0b4f03 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -506,8 +506,8 @@ bool RideTryGetOriginElement(const Ride& ride, CoordsXYE* output) if (output != nullptr) { output->element = resultTileElement; - output->x = it.x * COORDS_XY_STEP; - output->y = it.y * COORDS_XY_STEP; + output->x = it.x * kCoordsXYStep; + output->y = it.y * kCoordsXYStep; } } @@ -543,7 +543,7 @@ bool TrackBlockGetNextFromZero( if (tileElement == nullptr) { output->element = nullptr; - output->x = LOCATION_NULL; + output->x = kLocationNull; return false; } @@ -1190,10 +1190,10 @@ void UpdateChairlift(Ride& ride) return; auto bullwheelLoc = ride.ChairliftBullwheelLocation[0].ToCoordsXYZ(); - MapInvalidateTileZoom1({ bullwheelLoc, bullwheelLoc.z, bullwheelLoc.z + (4 * COORDS_Z_STEP) }); + MapInvalidateTileZoom1({ bullwheelLoc, bullwheelLoc.z, bullwheelLoc.z + (4 * kCoordsZStep) }); bullwheelLoc = ride.ChairliftBullwheelLocation[1].ToCoordsXYZ(); - MapInvalidateTileZoom1({ bullwheelLoc, bullwheelLoc.z, bullwheelLoc.z + (4 * COORDS_Z_STEP) }); + MapInvalidateTileZoom1({ bullwheelLoc, bullwheelLoc.z, bullwheelLoc.z + (4 * kCoordsZStep) }); } /** @@ -1835,7 +1835,7 @@ Staff* FindClosestMechanic(const CoordsXY& entrancePosition, int32_t forInspecti if (!peep->IsLocationInPatrol(location)) continue; - if (peep->x == LOCATION_NULL) + if (peep->x == kLocationNull) continue; // Manhattan distance @@ -5393,7 +5393,7 @@ static bool CheckForAdjacentStation(const CoordsXYZ& stationCoords, uint8_t dire adjX += CoordsDirectionDelta[direction].x; adjY += CoordsDirectionDelta[direction].y; TileElement* stationElement = GetStationPlatform( - { { adjX, adjY, stationCoords.z }, stationCoords.z + 2 * COORDS_Z_STEP }); + { { adjX, adjY, stationCoords.z }, stationCoords.z + 2 * kCoordsZStep }); if (stationElement != nullptr) { auto rideIndex = stationElement->AsTrack()->GetRideIndex(); diff --git a/src/openrct2/ride/Ride.h b/src/openrct2/ride/Ride.h index 17ccb73e2d..ca846c8f49 100644 --- a/src/openrct2/ride/Ride.h +++ b/src/openrct2/ride/Ride.h @@ -44,9 +44,9 @@ constexpr uint8_t kRideAdjacencyCheckDistance = 5; constexpr uint8_t TUNE_ID_NULL = 0xFF; -constexpr uint16_t const MAX_STATION_LOCATIONS = OpenRCT2::Limits::kMaxStationsPerRide * 2; // Entrance and exit per station +constexpr uint16_t MAX_STATION_LOCATIONS = OpenRCT2::Limits::kMaxStationsPerRide * 2; // Entrance and exit per station -constexpr uint16_t const MAZE_CLEARANCE_HEIGHT = 4 * COORDS_Z_STEP; +constexpr uint16_t MAZE_CLEARANCE_HEIGHT = 4 * kCoordsZStep; constexpr uint8_t kRideMaxDropsCount = 63; constexpr uint8_t kRideNumDropsMask = 0b00111111; diff --git a/src/openrct2/ride/RideConstruction.cpp b/src/openrct2/ride/RideConstruction.cpp index d9af3cdcd3..c6eb5ba421 100644 --- a/src/openrct2/ride/RideConstruction.cpp +++ b/src/openrct2/ride/RideConstruction.cpp @@ -260,8 +260,8 @@ void Ride::RemovePeeps() { auto direction = DirectionReverse(location.direction); exitPosition = location; - exitPosition.x += (DirectionOffsets[direction].x * 20) + COORDS_XY_HALF_TILE; - exitPosition.y += (DirectionOffsets[direction].y * 20) + COORDS_XY_HALF_TILE; + exitPosition.x += (DirectionOffsets[direction].x * 20) + kCoordsXYHalfTile; + exitPosition.y += (DirectionOffsets[direction].y * 20) + kCoordsXYHalfTile; exitPosition.z += 2; // Reverse direction @@ -288,7 +288,7 @@ void Ride::RemovePeeps() { CoordsXYZ newLoc = { peep->NextLoc.ToTileCentre(), peep->NextLoc.z }; if (peep->GetNextIsSloped()) - newLoc.z += COORDS_Z_STEP; + newLoc.z += kCoordsZStep; newLoc.z++; peep->MoveTo(newLoc); } @@ -318,7 +318,7 @@ void Ride::RemovePeeps() { CoordsXYZ newLoc = { peep->NextLoc.ToTileCentre(), peep->NextLoc.z }; if (peep->GetNextIsSloped()) - newLoc.z += COORDS_Z_STEP; + newLoc.z += kCoordsZStep; newLoc.z++; peep->MoveTo(newLoc); } diff --git a/src/openrct2/ride/RideData.h b/src/openrct2/ride/RideData.h index 89ab0723ae..6423f13573 100644 --- a/src/openrct2/ride/RideData.h +++ b/src/openrct2/ride/RideData.h @@ -38,13 +38,13 @@ enum class ResearchCategory : uint8_t; -constexpr const uint8_t DefaultFoodStallHeight = 8 * COORDS_Z_STEP; -constexpr const uint8_t DefaultDrinksStallHeight = 8 * COORDS_Z_STEP; -constexpr const uint8_t DefaultShopHeight = 8 * COORDS_Z_STEP; -constexpr const uint8_t DefaultToiletHeight = 4 * COORDS_Z_STEP; -constexpr const uint8_t DefaultInformationKioskHeight = 6 * COORDS_Z_STEP; -constexpr const uint8_t DefaultFirstAidHeight = 6 * COORDS_Z_STEP; -constexpr const uint8_t DefaultCashMachineHeight = 8 * COORDS_Z_STEP; +constexpr uint8_t DefaultFoodStallHeight = 8 * kCoordsZStep; +constexpr uint8_t DefaultDrinksStallHeight = 8 * kCoordsZStep; +constexpr uint8_t DefaultShopHeight = 8 * kCoordsZStep; +constexpr uint8_t DefaultToiletHeight = 4 * kCoordsZStep; +constexpr uint8_t DefaultInformationKioskHeight = 6 * kCoordsZStep; +constexpr uint8_t DefaultFirstAidHeight = 6 * kCoordsZStep; +constexpr uint8_t DefaultCashMachineHeight = 8 * kCoordsZStep; struct RideComponentName { diff --git a/src/openrct2/ride/RideRatings.cpp b/src/openrct2/ride/RideRatings.cpp index b677e18800..a54bdddfff 100644 --- a/src/openrct2/ride/RideRatings.cpp +++ b/src/openrct2/ride/RideRatings.cpp @@ -584,7 +584,7 @@ static void ride_ratings_score_close_proximity_in_direction( } break; case TileElementType::Path: - if (abs(inputTileElement->GetBaseZ() - tileElement->GetBaseZ()) <= 2 * COORDS_Z_STEP) + if (abs(inputTileElement->GetBaseZ() - tileElement->GetBaseZ()) <= 2 * kCoordsZStep) { proximity_score_increment(state, PROXIMITY_PATH_SIDE_CLOSE); } @@ -592,7 +592,7 @@ static void ride_ratings_score_close_proximity_in_direction( case TileElementType::Track: if (inputTileElement->AsTrack()->GetRideIndex() != tileElement->AsTrack()->GetRideIndex()) { - if (abs(inputTileElement->GetBaseZ() - tileElement->GetBaseZ()) <= 2 * COORDS_Z_STEP) + if (abs(inputTileElement->GetBaseZ() - tileElement->GetBaseZ()) <= 2 * kCoordsZStep) { proximity_score_increment(state, PROXIMITY_FOREIGN_TRACK_SIDE_CLOSE); } diff --git a/src/openrct2/ride/Station.cpp b/src/openrct2/ride/Station.cpp index 69ace102fb..01d785290d 100644 --- a/src/openrct2/ride/Station.cpp +++ b/src/openrct2/ride/Station.cpp @@ -410,12 +410,12 @@ StationIndex RideGetFirstEmptyStationStart(const Ride& ride) int32_t RideStation::GetBaseZ() const { - return Height * COORDS_Z_STEP; + return Height * kCoordsZStep; } void RideStation::SetBaseZ(int32_t newZ) { - Height = newZ / COORDS_Z_STEP; + Height = newZ / kCoordsZStep; } CoordsXYZ RideStation::GetStart() const diff --git a/src/openrct2/ride/Track.cpp b/src/openrct2/ride/Track.cpp index c69b48aca5..0ddf359706 100644 --- a/src/openrct2/ride/Track.cpp +++ b/src/openrct2/ride/Track.cpp @@ -138,7 +138,7 @@ ResultWithMessage TrackAddStationElement(CoordsXYZD loc, RideId rideIndex, int32 auto& station = ride->GetStation(stationIndex); station.Start.x = loc.x; station.Start.y = loc.y; - station.Height = loc.z / COORDS_Z_STEP; + station.Height = loc.z / kCoordsZStep; station.Depart = 1; station.Length = 0; ride->num_stations++; @@ -229,7 +229,7 @@ ResultWithMessage TrackAddStationElement(CoordsXYZD loc, RideId rideIndex, int32 { auto& station = ride->GetStation(stationIndex); station.Start = loc; - station.Height = loc.z / COORDS_Z_STEP; + station.Height = loc.z / kCoordsZStep; station.Depart = 1; station.Length = stationLength; ride->num_stations++; @@ -364,7 +364,7 @@ ResultWithMessage TrackRemoveStationElement(const CoordsXYZD& loc, RideId rideIn { auto& station = ride->GetStation(stationIndex); station.Start = currentLoc; - station.Height = currentLoc.z / COORDS_Z_STEP; + station.Height = currentLoc.z / kCoordsZStep; station.Depart = 1; station.Length = stationLength != 0 ? stationLength : ByteF441D1; ride->num_stations++; diff --git a/src/openrct2/ride/Track.h b/src/openrct2/ride/Track.h index f143667dc5..52ed5be4f3 100644 --- a/src/openrct2/ride/Track.h +++ b/src/openrct2/ride/Track.h @@ -125,7 +125,7 @@ enum }; constexpr int8_t kMaxStationPlatformLength = 32; -constexpr uint16_t const MAX_TRACK_HEIGHT = 254 * COORDS_Z_STEP; +constexpr uint16_t const MAX_TRACK_HEIGHT = 254 * kCoordsZStep; constexpr uint8_t const DEFAULT_SEAT_ROTATION = 4; // Vehicle sprite groups required by track groups are defined in ride_entry_get_supported_track_pieces diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index 9c435bb4de..dd3895be15 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -317,7 +317,7 @@ ResultWithMessage TrackDesign::CreateTrackDesignTrack(TrackDesignState& tds, con auto rotatedMapLocation = TileCoordsXY(mapLocation.Rotate(0 - _saveDirection)); z -= tds.origin.z; - z /= COORDS_Z_STEP; + z /= kCoordsZStep; if (z > 127 || z < -126) { @@ -363,9 +363,9 @@ ResultWithMessage TrackDesign::CreateTrackDesignMaze(TrackDesignState& tds, cons // x is defined here as we can start the search // on tile start_x, start_y but then the next row // must restart on 0 - for (int32_t y = startLoc.y, x = startLoc.x; y < MAXIMUM_MAP_SIZE_BIG; y += COORDS_XY_STEP) + for (int32_t y = startLoc.y, x = startLoc.x; y < MAXIMUM_MAP_SIZE_BIG; y += kCoordsXYStep) { - for (; x < MAXIMUM_MAP_SIZE_BIG; x += COORDS_XY_STEP) + for (; x < MAXIMUM_MAP_SIZE_BIG; x += kCoordsXYStep) { auto tileElement = MapGetFirstElementAt(CoordsXY{ x, y }); do @@ -380,8 +380,8 @@ ResultWithMessage TrackDesign::CreateTrackDesignMaze(TrackDesignState& tds, cons TrackDesignMazeElement maze{}; maze.mazeEntry = tileElement->AsTrack()->GetMazeEntry(); - maze.location.x = (x - startLoc.x) / COORDS_XY_STEP; - maze.location.y = (y - startLoc.y) / COORDS_XY_STEP; + maze.location.x = (x - startLoc.x) / kCoordsXYStep; + maze.location.y = (y - startLoc.y) / kCoordsXYStep; _saveDirection = tileElement->GetDirection(); mazeElements.push_back(maze); @@ -465,9 +465,9 @@ ResultWithMessage TrackDesign::CreateTrackDesignMaze(TrackDesignState& tds, cons CoordsXYE TrackDesign::MazeGetFirstElement(const Ride& ride) { CoordsXYE tile{}; - for (tile.y = 0; tile.y < MAXIMUM_MAP_SIZE_BIG; tile.y += COORDS_XY_STEP) + for (tile.y = 0; tile.y < MAXIMUM_MAP_SIZE_BIG; tile.y += kCoordsXYStep) { - for (tile.x = 0; tile.x < MAXIMUM_MAP_SIZE_BIG; tile.x += COORDS_XY_STEP) + for (tile.x = 0; tile.x < MAXIMUM_MAP_SIZE_BIG; tile.x += kCoordsXYStep) { tile.element = MapGetFirstElementAt(CoordsXY{ tile.x, tile.y }); do @@ -526,13 +526,13 @@ ResultWithMessage TrackDesign::CreateTrackDesignScenery(TrackDesignState& tds) const auto relativeMapPosition = scenery.loc - tds.origin; const CoordsXY rotatedRelativeMapPos = relativeMapPosition.Rotate(0 - _saveDirection); - if (rotatedRelativeMapPos.x > 127 * COORDS_XY_STEP || rotatedRelativeMapPos.y > 127 * COORDS_XY_STEP - || rotatedRelativeMapPos.x < -126 * COORDS_XY_STEP || rotatedRelativeMapPos.y < -126 * COORDS_XY_STEP) + if (rotatedRelativeMapPos.x > 127 * kCoordsXYStep || rotatedRelativeMapPos.y > 127 * kCoordsXYStep + || rotatedRelativeMapPos.x < -126 * kCoordsXYStep || rotatedRelativeMapPos.y < -126 * kCoordsXYStep) { return { false, STR_TRACK_TOO_LARGE_OR_TOO_MUCH_SCENERY }; } - if (relativeMapPosition.z > 127 * COORDS_Z_STEP || relativeMapPosition.z < -126 * COORDS_Z_STEP) + if (relativeMapPosition.z > 127 * kCoordsZStep || relativeMapPosition.z < -126 * kCoordsZStep) { return { false, STR_TRACK_TOO_LARGE_OR_TOO_MUCH_SCENERY }; } @@ -1328,7 +1328,7 @@ static std::optional TrackDesignPlaceEntrances( case TrackPlaceOperation::placeTrackPreview: { rotation = (rotation + entrance.location.direction) & 3; - newCoords.z = entrance.location.z * COORDS_Z_STEP; + newCoords.z = entrance.location.z * kCoordsZStep; newCoords.z += tds.origin.z; if (tds.placeOperation != TrackPlaceOperation::placeQuery) diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index da97ad8766..68f2d81059 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -388,14 +388,14 @@ static constexpr Unk9A36C4Struct Unk9A36C4[] = { /** rct2: 0x009A37C4 */ static constexpr CoordsXY SurroundingTiles[] = { { 0, 0 }, - { 0, +COORDS_XY_STEP }, - { +COORDS_XY_STEP, 0 }, - { 0, -COORDS_XY_STEP }, - { 0, -COORDS_XY_STEP }, - { -COORDS_XY_STEP, 0 }, - { -COORDS_XY_STEP, 0 }, - { 0, +COORDS_XY_STEP }, - { 0, +COORDS_XY_STEP }, + { 0, +kCoordsXYStep }, + { +kCoordsXYStep, 0 }, + { 0, -kCoordsXYStep }, + { 0, -kCoordsXYStep }, + { -kCoordsXYStep, 0 }, + { -kCoordsXYStep, 0 }, + { 0, +kCoordsXYStep }, + { 0, +kCoordsXYStep }, }; /** rct2: 0x009A37E4 */ @@ -1018,7 +1018,7 @@ void Vehicle::UpdateMeasurements() { curRide->testing_flags &= ~RIDE_TESTING_DROP_DOWN; - int16_t curZ = z / COORDS_Z_STEP - curRide->start_drop_height; + int16_t curZ = z / kCoordsZStep - curRide->start_drop_height; if (curZ < 0) { curZ = abs(curZ); @@ -1039,7 +1039,7 @@ void Vehicle::UpdateMeasurements() drops++; curRide->setNumDrops(drops); - curRide->start_drop_height = z / COORDS_Z_STEP; + curRide->start_drop_height = z / kCoordsZStep; testingFlags &= ~RIDE_TESTING_DROP_UP; } @@ -1049,7 +1049,7 @@ void Vehicle::UpdateMeasurements() { curRide->testing_flags &= ~RIDE_TESTING_DROP_UP; - int16_t curZ = z / COORDS_Z_STEP - curRide->start_drop_height; + int16_t curZ = z / kCoordsZStep - curRide->start_drop_height; if (curZ < 0) { curZ = abs(curZ); @@ -1070,7 +1070,7 @@ void Vehicle::UpdateMeasurements() drops++; curRide->setNumDrops(drops); - curRide->start_drop_height = z / COORDS_Z_STEP; + curRide->start_drop_height = z / kCoordsZStep; } if (trackFlags & TRACK_ELEM_FLAG_HELIX) @@ -1087,7 +1087,7 @@ void Vehicle::UpdateMeasurements() if (currentStation.Entrance.IsNull()) return; - if (x == LOCATION_NULL) + if (x == kLocationNull) { curRide->testing_flags &= ~RIDE_TESTING_SHELTERED; return; @@ -1979,7 +1979,7 @@ static bool try_add_synchronised_station(const CoordsXYZ& coords) return false; } - TileElement* tileElement = GetStationPlatform({ coords, coords.z + 2 * COORDS_Z_STEP }); + TileElement* tileElement = GetStationPlatform({ coords, coords.z + 2 * kCoordsZStep }); if (tileElement == nullptr) { /* No station platform element found, @@ -3799,14 +3799,14 @@ void Vehicle::UpdateMotionBoatHire() if (!(curRide->boat_hire_return_direction & 1)) { - uint16_t tilePart = loc2.y % COORDS_XY_STEP; - if (tilePart == COORDS_XY_HALF_TILE) + uint16_t tilePart = loc2.y % kCoordsXYStep; + if (tilePart == kCoordsXYHalfTile) { TryReconnectBoatToTrack(loc2, flooredLocation); break; } loc2 = _vehicleCurPosition; - if (tilePart <= COORDS_XY_HALF_TILE) + if (tilePart <= kCoordsXYHalfTile) { loc2.y += 1; } @@ -3818,14 +3818,14 @@ void Vehicle::UpdateMotionBoatHire() else { // Loc6DA9A2: - uint16_t tilePart = loc2.x % COORDS_XY_STEP; - if (tilePart == COORDS_XY_HALF_TILE) + uint16_t tilePart = loc2.x % kCoordsXYStep; + if (tilePart == kCoordsXYHalfTile) { TryReconnectBoatToTrack(loc2, flooredLocation); break; } loc2 = _vehicleCurPosition; - if (tilePart <= COORDS_XY_HALF_TILE) + if (tilePart <= kCoordsXYHalfTile) { loc2.x += 1; } @@ -3988,8 +3988,8 @@ static bool vehicle_boat_is_location_accessible(const CoordsXYZ& location) } else { - if (location.z > (tileElement->GetBaseZ() - (2 * COORDS_Z_STEP)) - && location.z < tileElement->GetClearanceZ() + (2 * COORDS_Z_STEP)) + if (location.z > (tileElement->GetBaseZ() - (2 * kCoordsZStep)) + && location.z < tileElement->GetClearanceZ() + (2 * kCoordsZStep)) { return false; } @@ -7904,7 +7904,7 @@ Loc6DC462: for (;;) { moveInfo = GetMoveInfo(); - if (moveInfo->x != LOCATION_NULL) + if (moveInfo->x != kLocationNull) { break; } diff --git a/src/openrct2/ride/VehicleSubpositionData.cpp b/src/openrct2/ride/VehicleSubpositionData.cpp index 2198632a23..9232ee3a29 100644 --- a/src/openrct2/ride/VehicleSubpositionData.cpp +++ b/src/openrct2/ride/VehicleSubpositionData.cpp @@ -17,16 +17,16 @@ using namespace OpenRCT2; static constexpr VehicleInfo VAR##_data[] = __VA_ARGS__; \ static constexpr VehicleInfoList VAR = { static_cast(std::size(VAR##_data)), VAR##_data }; +// clang-format off #define MINI_GOLF_STATE(STATE) \ { \ - LOCATION_NULL, EnumValue(MiniGolfState::STATE), 0, 0, 0, 0 \ + kLocationNull, EnumValue(MiniGolfState::STATE), 0, 0, 0, 0 \ } #define MINI_GOLF_ANIMATION(VALUE) \ { \ - LOCATION_NULL, EnumValue(MiniGolfState::Unk4), EnumValue(MiniGolfAnimation::VALUE), 0, 0, 0 \ + kLocationNull, EnumValue(MiniGolfState::Unk4), EnumValue(MiniGolfAnimation::VALUE), 0, 0, 0 \ } -// clang-format off CREATE_VEHICLE_INFO(TrackVehicleInfo_8BE57A, { { 31, 16, 0, 0, 0, 0 }, { 30, 16, 0, 0, 0, 0 }, { 29, 16, 0, 0, 0, 0 }, { 28, 16, 0, 0, 0, 0 }, { 27, 16, 0, 0, 0, 0 }, { 26, 16, 0, 0, 0, 0 }, { 25, 16, 0, 0, 0, 0 }, { 24, 16, 0, 0, 0, 0 }, { 23, 16, 0, 0, 0, 0 }, { 22, 16, 0, 0, 0, 0 }, diff --git a/src/openrct2/ride/gentle/Maze.cpp b/src/openrct2/ride/gentle/Maze.cpp index 08f9378f83..42cdb5a1b4 100644 --- a/src/openrct2/ride/gentle/Maze.cpp +++ b/src/openrct2/ride/gentle/Maze.cpp @@ -207,7 +207,7 @@ money64 MazeCalculateCost(money64 constructionCost, const Ride& ride, const Coor money64 price = (ride.GetRideTypeDescriptor().BuildCosts.TrackPrice * ted.PriceModifier) >> 16; auto surfaceElement = MapGetSurfaceElementAt(loc); - auto heightDifference = (loc.z - surfaceElement->GetBaseZ()) / COORDS_Z_PER_TINY_Z; + auto heightDifference = (loc.z - surfaceElement->GetBaseZ()) / kCoordsZPerTinyZ; money64 supportCost = heightDifference * ride.GetRideTypeDescriptor().BuildCosts.SupportPrice; return constructionCost + price + supportCost; diff --git a/src/openrct2/scripting/bindings/entity/ScStaff.cpp b/src/openrct2/scripting/bindings/entity/ScStaff.cpp index 1224b65750..271b88dd72 100644 --- a/src/openrct2/scripting/bindings/entity/ScStaff.cpp +++ b/src/openrct2/scripting/bindings/entity/ScStaff.cpp @@ -639,9 +639,9 @@ namespace OpenRCT2::Scripting else { auto mapRange = FromDuk(coordsOrRange); - for (int32_t y = mapRange.GetTop(); y <= mapRange.GetBottom(); y += COORDS_XY_STEP) + for (int32_t y = mapRange.GetTop(); y <= mapRange.GetBottom(); y += kCoordsXYStep) { - for (int32_t x = mapRange.GetLeft(); x <= mapRange.GetRight(); x += COORDS_XY_STEP) + for (int32_t x = mapRange.GetLeft(); x <= mapRange.GetRight(); x += kCoordsXYStep) { CoordsXY coord(x, y); staff->SetPatrolArea(coord, value); diff --git a/src/openrct2/scripting/bindings/world/ScPark.cpp b/src/openrct2/scripting/bindings/world/ScPark.cpp index 8c28008717..066d5c04a6 100644 --- a/src/openrct2/scripting/bindings/world/ScPark.cpp +++ b/src/openrct2/scripting/bindings/world/ScPark.cpp @@ -384,7 +384,7 @@ namespace OpenRCT2::Scripting text = message["text"].as_string(); if (type == News::ItemType::Blank) { - assoc = static_cast(((COORDS_NULL & 0xFFFF) << 16) | (COORDS_NULL & 0xFFFF)); + assoc = static_cast(((kCoordsNull & 0xFFFF) << 16) | (kCoordsNull & 0xFFFF)); } auto dukSubject = message["subject"]; diff --git a/src/openrct2/scripting/bindings/world/ScTile.cpp b/src/openrct2/scripting/bindings/world/ScTile.cpp index 3113592e72..e04fd9385b 100644 --- a/src/openrct2/scripting/bindings/world/ScTile.cpp +++ b/src/openrct2/scripting/bindings/world/ScTile.cpp @@ -36,12 +36,12 @@ namespace OpenRCT2::Scripting int32_t ScTile::x_get() const { - return _coords.x / COORDS_XY_STEP; + return _coords.x / kCoordsXYStep; } int32_t ScTile::y_get() const { - return _coords.y / COORDS_XY_STEP; + return _coords.y / kCoordsXYStep; } uint32_t ScTile::numElements_get() const diff --git a/src/openrct2/world/Banner.cpp b/src/openrct2/world/Banner.cpp index 39185532d7..2a12414a9c 100644 --- a/src/openrct2/world/Banner.cpp +++ b/src/openrct2/world/Banner.cpp @@ -107,7 +107,7 @@ static RideId BannerGetRideIndexAt(const CoordsXYZ& bannerCoords) if (ride == nullptr || ride->GetRideTypeDescriptor().HasFlag(RIDE_TYPE_FLAG_IS_SHOP_OR_FACILITY)) continue; - if ((tileElement->GetClearanceZ()) + (4 * COORDS_Z_STEP) <= bannerCoords.z) + if ((tileElement->GetClearanceZ()) + (4 * kCoordsZStep) <= bannerCoords.z) continue; resultRideIndex = rideIndex; @@ -201,14 +201,14 @@ WallElement* BannerGetScrollingWallTileElement(BannerIndex bannerIndex) RideId BannerGetClosestRideIndex(const CoordsXYZ& mapPos) { static constexpr std::array NeighbourCheckOrder = { - CoordsXY{ COORDS_XY_STEP, 0 }, - CoordsXY{ -COORDS_XY_STEP, 0 }, - CoordsXY{ 0, COORDS_XY_STEP }, - CoordsXY{ 0, -COORDS_XY_STEP }, - CoordsXY{ -COORDS_XY_STEP, +COORDS_XY_STEP }, - CoordsXY{ +COORDS_XY_STEP, -COORDS_XY_STEP }, - CoordsXY{ +COORDS_XY_STEP, +COORDS_XY_STEP }, - CoordsXY{ -COORDS_XY_STEP, +COORDS_XY_STEP }, + CoordsXY{ kCoordsXYStep, 0 }, + CoordsXY{ -kCoordsXYStep, 0 }, + CoordsXY{ 0, kCoordsXYStep }, + CoordsXY{ 0, -kCoordsXYStep }, + CoordsXY{ -kCoordsXYStep, +kCoordsXYStep }, + CoordsXY{ +kCoordsXYStep, -kCoordsXYStep }, + CoordsXY{ +kCoordsXYStep, +kCoordsXYStep }, + CoordsXY{ -kCoordsXYStep, +kCoordsXYStep }, CoordsXY{ 0, 0 }, }; diff --git a/src/openrct2/world/ConstructionClearance.cpp b/src/openrct2/world/ConstructionClearance.cpp index 65f8b5337f..1a643c58f9 100644 --- a/src/openrct2/world/ConstructionClearance.cpp +++ b/src/openrct2/world/ConstructionClearance.cpp @@ -194,7 +194,7 @@ GameActions::Result MapCanConstructWithClearAt( { const auto heightFromGround = pos.clearanceZ - tileElement->GetBaseZ(); - if (heightFromGround > (18 * COORDS_Z_STEP)) + if (heightFromGround > (18 * kCoordsZStep)) { res.Error = GameActions::Status::Disallowed; res.ErrorMessage = STR_LOCAL_AUTHORITY_WONT_ALLOW_CONSTRUCTION_ABOVE_TREE_HEIGHT; @@ -248,7 +248,7 @@ GameActions::Result MapCanConstructWithClearAt( if (slope == (kTileSlopeECornerDown | kTileSlopeDiagonalFlag)) westZ += LAND_HEIGHT_STEP; } - const auto baseHeight = pos.baseZ + (4 * COORDS_Z_STEP); + const auto baseHeight = pos.baseZ + (4 * kCoordsZStep); const auto baseQuarter = quarterTile.GetBaseQuarterOccupied(); const auto zQuarter = quarterTile.GetZQuarterOccupied(); if ((!(baseQuarter & 0b0001) || ((zQuarter & 0b0001 || pos.baseZ >= northZ) && baseHeight >= northZ)) diff --git a/src/openrct2/world/Entrance.h b/src/openrct2/world/Entrance.h index 8ff01578a1..0ea355a279 100644 --- a/src/openrct2/world/Entrance.h +++ b/src/openrct2/world/Entrance.h @@ -27,14 +27,14 @@ namespace OpenRCT2::EntranceSequence constexpr uint8_t Right = 2; }; // namespace OpenRCT2::EntranceSequence -constexpr const uint8_t ParkEntranceHeight = 12 * COORDS_Z_STEP; -constexpr const uint8_t RideEntranceHeight = 7 * COORDS_Z_STEP; -constexpr const uint8_t RideExitHeight = 5 * COORDS_Z_STEP; +constexpr uint8_t ParkEntranceHeight = 12 * kCoordsZStep; +constexpr uint8_t RideEntranceHeight = 7 * kCoordsZStep; +constexpr uint8_t RideExitHeight = 5 * kCoordsZStep; extern bool gParkEntranceGhostExists; extern CoordsXYZD gParkEntranceGhostPosition; -constexpr int32_t MaxRideEntranceOrExitHeight = 244 * COORDS_Z_STEP; +constexpr int32_t MaxRideEntranceOrExitHeight = 244 * kCoordsZStep; extern CoordsXYZD gRideEntranceExitGhostPosition; extern StationIndex gRideEntranceExitGhostStationIndex; diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index 2c548f8f9c..debd4b90ca 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -74,7 +74,7 @@ const std::array BinUseOffsets = { // These are the offsets for bench positions on footpaths, 2 for each edge // rct2: 0x00981F2C, 0x00981F2E -const std::array BenchUseOffsets = { +const std::array BenchUseOffsets = { CoordsXY{ 7, 12 }, { 12, 25 }, { 25, 20 }, { 20, 7 }, { 7, 20 }, { 20, 25 }, { 25, 12 }, { 12, 7 }, }; @@ -2334,7 +2334,7 @@ void FootpathRemoveEdgesAt(const CoordsXY& footpathPos, TileElement* tileElement bool isQueue = tileElement->GetType() == TileElementType::Path ? tileElement->AsPath()->IsQueue() : false; int32_t z0 = z1 - 2; FootpathRemoveEdgesTowards( - { footpathPos + CoordsDirectionDelta[direction], z0 * COORDS_Z_STEP, z1 * COORDS_Z_STEP }, direction, isQueue); + { footpathPos + CoordsDirectionDelta[direction], z0 * kCoordsZStep, z1 * kCoordsZStep }, direction, isQueue); } else { diff --git a/src/openrct2/world/Footpath.h b/src/openrct2/world/Footpath.h index fadb0d24d6..6ff28f7c0e 100644 --- a/src/openrct2/world/Footpath.h +++ b/src/openrct2/world/Footpath.h @@ -25,10 +25,10 @@ enum PROVISIONAL_PATH_FLAG_2 = (1 << 2), }; -constexpr auto FootpathMaxHeight = 248 * COORDS_Z_STEP; -constexpr auto FootpathMinHeight = 2 * COORDS_Z_STEP; -constexpr auto PATH_HEIGHT_STEP = 2 * COORDS_Z_STEP; -constexpr auto PATH_CLEARANCE = 4 * COORDS_Z_STEP; +constexpr auto FootpathMaxHeight = 248 * kCoordsZStep; +constexpr auto FootpathMinHeight = 2 * kCoordsZStep; +constexpr auto PATH_HEIGHT_STEP = 2 * kCoordsZStep; +constexpr auto PATH_CLEARANCE = 4 * kCoordsZStep; enum class RailingEntrySupportType : uint8_t { diff --git a/src/openrct2/world/Location.hpp b/src/openrct2/world/Location.hpp index 6f43daaf53..83cf5127c3 100644 --- a/src/openrct2/world/Location.hpp +++ b/src/openrct2/world/Location.hpp @@ -13,16 +13,16 @@ #include -constexpr int16_t LOCATION_NULL = -32768; +constexpr int16_t kLocationNull = -32768; -constexpr int32_t COORDS_XY_STEP = 32; -constexpr int32_t COORDS_XY_HALF_TILE = (COORDS_XY_STEP / 2); -constexpr int32_t COORDS_Z_STEP = 8; -constexpr int32_t COORDS_Z_PER_TINY_Z = 16; +constexpr int32_t kCoordsXYStep = 32; +constexpr int32_t kCoordsXYHalfTile = (kCoordsXYStep / 2); +constexpr int32_t kCoordsZStep = 8; +constexpr int32_t kCoordsZPerTinyZ = 16; constexpr auto kNumOrthogonalDirections = 4; -constexpr int32_t COORDS_NULL = 0xFFFF8000; +constexpr int32_t kCoordsNull = 0xFFFF8000; struct ScreenSize { @@ -222,22 +222,22 @@ struct CoordsXY constexpr CoordsXY ToTileCentre() const { - return ToTileStart() + CoordsXY{ COORDS_XY_HALF_TILE, COORDS_XY_HALF_TILE }; + return ToTileStart() + CoordsXY{ kCoordsXYHalfTile, kCoordsXYHalfTile }; } constexpr CoordsXY ToTileStart() const { - return { Floor2(x, COORDS_XY_STEP), Floor2(y, COORDS_XY_STEP) }; + return { Floor2(x, kCoordsXYStep), Floor2(y, kCoordsXYStep) }; } constexpr bool IsNull() const { - return x == COORDS_NULL; + return x == kCoordsNull; }; constexpr void SetNull() { - x = COORDS_NULL; + x = kCoordsNull; y = 0; } }; @@ -276,12 +276,12 @@ struct CoordsXYZ : public CoordsXY constexpr CoordsXYZ ToTileStart() const { - return { Floor2(x, COORDS_XY_STEP), Floor2(y, COORDS_XY_STEP), z }; + return { Floor2(x, kCoordsXYStep), Floor2(y, kCoordsXYStep), z }; } constexpr CoordsXYZ ToTileCentre() const { - return ToTileStart() + CoordsXYZ{ COORDS_XY_HALF_TILE, COORDS_XY_HALF_TILE, 0 }; + return ToTileStart() + CoordsXYZ{ kCoordsXYHalfTile, kCoordsXYHalfTile, 0 }; } constexpr void SetNull() @@ -332,8 +332,8 @@ struct TileCoordsXY } constexpr explicit TileCoordsXY(const CoordsXY& c) - : x(c.x / COORDS_XY_STEP) - , y(c.y / COORDS_XY_STEP) + : x(c.x / kCoordsXYStep) + , y(c.y / kCoordsXYStep) { } @@ -365,7 +365,7 @@ struct TileCoordsXY return ret; } - return { x * COORDS_XY_STEP, y * COORDS_XY_STEP }; + return { x * kCoordsXYStep, y * kCoordsXYStep }; } constexpr TileCoordsXY Rotate(int32_t direction) const @@ -407,12 +407,12 @@ struct TileCoordsXY constexpr bool IsNull() const { - return x == COORDS_NULL; + return x == kCoordsNull; }; constexpr void SetNull() { - x = COORDS_NULL; + x = kCoordsNull; y = 0; } }; @@ -442,7 +442,7 @@ struct TileCoordsXYZ : public TileCoordsXY constexpr explicit TileCoordsXYZ(const CoordsXYZ& c) : TileCoordsXY(c) - , z(c.z / COORDS_Z_STEP) + , z(c.z / kCoordsZStep) { } @@ -478,7 +478,7 @@ struct TileCoordsXYZ : public TileCoordsXY ret.SetNull(); return ret; } - return { x * COORDS_XY_STEP, y * COORDS_XY_STEP, z * COORDS_Z_STEP }; + return { x * kCoordsXYStep, y * kCoordsXYStep, z * kCoordsZStep }; } constexpr void SetNull() @@ -661,12 +661,12 @@ struct CoordsXYZD : public CoordsXYZ constexpr CoordsXYZD ToTileStart() const { - return { Floor2(x, COORDS_XY_STEP), Floor2(y, COORDS_XY_STEP), z, direction }; + return { Floor2(x, kCoordsXYStep), Floor2(y, kCoordsXYStep), z, direction }; } constexpr CoordsXYZD ToTileCentre() const { - return ToTileStart() + CoordsXYZD{ COORDS_XY_HALF_TILE, COORDS_XY_HALF_TILE, 0, 0 }; + return ToTileStart() + CoordsXYZD{ kCoordsXYHalfTile, kCoordsXYHalfTile, 0, 0 }; } }; @@ -719,7 +719,7 @@ struct TileCoordsXYZD : public TileCoordsXYZ ret.SetNull(); return ret; } - return { x * COORDS_XY_STEP, y * COORDS_XY_STEP, z * COORDS_Z_STEP, direction }; + return { x * kCoordsXYStep, y * kCoordsXYStep, z * kCoordsZStep, direction }; } constexpr void SetNull() diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index e152a42dc2..bf108b2c84 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -70,14 +70,14 @@ using namespace OpenRCT2; */ // clang-format off const std::array CoordsDirectionDelta = { - CoordsXY{ -COORDS_XY_STEP, 0 }, - CoordsXY{ 0, +COORDS_XY_STEP }, - CoordsXY{ +COORDS_XY_STEP, 0 }, - CoordsXY{ 0, -COORDS_XY_STEP }, - CoordsXY{ -COORDS_XY_STEP, +COORDS_XY_STEP }, - CoordsXY{ +COORDS_XY_STEP, +COORDS_XY_STEP }, - CoordsXY{ +COORDS_XY_STEP, -COORDS_XY_STEP }, - CoordsXY{ -COORDS_XY_STEP, -COORDS_XY_STEP } + CoordsXY{ -kCoordsXYStep, 0 }, + CoordsXY{ 0, +kCoordsXYStep }, + CoordsXY{ +kCoordsXYStep, 0 }, + CoordsXY{ 0, -kCoordsXYStep }, + CoordsXY{ -kCoordsXYStep, +kCoordsXYStep }, + CoordsXY{ +kCoordsXYStep, +kCoordsXYStep }, + CoordsXY{ +kCoordsXYStep, -kCoordsXYStep }, + CoordsXY{ -kCoordsXYStep, -kCoordsXYStep } }; // clang-format on @@ -135,13 +135,13 @@ void UnstashMap() CoordsXY GetMapSizeUnits() { auto& gameState = OpenRCT2::GetGameState(); - return { (gameState.MapSize.x - 1) * COORDS_XY_STEP, (gameState.MapSize.y - 1) * COORDS_XY_STEP }; + return { (gameState.MapSize.x - 1) * kCoordsXYStep, (gameState.MapSize.y - 1) * kCoordsXYStep }; } CoordsXY GetMapSizeMinus2() { auto& gameState = OpenRCT2::GetGameState(); - return { (gameState.MapSize.x * COORDS_XY_STEP) + (8 * COORDS_XY_STEP - 2), - (gameState.MapSize.y * COORDS_XY_STEP) + (8 * COORDS_XY_STEP - 2) }; + return { (gameState.MapSize.x * kCoordsXYStep) + (8 * kCoordsXYStep - 2), + (gameState.MapSize.y * kCoordsXYStep) + (8 * kCoordsXYStep - 2) }; } CoordsXY GetMapSizeMaxXY() { @@ -769,11 +769,11 @@ void MapUpdatePathWideFlags() FootpathUpdatePathWideFlags(loopPosition); // Next x, y tile - loopPosition.x += COORDS_XY_STEP; + loopPosition.x += kCoordsXYStep; if (loopPosition.x >= MAXIMUM_MAP_SIZE_BIG) { loopPosition.x = 0; - loopPosition.y += COORDS_XY_STEP; + loopPosition.y += kCoordsXYStep; if (loopPosition.y >= MAXIMUM_MAP_SIZE_BIG) { loopPosition.y = 0; @@ -950,9 +950,9 @@ uint8_t MapGetLowestLandHeight(const MapRange& range) std::min(range.GetRight(), mapSizeMax.x), std::min(range.GetBottom(), mapSizeMax.y) }; uint8_t min_height = 0xFF; - for (int32_t yi = validRange.GetTop(); yi <= validRange.GetBottom(); yi += COORDS_XY_STEP) + for (int32_t yi = validRange.GetTop(); yi <= validRange.GetBottom(); yi += kCoordsXYStep) { - for (int32_t xi = validRange.GetLeft(); xi <= validRange.GetRight(); xi += COORDS_XY_STEP) + for (int32_t xi = validRange.GetLeft(); xi <= validRange.GetRight(); xi += kCoordsXYStep) { auto* surfaceElement = MapGetSurfaceElementAt(CoordsXY{ xi, yi }); @@ -980,9 +980,9 @@ uint8_t MapGetHighestLandHeight(const MapRange& range) std::min(range.GetRight(), mapSizeMax.x), std::min(range.GetBottom(), mapSizeMax.y) }; uint8_t max_height = 0; - for (int32_t yi = validRange.GetTop(); yi <= validRange.GetBottom(); yi += COORDS_XY_STEP) + for (int32_t yi = validRange.GetTop(); yi <= validRange.GetBottom(); yi += kCoordsXYStep) { - for (int32_t xi = validRange.GetLeft(); xi <= validRange.GetRight(); xi += COORDS_XY_STEP) + for (int32_t xi = validRange.GetLeft(); xi <= validRange.GetRight(); xi += kCoordsXYStep) { auto* surfaceElement = MapGetSurfaceElementAt(CoordsXY{ xi, yi }); if (surfaceElement != nullptr) @@ -1360,9 +1360,9 @@ void MapRemoveOutOfRangeElements() bool buildState = GetGameState().Cheats.BuildInPauseMode; GetGameState().Cheats.BuildInPauseMode = true; - for (int32_t y = MAXIMUM_MAP_SIZE_BIG - COORDS_XY_STEP; y >= 0; y -= COORDS_XY_STEP) + for (int32_t y = MAXIMUM_MAP_SIZE_BIG - kCoordsXYStep; y >= 0; y -= kCoordsXYStep) { - for (int32_t x = MAXIMUM_MAP_SIZE_BIG - COORDS_XY_STEP; x >= 0; x -= COORDS_XY_STEP) + for (int32_t x = MAXIMUM_MAP_SIZE_BIG - kCoordsXYStep; x >= 0; x -= kCoordsXYStep) { if (x == 0 || y == 0 || x >= mapSizeMax.x || y >= mapSizeMax.y) { @@ -1912,9 +1912,9 @@ bool MapSurfaceIsBlocked(const CoordsXY& mapCoords) /* Clears all map elements, to be used before generating a new map */ void MapClearAllElements() { - for (int32_t y = 0; y < MAXIMUM_MAP_SIZE_BIG; y += COORDS_XY_STEP) + for (int32_t y = 0; y < MAXIMUM_MAP_SIZE_BIG; y += kCoordsXYStep) { - for (int32_t x = 0; x < MAXIMUM_MAP_SIZE_BIG; x += COORDS_XY_STEP) + for (int32_t x = 0; x < MAXIMUM_MAP_SIZE_BIG; x += kCoordsXYStep) { ClearElementsAt({ x, y }); } @@ -2230,9 +2230,9 @@ void FixLandOwnershipTilesWithOwnership(std::initializer_list tile MapRange ClampRangeWithinMap(const MapRange& range) { auto mapSizeMax = GetMapSizeMaxXY(); - auto aX = std::max(COORDS_XY_STEP, range.GetLeft()); + auto aX = std::max(kCoordsXYStep, range.GetLeft()); auto bX = std::min(mapSizeMax.x, range.GetRight()); - auto aY = std::max(COORDS_XY_STEP, range.GetTop()); + auto aY = std::max(kCoordsXYStep, range.GetTop()); auto bY = std::min(mapSizeMax.y, range.GetBottom()); MapRange validRange = MapRange{ aX, aY, bX, bY }; return validRange; diff --git a/src/openrct2/world/Map.h b/src/openrct2/world/Map.h index 1af21d8db4..586b632164 100644 --- a/src/openrct2/world/Map.h +++ b/src/openrct2/world/Map.h @@ -28,16 +28,16 @@ constexpr uint8_t kMinimumMapSizeTechnical = 5; constexpr uint16_t kMaximumMapSizeTechnical = 1001; constexpr int16_t kMinimumMapSizePractical = (kMinimumMapSizeTechnical - 2); constexpr int16_t kMaximumMapSizePractical = (kMaximumMapSizeTechnical - 2); -constexpr const int32_t MAXIMUM_MAP_SIZE_BIG = COORDS_XY_STEP * kMaximumMapSizeTechnical; -constexpr int32_t MAXIMUM_TILE_START_XY = MAXIMUM_MAP_SIZE_BIG - COORDS_XY_STEP; -constexpr const int32_t LAND_HEIGHT_STEP = 2 * COORDS_Z_STEP; -constexpr const int32_t WATER_HEIGHT_STEP = 2 * COORDS_Z_STEP; -constexpr const int32_t kMinimumLandZ = kMinimumLandHeight * COORDS_Z_STEP; +constexpr const int32_t MAXIMUM_MAP_SIZE_BIG = kCoordsXYStep * kMaximumMapSizeTechnical; +constexpr int32_t MAXIMUM_TILE_START_XY = MAXIMUM_MAP_SIZE_BIG - kCoordsXYStep; +constexpr const int32_t LAND_HEIGHT_STEP = 2 * kCoordsZStep; +constexpr const int32_t WATER_HEIGHT_STEP = 2 * kCoordsZStep; +constexpr const int32_t kMinimumLandZ = kMinimumLandHeight * kCoordsZStep; constexpr TileCoordsXY DEFAULT_MAP_SIZE = { 150, 150 }; // How high construction has to be off the ground when the player owns construction rights, in tile coords. constexpr uint8_t ConstructionRightsClearanceSmall = 3; // Same as previous, but in big coords. -constexpr const uint8_t ConstructionRightsClearanceBig = 3 * COORDS_Z_STEP; +constexpr const uint8_t ConstructionRightsClearanceBig = 3 * kCoordsZStep; constexpr int16_t kMapMinimumXY = (-kMaximumMapSizeTechnical); diff --git a/src/openrct2/world/MapGen.cpp b/src/openrct2/world/MapGen.cpp index f0f27cc9e5..f783371e9f 100644 --- a/src/openrct2/world/MapGen.cpp +++ b/src/openrct2/world/MapGen.cpp @@ -342,8 +342,8 @@ static void MapGenPlaceTrees() { for (int32_t x = 1; x < gameState.MapSize.x - 1; x++) { - pos.x = x * COORDS_XY_STEP; - pos.y = y * COORDS_XY_STEP; + pos.x = x * kCoordsXYStep; + pos.y = y * kCoordsXYStep; auto* surfaceElement = MapGetSurfaceElementAt(pos); if (surfaceElement == nullptr) @@ -367,10 +367,10 @@ static void MapGenPlaceTrees() for (int32_t offsetX = -maxOasisDistance; offsetX <= maxOasisDistance; offsetX++) { // Get map coord, clamped to the edges - const auto offset = CoordsXY{ offsetX * COORDS_XY_STEP, offsetY * COORDS_XY_STEP }; + const auto offset = CoordsXY{ offsetX * kCoordsXYStep, offsetY * kCoordsXYStep }; auto neighbourPos = pos + offset; - neighbourPos.x = std::clamp(neighbourPos.x, COORDS_XY_STEP, COORDS_XY_STEP * (gameState.MapSize.x - 1)); - neighbourPos.y = std::clamp(neighbourPos.y, COORDS_XY_STEP, COORDS_XY_STEP * (gameState.MapSize.y - 1)); + neighbourPos.x = std::clamp(neighbourPos.x, kCoordsXYStep, kCoordsXYStep * (gameState.MapSize.x - 1)); + neighbourPos.y = std::clamp(neighbourPos.y, kCoordsXYStep, kCoordsXYStep * (gameState.MapSize.y - 1)); const auto neighboutSurface = MapGetSurfaceElementAt(neighbourPos); if (neighboutSurface != nullptr && neighboutSurface->GetWaterHeight() > 0) @@ -425,7 +425,7 @@ static void MapGenSetWaterLevel(int32_t waterLevel) { auto surfaceElement = MapGetSurfaceElementAt(TileCoordsXY{ x, y }); if (surfaceElement != nullptr && surfaceElement->BaseHeight < waterLevel) - surfaceElement->SetWaterHeight(waterLevel * COORDS_Z_STEP); + surfaceElement->SetWaterHeight(waterLevel * kCoordsZStep); } } } @@ -868,7 +868,7 @@ void MapGenGenerateFromHeightmap(MapGenSettings* settings) // Set water level if (surfaceElement->BaseHeight < settings->water_level) { - surfaceElement->SetWaterHeight(settings->water_level * COORDS_Z_STEP); + surfaceElement->SetWaterHeight(settings->water_level * kCoordsZStep); } } } diff --git a/src/openrct2/world/Park.cpp b/src/openrct2/world/Park.cpp index 2c34da9720..6483d3a961 100644 --- a/src/openrct2/world/Park.cpp +++ b/src/openrct2/world/Park.cpp @@ -670,22 +670,22 @@ namespace OpenRCT2::Park if (fenceRequired) { - if (MapIsLocationInPark({ coords.x - COORDS_XY_STEP, coords.y })) + if (MapIsLocationInPark({ coords.x - kCoordsXYStep, coords.y })) { newFences |= 0x8; } - if (MapIsLocationInPark({ coords.x, coords.y - COORDS_XY_STEP })) + if (MapIsLocationInPark({ coords.x, coords.y - kCoordsXYStep })) { newFences |= 0x4; } - if (MapIsLocationInPark({ coords.x + COORDS_XY_STEP, coords.y })) + if (MapIsLocationInPark({ coords.x + kCoordsXYStep, coords.y })) { newFences |= 0x2; } - if (MapIsLocationInPark({ coords.x, coords.y + COORDS_XY_STEP })) + if (MapIsLocationInPark({ coords.x, coords.y + kCoordsXYStep })) { newFences |= 0x1; } @@ -704,10 +704,10 @@ namespace OpenRCT2::Park void UpdateFencesAroundTile(const CoordsXY& coords) { UpdateFences(coords); - UpdateFences({ coords.x + COORDS_XY_STEP, coords.y }); - UpdateFences({ coords.x - COORDS_XY_STEP, coords.y }); - UpdateFences({ coords.x, coords.y + COORDS_XY_STEP }); - UpdateFences({ coords.x, coords.y - COORDS_XY_STEP }); + UpdateFences({ coords.x + kCoordsXYStep, coords.y }); + UpdateFences({ coords.x - kCoordsXYStep, coords.y }); + UpdateFences({ coords.x, coords.y + kCoordsXYStep }); + UpdateFences({ coords.x, coords.y - kCoordsXYStep }); } void SetForcedRating(int32_t rating) diff --git a/src/openrct2/world/TileElementBase.cpp b/src/openrct2/world/TileElementBase.cpp index d06f672737..5a3ce735bb 100644 --- a/src/openrct2/world/TileElementBase.cpp +++ b/src/openrct2/world/TileElementBase.cpp @@ -98,22 +98,22 @@ void TileElementBase::SetOccupiedQuadrants(uint8_t quadrants) int32_t TileElementBase::GetBaseZ() const { - return BaseHeight * COORDS_Z_STEP; + return BaseHeight * kCoordsZStep; } void TileElementBase::SetBaseZ(int32_t newZ) { - BaseHeight = (newZ / COORDS_Z_STEP); + BaseHeight = (newZ / kCoordsZStep); } int32_t TileElementBase::GetClearanceZ() const { - return ClearanceHeight * COORDS_Z_STEP; + return ClearanceHeight * kCoordsZStep; } void TileElementBase::SetClearanceZ(int32_t newZ) { - ClearanceHeight = (newZ / COORDS_Z_STEP); + ClearanceHeight = (newZ / kCoordsZStep); } uint8_t TileElementBase::GetOwner() const diff --git a/src/openrct2/world/TileInspector.cpp b/src/openrct2/world/TileInspector.cpp index 913fb3ee13..a300a3af80 100644 --- a/src/openrct2/world/TileInspector.cpp +++ b/src/openrct2/world/TileInspector.cpp @@ -244,14 +244,14 @@ namespace OpenRCT2::TileInspector uint8_t z = tileElement->BaseHeight; // Make sure this is the correct entrance or exit - if (entranceType == ENTRANCE_TYPE_RIDE_ENTRANCE && entrance.x == loc.x / COORDS_XY_STEP - && entrance.y == loc.y / COORDS_XY_STEP && entrance.z == z) + if (entranceType == ENTRANCE_TYPE_RIDE_ENTRANCE && entrance.x == loc.x / kCoordsXYStep + && entrance.y == loc.y / kCoordsXYStep && entrance.z == z) { station.Entrance = { entrance, newRotation }; } else if ( - entranceType == ENTRANCE_TYPE_RIDE_EXIT && exit.x == loc.x / COORDS_XY_STEP - && exit.y == loc.y / COORDS_XY_STEP && exit.z == z) + entranceType == ENTRANCE_TYPE_RIDE_EXIT && exit.x == loc.x / kCoordsXYStep + && exit.y == loc.y / kCoordsXYStep && exit.z == z) { station.Exit = { exit, newRotation }; }