From d943171faefddb192ac3aa143270f449f447d2db Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Wed, 12 Aug 2026 15:16:35 +0200 Subject: [PATCH] Create enum class for EntranceType --- .../interface/ViewportInteraction.cpp | 2 +- src/openrct2-ui/windows/Map.cpp | 2 +- src/openrct2-ui/windows/MazeConstruction.cpp | 23 +++++++++++------- src/openrct2-ui/windows/RideConstruction.cpp | 24 ++++++++++++------- src/openrct2-ui/windows/TileInspector.cpp | 10 ++++---- .../actions/park/LandSetRightsAction.cpp | 2 +- .../actions/park/ParkEntrancePlaceAction.cpp | 2 +- .../ride/RideEntranceExitPlaceAction.cpp | 2 +- .../ride/RideEntranceExitRemoveAction.cpp | 6 ++--- src/openrct2/entity/Guest.cpp | 2 +- src/openrct2/entity/Peep.cpp | 12 +++++----- .../paint/tile_element/Paint.Entrance.cpp | 12 +++++----- src/openrct2/peep/GuestPathfinding.cpp | 12 +++++----- src/openrct2/rct1/S4Importer.cpp | 4 ++-- src/openrct2/rct12/RCT12.cpp | 2 +- src/openrct2/rct12/RCT12.h | 11 +++++---- src/openrct2/rct12/ScenarioPatcher.cpp | 4 ++-- src/openrct2/ride/Ride.cpp | 14 +++++------ src/openrct2/ride/Ride.h | 4 +++- src/openrct2/ride/RideConstruction.cpp | 18 +++++++------- src/openrct2/ride/RideConstruction.h | 3 ++- src/openrct2/ride/TrackDesign.cpp | 4 ++-- src/openrct2/ride/TrackDesignSave.cpp | 4 ++-- .../scenes/editor/EditorController.cpp | 2 +- .../bindings/world/ScTileElement.cpp | 5 ++-- src/openrct2/world/ConstructionClearance.cpp | 6 ++--- src/openrct2/world/Entrance.cpp | 10 ++++---- src/openrct2/world/Footpath.cpp | 6 ++--- src/openrct2/world/Map.cpp | 10 ++++---- src/openrct2/world/MapAnimation.cpp | 8 +++---- src/openrct2/world/Park.cpp | 2 +- src/openrct2/world/TileInspector.cpp | 20 +++++++++------- .../world/tile_element/EntranceElement.cpp | 16 ++++++------- .../world/tile_element/EntranceElement.h | 14 +++++------ 34 files changed, 149 insertions(+), 129 deletions(-) diff --git a/src/openrct2-ui/interface/ViewportInteraction.cpp b/src/openrct2-ui/interface/ViewportInteraction.cpp index 1b3a5d7fa3..6531db4443 100644 --- a/src/openrct2-ui/interface/ViewportInteraction.cpp +++ b/src/openrct2-ui/interface/ViewportInteraction.cpp @@ -333,7 +333,7 @@ namespace OpenRCT2::Ui if (tileElement->getType() == TileElementType::entrance) { StringId stringId; - if (tileElement->asEntrance()->getEntranceType() == ENTRANCE_TYPE_RIDE_ENTRANCE) + if (tileElement->asEntrance()->getEntranceType() == EntranceType::rideEntrance) { if (ride->numStations > 1) { diff --git a/src/openrct2-ui/windows/Map.cpp b/src/openrct2-ui/windows/Map.cpp index 5b293fe0a7..84eab00445 100644 --- a/src/openrct2-ui/windows/Map.cpp +++ b/src/openrct2-ui/windows/Map.cpp @@ -922,7 +922,7 @@ namespace OpenRCT2::Ui::Windows break; case TileElementType::entrance: { - if (tileElement->asEntrance()->getEntranceType() == ENTRANCE_TYPE_PARK_ENTRANCE) + if (tileElement->asEntrance()->getEntranceType() == EntranceType::parkEntrance) break; Ride* targetRide = GetRide(tileElement->asEntrance()->getRideIndex()); if (targetRide != nullptr) diff --git a/src/openrct2-ui/windows/MazeConstruction.cpp b/src/openrct2-ui/windows/MazeConstruction.cpp index 880b052dd3..e39559e8e0 100644 --- a/src/openrct2-ui/windows/MazeConstruction.cpp +++ b/src/openrct2-ui/windows/MazeConstruction.cpp @@ -315,8 +315,8 @@ namespace OpenRCT2::Ui::Windows if (ToolSet(*this, widgetIndex, Tool::crosshair)) return; - gRideEntranceExitPlaceType = widgetIndex == WIDX_MAZE_ENTRANCE ? ENTRANCE_TYPE_RIDE_ENTRANCE - : ENTRANCE_TYPE_RIDE_EXIT; + gRideEntranceExitPlaceType = widgetIndex == WIDX_MAZE_ENTRANCE ? EntranceType::rideEntrance + : EntranceType::rideExit; gRideEntranceExitPlaceRideIndex = rideId; gRideEntranceExitPlaceStationIndex = StationIndex::FromUnderlying(0); gInputFlags.set(InputFlag::allowRightMouseRemoval); @@ -360,7 +360,7 @@ namespace OpenRCT2::Ui::Windows auto rideEntranceExitPlaceAction = GameActions::RideEntranceExitPlaceAction( entranceOrExitCoords, DirectionReverse(entranceOrExitCoords.direction), rideIndex, - gRideEntranceExitPlaceStationIndex, gRideEntranceExitPlaceType == ENTRANCE_TYPE_RIDE_EXIT); + gRideEntranceExitPlaceStationIndex, gRideEntranceExitPlaceType == EntranceType::rideExit); rideEntranceExitPlaceAction.SetCallback([=, this]( const GameActions::GameAction* ga, const GameActions::Result* result) { @@ -382,12 +382,19 @@ namespace OpenRCT2::Ui::Windows } else { - gRideEntranceExitPlaceType = gRideEntranceExitPlaceType ^ 1; + WidgetIndex newToolWidgetIndex; + if (gRideEntranceExitPlaceType == EntranceType::rideEntrance) + { + gRideEntranceExitPlaceType = EntranceType::rideExit; + newToolWidgetIndex = WIDX_MAZE_EXIT; + } + else + { + gRideEntranceExitPlaceType = EntranceType::rideEntrance; + newToolWidgetIndex = WIDX_MAZE_ENTRANCE; + } + windowMgr->InvalidateByClass(WindowClass::rideConstruction); - - auto newToolWidgetIndex = (gRideEntranceExitPlaceType == ENTRANCE_TYPE_RIDE_ENTRANCE) ? WIDX_MAZE_ENTRANCE - : WIDX_MAZE_EXIT; - ToolCancel(); ToolSet(*this, newToolWidgetIndex, Tool::crosshair); diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index c8e41ad873..2bc6a5a75d 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -2443,7 +2443,7 @@ namespace OpenRCT2::Ui::Windows } else { - gRideEntranceExitPlaceType = ENTRANCE_TYPE_RIDE_ENTRANCE; + gRideEntranceExitPlaceType = EntranceType::rideEntrance; gRideEntranceExitPlaceRideIndex = _currentRideIndex; gRideEntranceExitPlaceStationIndex = StationIndex::FromUnderlying(0); gInputFlags.set(InputFlag::allowRightMouseRemoval); @@ -2469,7 +2469,7 @@ namespace OpenRCT2::Ui::Windows } else { - gRideEntranceExitPlaceType = ENTRANCE_TYPE_RIDE_EXIT; + gRideEntranceExitPlaceType = EntranceType::rideExit; gRideEntranceExitPlaceRideIndex = _currentRideIndex; gRideEntranceExitPlaceStationIndex = StationIndex::FromUnderlying(0); gInputFlags.set(InputFlag::allowRightMouseRemoval); @@ -2599,7 +2599,7 @@ namespace OpenRCT2::Ui::Windows auto rideEntranceExitPlaceAction = GameActions::RideEntranceExitPlaceAction( entranceOrExitCoords, DirectionReverse(gRideEntranceExitPlaceDirection), gRideEntranceExitPlaceRideIndex, - gRideEntranceExitPlaceStationIndex, gRideEntranceExitPlaceType == ENTRANCE_TYPE_RIDE_EXIT); + gRideEntranceExitPlaceStationIndex, gRideEntranceExitPlaceType == EntranceType::rideExit); rideEntranceExitPlaceAction.SetCallback( [=, this](const GameActions::GameAction* ga, const GameActions::Result* result) { @@ -2621,13 +2621,19 @@ namespace OpenRCT2::Ui::Windows } else { - gRideEntranceExitPlaceType = gRideEntranceExitPlaceType ^ 1; + WidgetIndex newToolWidgetIndex; + if (gRideEntranceExitPlaceType == EntranceType::rideEntrance) + { + gRideEntranceExitPlaceType = EntranceType::rideExit; + newToolWidgetIndex = WC_RIDE_CONSTRUCTION__WIDX_EXIT; + } + else + { + gRideEntranceExitPlaceType = EntranceType::rideEntrance; + newToolWidgetIndex = WC_RIDE_CONSTRUCTION__WIDX_ENTRANCE; + } + windowMgr->InvalidateByClass(WindowClass::rideConstruction); - - auto newToolWidgetIndex = (gRideEntranceExitPlaceType == ENTRANCE_TYPE_RIDE_ENTRANCE) - ? WC_RIDE_CONSTRUCTION__WIDX_ENTRANCE - : WC_RIDE_CONSTRUCTION__WIDX_EXIT; - ToolCancel(); ToolSet(*this, newToolWidgetIndex, Tool::crosshair); } diff --git a/src/openrct2-ui/windows/TileInspector.cpp b/src/openrct2-ui/windows/TileInspector.cpp index 1817aebc9a..8218ec96b8 100644 --- a/src/openrct2-ui/windows/TileInspector.cpp +++ b/src/openrct2-ui/windows/TileInspector.cpp @@ -1389,10 +1389,10 @@ namespace OpenRCT2::Ui::Windows // Details // Entrance type auto ft = Formatter(); - ft.Add(kEntranceTypeStringIds[entranceEl.getEntranceType()]); + ft.Add(kEntranceTypeStringIds[EnumValue(entranceEl.getEntranceType())]); drawText(rt, screenCoords, STR_TILE_INSPECTOR_ENTRANCE_TYPE, ft, { colours[1] }); - if (entranceEl.getEntranceType() == ENTRANCE_TYPE_PARK_ENTRANCE) + if (entranceEl.getEntranceType() == EntranceType::parkEntrance) { // TODO: Make this work with Left/Right park entrance parts ft = Formatter(); @@ -1404,7 +1404,7 @@ namespace OpenRCT2::Ui::Windows { ft = Formatter(); ft.Add(entranceEl.getStationIndex().ToUnderlying()); - if (entranceEl.getEntranceType() == ENTRANCE_TYPE_RIDE_ENTRANCE) + if (entranceEl.getEntranceType() == EntranceType::rideEntrance) { // Ride entrance ID drawText( @@ -1419,7 +1419,7 @@ namespace OpenRCT2::Ui::Windows } } - if (entranceEl.getEntranceType() == ENTRANCE_TYPE_PARK_ENTRANCE) + if (entranceEl.getEntranceType() == EntranceType::parkEntrance) { // Entrance part ft = Formatter(); @@ -2343,7 +2343,7 @@ namespace OpenRCT2::Ui::Windows setWidgetDisabled( WIDX_ENTRANCE_BUTTON_MAKE_USABLE, - tileElement->asEntrance()->getEntranceType() == ENTRANCE_TYPE_PARK_ENTRANCE); + tileElement->asEntrance()->getEntranceType() == EntranceType::parkEntrance); break; case TileElementType::wall: diff --git a/src/openrct2/actions/park/LandSetRightsAction.cpp b/src/openrct2/actions/park/LandSetRightsAction.cpp index 8a13c7fcc3..4e27e279ae 100644 --- a/src/openrct2/actions/park/LandSetRightsAction.cpp +++ b/src/openrct2/actions/park/LandSetRightsAction.cpp @@ -162,7 +162,7 @@ namespace OpenRCT2::GameActions for (auto* entranceElement : TileElementsView(loc)) { - if (entranceElement->getEntranceType() != ENTRANCE_TYPE_PARK_ENTRANCE) + if (entranceElement->getEntranceType() != EntranceType::parkEntrance) continue; // Do not allow ownership of park entrance. diff --git a/src/openrct2/actions/park/ParkEntrancePlaceAction.cpp b/src/openrct2/actions/park/ParkEntrancePlaceAction.cpp index 2560dd34cc..19fb90a912 100644 --- a/src/openrct2/actions/park/ParkEntrancePlaceAction.cpp +++ b/src/openrct2/actions/park/ParkEntrancePlaceAction.cpp @@ -161,7 +161,7 @@ namespace OpenRCT2::GameActions entranceElement->setGhost(flags.has(CommandFlag::ghost)); entranceElement->setDirection(_loc.direction); entranceElement->setSequenceIndex(index); - entranceElement->setEntranceType(ENTRANCE_TYPE_PARK_ENTRANCE); + entranceElement->setEntranceType(EntranceType::parkEntrance); entranceElement->setEntryIndex(_entranceType); if (!_pathTypeIsLegacy) { diff --git a/src/openrct2/actions/ride/RideEntranceExitPlaceAction.cpp b/src/openrct2/actions/ride/RideEntranceExitPlaceAction.cpp index 24e51087d6..06cc8fa255 100644 --- a/src/openrct2/actions/ride/RideEntranceExitPlaceAction.cpp +++ b/src/openrct2/actions/ride/RideEntranceExitPlaceAction.cpp @@ -206,7 +206,7 @@ namespace OpenRCT2::GameActions entranceElement->setDirection(_direction); entranceElement->setClearanceZ(clear_z); - entranceElement->setEntranceType(_isExit ? ENTRANCE_TYPE_RIDE_EXIT : ENTRANCE_TYPE_RIDE_ENTRANCE); + entranceElement->setEntranceType(_isExit ? EntranceType::rideExit : EntranceType::rideEntrance); entranceElement->setStationIndex(_stationNum); entranceElement->setRideIndex(_rideIndex); entranceElement->setGhost(GetFlags().has(CommandFlag::ghost)); diff --git a/src/openrct2/actions/ride/RideEntranceExitRemoveAction.cpp b/src/openrct2/actions/ride/RideEntranceExitRemoveAction.cpp index 68dccf4852..175eea46ab 100644 --- a/src/openrct2/actions/ride/RideEntranceExitRemoveAction.cpp +++ b/src/openrct2/actions/ride/RideEntranceExitRemoveAction.cpp @@ -48,7 +48,7 @@ namespace OpenRCT2::GameActions } static TileElement* FindEntranceElement( - const CoordsXY& loc, RideId rideIndex, StationIndex stationNum, int32_t entranceType) + const CoordsXY& loc, RideId rideIndex, StationIndex stationNum, EntranceType entranceType) { for (auto* entranceElement : TileElementsView(loc)) { @@ -91,7 +91,7 @@ namespace OpenRCT2::GameActions } auto* entranceElement = FindEntranceElement( - _loc, _rideIndex, _stationNum, _isExit ? ENTRANCE_TYPE_RIDE_EXIT : ENTRANCE_TYPE_RIDE_ENTRANCE); + _loc, _rideIndex, _stationNum, _isExit ? EntranceType::rideExit : EntranceType::rideEntrance); // If we are trying to remove a ghost and the element we found is real, return an error, but don't log a warning if (entranceElement != nullptr && (GetFlags().has(CommandFlag::ghost)) && !(entranceElement->isGhost())) @@ -127,7 +127,7 @@ namespace OpenRCT2::GameActions } auto* entranceElement = FindEntranceElement( - _loc, _rideIndex, _stationNum, _isExit ? ENTRANCE_TYPE_RIDE_EXIT : ENTRANCE_TYPE_RIDE_ENTRANCE); + _loc, _rideIndex, _stationNum, _isExit ? EntranceType::rideExit : EntranceType::rideEntrance); // If we are trying to remove a ghost and the element we found is real, return an error, but don't log a warning if (entranceElement != nullptr && isGhost && !(entranceElement->isGhost())) diff --git a/src/openrct2/entity/Guest.cpp b/src/openrct2/entity/Guest.cpp index e4df43bfdf..19398fc167 100644 --- a/src/openrct2/entity/Guest.cpp +++ b/src/openrct2/entity/Guest.cpp @@ -4953,7 +4953,7 @@ namespace OpenRCT2 } if (tileElement->getType() == TileElementType::entrance - && tileElement->asEntrance()->getEntranceType() == ENTRANCE_TYPE_RIDE_EXIT) + && tileElement->asEntrance()->getEntranceType() == EntranceType::rideExit) { mazeType = MazeType::entranceOrExit; break; diff --git a/src/openrct2/entity/Peep.cpp b/src/openrct2/entity/Peep.cpp index 2129e2ddaf..e512de1c3f 100644 --- a/src/openrct2/entity/Peep.cpp +++ b/src/openrct2/entity/Peep.cpp @@ -1622,10 +1622,10 @@ namespace OpenRCT2 static bool PeepInteractWithEntrance(Peep* peep, const CoordsXYE& coords, uint8_t& pathing_result) { auto tile_element = coords.element; - uint8_t entranceType = tile_element->asEntrance()->getEntranceType(); + auto entranceType = tile_element->asEntrance()->getEntranceType(); auto rideIndex = tile_element->asEntrance()->getRideIndex(); - if ((entranceType == ENTRANCE_TYPE_RIDE_ENTRANCE) || (entranceType == ENTRANCE_TYPE_RIDE_EXIT)) + if ((entranceType == EntranceType::rideEntrance) || (entranceType == EntranceType::rideExit)) { // If an entrance or exit that doesn't belong to the ride we are queuing for ignore the entrance/exit // This can happen when paths clip through entrance/exits @@ -1637,18 +1637,18 @@ namespace OpenRCT2 // Store some details to determine when to override the default // behaviour (defined below) for when staff attempt to enter a ride // to fix/inspect it. - if (entranceType == ENTRANCE_TYPE_RIDE_EXIT) + if (entranceType == EntranceType::rideExit) { pathing_result |= PATHING_RIDE_EXIT; _peepRideEntranceExitElement = tile_element; } - else if (entranceType == ENTRANCE_TYPE_RIDE_ENTRANCE) + else if (entranceType == EntranceType::rideEntrance) { pathing_result |= PATHING_RIDE_ENTRANCE; _peepRideEntranceExitElement = tile_element; } - if (entranceType == ENTRANCE_TYPE_RIDE_EXIT) + if (entranceType == EntranceType::rideExit) { // Default guest/staff behaviour attempting to enter a // ride exit is to turn around. @@ -1657,7 +1657,7 @@ namespace OpenRCT2 return true; } - if (entranceType == ENTRANCE_TYPE_RIDE_ENTRANCE) + if (entranceType == EntranceType::rideEntrance) { auto ride = GetRide(rideIndex); if (ride == nullptr) diff --git a/src/openrct2/paint/tile_element/Paint.Entrance.cpp b/src/openrct2/paint/tile_element/Paint.Entrance.cpp index b236ed901b..ab9c907e4d 100644 --- a/src/openrct2/paint/tile_element/Paint.Entrance.cpp +++ b/src/openrct2/paint/tile_element/Paint.Entrance.cpp @@ -43,7 +43,7 @@ static void PaintRideEntranceExitScrollingText( if (stationObj.ScrollingMode == kScrollingModeNone) return; - if (entranceEl.getEntranceType() == ENTRANCE_TYPE_RIDE_EXIT) + if (entranceEl.getEntranceType() == EntranceType::rideExit) return; const auto* ride = GetRide(entranceEl.getRideIndex()); @@ -71,7 +71,7 @@ static void PaintRideEntranceExitLightEffects(PaintSession& session, int32_t hei if (LightFx::IsAvailable()) { - if (entranceEl.getEntranceType() == ENTRANCE_TYPE_RIDE_ENTRANCE) + if (entranceEl.getEntranceType() == EntranceType::rideEntrance) { LightFx::Add3DLightMagicFromDrawingTile(session.MapPosition, 0, 0, height + 45, LightType::lantern3); } @@ -157,7 +157,7 @@ static void PaintRideEntranceExit(PaintSession& session, uint8_t direction, int3 // Each entrance is split into 2 images for drawing // Certain entrance styles have another 2 images to draw for coloured windows - auto isExit = entranceEl.getEntranceType() == ENTRANCE_TYPE_RIDE_EXIT; + auto isExit = entranceEl.getEntranceType() == EntranceType::rideExit; // Back ImageIndex backImageIndex = (isExit ? stationObj->exitBackIndex : stationObj->entranceBackIndex) + direction; @@ -345,11 +345,11 @@ void PaintEntrance(PaintSession& session, uint8_t direction, int32_t height, con PaintHeightMarkers(session, entranceElement, height); switch (entranceElement.getEntranceType()) { - case ENTRANCE_TYPE_RIDE_ENTRANCE: - case ENTRANCE_TYPE_RIDE_EXIT: + case EntranceType::rideEntrance: + case EntranceType::rideExit: PaintRideEntranceExit(session, direction, height, entranceElement); break; - case ENTRANCE_TYPE_PARK_ENTRANCE: + case EntranceType::parkEntrance: PaintParkEntrance(session, direction, height, entranceElement); break; } diff --git a/src/openrct2/peep/GuestPathfinding.cpp b/src/openrct2/peep/GuestPathfinding.cpp index 461b09fdd7..106ebc09e1 100644 --- a/src/openrct2/peep/GuestPathfinding.cpp +++ b/src/openrct2/peep/GuestPathfinding.cpp @@ -426,7 +426,7 @@ namespace OpenRCT2::PathFinding continue; switch (tileElement->asEntrance()->getEntranceType()) { - case ENTRANCE_TYPE_RIDE_ENTRANCE: + case EntranceType::rideEntrance: direction = tileElement->getDirection(); if (direction == chosenDirection) { @@ -434,7 +434,7 @@ namespace OpenRCT2::PathFinding return PathSearchResult::rideEntrance; } break; - case ENTRANCE_TYPE_RIDE_EXIT: + case EntranceType::rideExit: direction = tileElement->getDirection(); if (direction == chosenDirection) { @@ -442,7 +442,7 @@ namespace OpenRCT2::PathFinding return PathSearchResult::rideExit; } break; - case ENTRANCE_TYPE_PARK_ENTRANCE: + case EntranceType::parkEntrance: return PathSearchResult::parkExit; } break; @@ -797,7 +797,7 @@ namespace OpenRCT2::PathFinding searchResult = PathSearchResult::other; switch (tileElement->asEntrance()->getEntranceType()) { - case ENTRANCE_TYPE_RIDE_ENTRANCE: + case EntranceType::rideEntrance: /* For peeps heading for a ride without a queue, the * goal is the ride entrance tile. * For mechanics heading for the ride entrance @@ -814,13 +814,13 @@ namespace OpenRCT2::PathFinding break; } continue; // Ride entrance is not facing the right direction. - case ENTRANCE_TYPE_PARK_ENTRANCE: + case EntranceType::parkEntrance: /* For peeps leaving the park, the goal is the park * entrance/exit tile. */ searchResult = PathSearchResult::parkExit; found = true; break; - case ENTRANCE_TYPE_RIDE_EXIT: + case EntranceType::rideExit: /* For mechanics heading for the ride exit, the * goal is the ride exit tile. */ direction = tileElement->getDirection(); diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index e4460f07bd..41c9c4891f 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -1823,7 +1823,7 @@ namespace OpenRCT2::RCT1 dst2->setStationIndex(StationIndex::FromUnderlying(src2->GetStationIndex())); dst2->setSequenceIndex(src2->GetSequenceIndex()); - if (src2->GetEntranceType() == ENTRANCE_TYPE_PARK_ENTRANCE) + if (src2->GetEntranceType() == EntranceType::parkEntrance) { auto pathType = src2->GetPathType(); if (pathType == 0) @@ -2537,7 +2537,7 @@ namespace OpenRCT2::RCT1 if (element->getType() != TileElementType::entrance) continue; - if (element->asEntrance()->getEntranceType() != ENTRANCE_TYPE_PARK_ENTRANCE) + if (element->asEntrance()->getEntranceType() != EntranceType::parkEntrance) continue; if ((element->asEntrance()->getSequenceIndex()) != 0) continue; diff --git a/src/openrct2/rct12/RCT12.cpp b/src/openrct2/rct12/RCT12.cpp index 852ff22895..943db5decf 100644 --- a/src/openrct2/rct12/RCT12.cpp +++ b/src/openrct2/rct12/RCT12.cpp @@ -431,7 +431,7 @@ uint8_t RCT12WallElement::GetRCT1Slope() const return EntryIndex & 0b00011111; } -uint8_t RCT12EntranceElement::GetEntranceType() const +OpenRCT2::EntranceType RCT12EntranceElement::GetEntranceType() const { return EntranceType; } diff --git a/src/openrct2/rct12/RCT12.h b/src/openrct2/rct12/RCT12.h index 9c7802e8a7..c510deb49d 100644 --- a/src/openrct2/rct12/RCT12.h +++ b/src/openrct2/rct12/RCT12.h @@ -29,6 +29,7 @@ namespace OpenRCT2 { class ObjectList; + enum class EntranceType : uint8_t; enum class TrackElemType : uint16_t; } // namespace OpenRCT2 @@ -862,12 +863,12 @@ static_assert(sizeof(RCT12WallElement) == 8); struct RCT12EntranceElement : RCT12TileElementBase { private: - uint8_t EntranceType; // 4 - uint8_t Index; // 5. 0bUSSS????, S = station index. - uint8_t PathType; // 6 - uint8_t RideIndex; // 7 + OpenRCT2::EntranceType EntranceType; // 4 + uint8_t Index; // 5. 0bUSSS????, S = station index. + uint8_t PathType; // 6 + uint8_t RideIndex; // 7 public: - uint8_t GetEntranceType() const; + OpenRCT2::EntranceType GetEntranceType() const; uint8_t GetRideIndex() const; uint8_t GetStationIndex() const; uint8_t GetSequenceIndex() const; diff --git a/src/openrct2/rct12/ScenarioPatcher.cpp b/src/openrct2/rct12/ScenarioPatcher.cpp index 553c5058ea..7a9ecf27a8 100644 --- a/src/openrct2/rct12/ScenarioPatcher.cpp +++ b/src/openrct2/rct12/ScenarioPatcher.cpp @@ -512,9 +512,9 @@ static void SwapRideEntranceAndExit(RideId rideId) station.Exit = exitCoords; auto entranceElement = MapGetRideExitElementAt(entranceCoords.ToCoordsXYZD(), false); - entranceElement->setEntranceType(ENTRANCE_TYPE_RIDE_ENTRANCE); + entranceElement->setEntranceType(EntranceType::rideEntrance); auto exitElement = MapGetRideEntranceElementAt(exitCoords.ToCoordsXYZD(), false); - exitElement->setEntranceType(ENTRANCE_TYPE_RIDE_EXIT); + exitElement->setEntranceType(EntranceType::rideExit); // Trigger footpath update FootpathQueueChainReset(); diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index 60821e2f2b..5c83885f7e 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -2212,7 +2212,7 @@ namespace OpenRCT2 if (ride == nullptr) return; - if (entranceElement.getEntranceType() == ENTRANCE_TYPE_RIDE_ENTRANCE) + if (entranceElement.getEntranceType() == EntranceType::rideEntrance) { // Get the queue length int32_t queueLength = 0; @@ -2787,8 +2787,8 @@ namespace OpenRCT2 break; if (tileElement->getType() != TileElementType::entrance) continue; - if (tileElement->asEntrance()->getEntranceType() != ENTRANCE_TYPE_RIDE_ENTRANCE - && tileElement->asEntrance()->getEntranceType() != ENTRANCE_TYPE_RIDE_EXIT) + if (tileElement->asEntrance()->getEntranceType() != EntranceType::rideEntrance + && tileElement->asEntrance()->getEntranceType() != EntranceType::rideExit) { continue; } @@ -5402,7 +5402,7 @@ namespace OpenRCT2 // The expected height is where entrances and exit reside in non-hacked parks. const uint8_t expectedHeight = station.Height; - if (fixEntrance && entranceElement->getEntranceType() == ENTRANCE_TYPE_RIDE_ENTRANCE) + if (fixEntrance && entranceElement->getEntranceType() == EntranceType::rideEntrance) { if (alreadyFoundEntrance) { @@ -5420,7 +5420,7 @@ namespace OpenRCT2 "Fixed disconnected entrance of ride %d, station %d to x = %d, y = %d and z = %d.", ride.id, stationIndex, x, y, entranceElement->baseHeight); } - else if (fixExit && entranceElement->getEntranceType() == ENTRANCE_TYPE_RIDE_EXIT) + else if (fixExit && entranceElement->getEntranceType() == EntranceType::rideExit) { if (alreadyFoundExit) { @@ -5466,8 +5466,8 @@ namespace OpenRCT2 { for (auto* entrance : TileElementsView(tilePos.ToCoordsXY())) { - const bool isRideEntranceExit = entrance->getEntranceType() == ENTRANCE_TYPE_RIDE_ENTRANCE - || entrance->getEntranceType() == ENTRANCE_TYPE_RIDE_EXIT; + const bool isRideEntranceExit = entrance->getEntranceType() == EntranceType::rideEntrance + || entrance->getEntranceType() == EntranceType::rideExit; if (!isRideEntranceExit) continue; if (entrance->getRideIndex() != ride.id) diff --git a/src/openrct2/ride/Ride.h b/src/openrct2/ride/Ride.h index 72e54828fe..6271facda1 100644 --- a/src/openrct2/ride/Ride.h +++ b/src/openrct2/ride/Ride.h @@ -47,6 +47,7 @@ namespace OpenRCT2 struct TileElement; struct TrackElement; + enum class EntranceType : uint8_t; enum class RideMode : uint8_t; enum class RideStatus : uint8_t; @@ -852,7 +853,8 @@ namespace OpenRCT2 void RideGetStartOfTrack(CoordsXYE* output); money64 RideEntranceExitPlaceGhost( - const Ride& ride, const CoordsXY& entranceExitCoords, Direction direction, int32_t placeType, StationIndex stationNum); + const Ride& ride, const CoordsXY& entranceExitCoords, Direction direction, EntranceType placeType, + StationIndex stationNum); ResultWithMessage RideAreAllPossibleEntrancesAndExitsBuilt(const Ride& ride); void RideFixBreakdown(Ride& ride, int32_t reliabilityIncreaseFactor); diff --git a/src/openrct2/ride/RideConstruction.cpp b/src/openrct2/ride/RideConstruction.cpp index b82953ed63..53b4f428f5 100644 --- a/src/openrct2/ride/RideConstruction.cpp +++ b/src/openrct2/ride/RideConstruction.cpp @@ -286,7 +286,7 @@ namespace OpenRCT2 CoordsXYZD _unkF440C5; - uint8_t gRideEntranceExitPlaceType; + EntranceType gRideEntranceExitPlaceType; RideId gRideEntranceExitPlaceRideIndex; StationIndex gRideEntranceExitPlaceStationIndex; RideConstructionState gRideEntranceExitPlacePreviousRideConstructionState; @@ -1063,7 +1063,7 @@ namespace OpenRCT2 return false; auto entranceType = entranceElement->getEntranceType(); - if (entranceType != ENTRANCE_TYPE_RIDE_ENTRANCE && entranceType != ENTRANCE_TYPE_RIDE_EXIT) + if (entranceType != EntranceType::rideEntrance && entranceType != EntranceType::rideExit) return false; auto stationIndex = entranceElement->getStationIndex(); @@ -1087,8 +1087,8 @@ namespace OpenRCT2 // Replace entrance / exit ToolSet( *constructionWindow, - entranceType == ENTRANCE_TYPE_RIDE_ENTRANCE ? WC_RIDE_CONSTRUCTION__WIDX_ENTRANCE - : WC_RIDE_CONSTRUCTION__WIDX_EXIT, + entranceType == EntranceType::rideEntrance ? WC_RIDE_CONSTRUCTION__WIDX_ENTRANCE + : WC_RIDE_CONSTRUCTION__WIDX_EXIT, Tool::crosshair); gRideEntranceExitPlaceType = entranceType; gRideEntranceExitPlaceRideIndex = rideIndex; @@ -1107,14 +1107,14 @@ namespace OpenRCT2 { // Remove entrance / exit auto rideEntranceExitRemove = GameActions::RideEntranceExitRemoveAction( - { tileElement.x, tileElement.y }, rideIndex, stationIndex, entranceType == ENTRANCE_TYPE_RIDE_EXIT); + { tileElement.x, tileElement.y }, rideIndex, stationIndex, entranceType == EntranceType::rideExit); rideEntranceExitRemove.SetCallback([=](const GameActions::GameAction* ga, const GameActions::Result* result) { gRideEntranceExitPlaceType = entranceType; windowMgr->InvalidateByClass(WindowClass::rideConstruction); - auto newToolWidgetIndex = (entranceType == ENTRANCE_TYPE_RIDE_ENTRANCE) ? WC_RIDE_CONSTRUCTION__WIDX_ENTRANCE - : WC_RIDE_CONSTRUCTION__WIDX_EXIT; + auto newToolWidgetIndex = (entranceType == EntranceType::rideEntrance) ? WC_RIDE_CONSTRUCTION__WIDX_ENTRANCE + : WC_RIDE_CONSTRUCTION__WIDX_EXIT; ToolCancel(); ToolSet(*constructionWindow, newToolWidgetIndex, Tool::crosshair); @@ -1551,7 +1551,7 @@ namespace OpenRCT2 if (tileElement->asEntrance()->getRideIndex() != id) continue; // if it's a park entrance continue to the next tile element - if (tileElement->asEntrance()->getEntranceType() > ENTRANCE_TYPE_RIDE_EXIT) + if (tileElement->asEntrance()->getEntranceType() > EntranceType::rideExit) continue; // find the station that's connected to this ride entrance @@ -1597,7 +1597,7 @@ namespace OpenRCT2 } auto& station = getStation(stationId); - if (tileElement->asEntrance()->getEntranceType() == ENTRANCE_TYPE_RIDE_EXIT) + if (tileElement->asEntrance()->getEntranceType() == EntranceType::rideExit) { // if the location is already set for this station, big problem! if (!station.Exit.IsNull()) diff --git a/src/openrct2/ride/RideConstruction.h b/src/openrct2/ride/RideConstruction.h index 86faf64efa..964849dd74 100644 --- a/src/openrct2/ride/RideConstruction.h +++ b/src/openrct2/ride/RideConstruction.h @@ -36,6 +36,7 @@ namespace OpenRCT2 struct TrackDrawerEntry; struct TileElement; + enum class EntranceType : uint8_t; enum class TrackElemType : uint16_t; namespace TrackMetadata @@ -125,7 +126,7 @@ namespace OpenRCT2 extern CoordsXYZD _unkF440C5; - extern uint8_t gRideEntranceExitPlaceType; + extern EntranceType gRideEntranceExitPlaceType; extern RideId gRideEntranceExitPlaceRideIndex; extern StationIndex gRideEntranceExitPlaceStationIndex; extern RideConstructionState gRideEntranceExitPlacePreviousRideConstructionState; diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index 94b3efacaf..03e5c77a84 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -404,7 +404,7 @@ ResultWithMessage TrackDesign::CreateTrackDesignMaze(TrackDesignState& tds, cons return { false, STR_TRACK_TOO_LARGE_OR_TOO_MUCH_SCENERY }; if (tileElement->getType() != TileElementType::entrance) continue; - if (tileElement->asEntrance()->getEntranceType() != ENTRANCE_TYPE_RIDE_ENTRANCE) + if (tileElement->asEntrance()->getEntranceType() != EntranceType::rideEntrance) continue; if (tileElement->asEntrance()->getRideIndex() == ride.id) break; @@ -431,7 +431,7 @@ ResultWithMessage TrackDesign::CreateTrackDesignMaze(TrackDesignState& tds, cons { if (tileElement->getType() != TileElementType::entrance) continue; - if (tileElement->asEntrance()->getEntranceType() != ENTRANCE_TYPE_RIDE_EXIT) + if (tileElement->asEntrance()->getEntranceType() != EntranceType::rideExit) continue; if (tileElement->asEntrance()->getRideIndex() == ride.id) break; diff --git a/src/openrct2/ride/TrackDesignSave.cpp b/src/openrct2/ride/TrackDesignSave.cpp index 004cf9e154..31e717eede 100644 --- a/src/openrct2/ride/TrackDesignSave.cpp +++ b/src/openrct2/ride/TrackDesignSave.cpp @@ -564,9 +564,9 @@ static bool TrackDesignSaveShouldSelectSceneryAround(RideId rideIndex, TileEleme break; case TileElementType::entrance: // FIXME: This will always break and return false! - if (tileElement->asEntrance()->getEntranceType() != ENTRANCE_TYPE_RIDE_ENTRANCE) + if (tileElement->asEntrance()->getEntranceType() != EntranceType::rideEntrance) break; - if (tileElement->asEntrance()->getEntranceType() != ENTRANCE_TYPE_RIDE_EXIT) + if (tileElement->asEntrance()->getEntranceType() != EntranceType::rideExit) break; if (tileElement->asEntrance()->getRideIndex() == rideIndex) return true; diff --git a/src/openrct2/scenes/editor/EditorController.cpp b/src/openrct2/scenes/editor/EditorController.cpp index d85d2dea3b..4f6a7138db 100644 --- a/src/openrct2/scenes/editor/EditorController.cpp +++ b/src/openrct2/scenes/editor/EditorController.cpp @@ -393,7 +393,7 @@ namespace OpenRCT2::Editor case TileElementType::entrance: { auto parkEntranceEl = iter.element->asEntrance(); - if (parkEntranceEl->getEntranceType() != ENTRANCE_TYPE_PARK_ENTRANCE) + if (parkEntranceEl->getEntranceType() != EntranceType::parkEntrance) break; type = iter.element->asEntrance()->getEntryIndex(); diff --git a/src/openrct2/scripting/bindings/world/ScTileElement.cpp b/src/openrct2/scripting/bindings/world/ScTileElement.cpp index ac5c257e90..1e45f3403e 100644 --- a/src/openrct2/scripting/bindings/world/ScTileElement.cpp +++ b/src/openrct2/scripting/bindings/world/ScTileElement.cpp @@ -1286,7 +1286,7 @@ namespace OpenRCT2::Scripting case TileElementType::entrance: { auto* el = element->asEntrance(); - return JS_NewUint32(ctx, el->getEntranceType()); + return JS_NewUint32(ctx, EnumValue(el->getEntranceType())); } case TileElementType::banner: { @@ -1349,7 +1349,8 @@ namespace OpenRCT2::Scripting { JS_UNPACK_UINT32(index, ctx, jsValue); auto* el = element->asEntrance(); - el->setEntranceType(index); + index = std::clamp(index, 0, 2); + el->setEntranceType(static_cast(index)); Invalidate(data); break; } diff --git a/src/openrct2/world/ConstructionClearance.cpp b/src/openrct2/world/ConstructionClearance.cpp index ad1cea95f8..cd8b115c26 100644 --- a/src/openrct2/world/ConstructionClearance.cpp +++ b/src/openrct2/world/ConstructionClearance.cpp @@ -365,13 +365,13 @@ void MapGetObstructionErrorText(TileElement* tileElement, GameActions::Result& r case TileElementType::entrance: switch (tileElement->asEntrance()->getEntranceType()) { - case ENTRANCE_TYPE_RIDE_ENTRANCE: + case EntranceType::rideEntrance: res.errorMessage = STR_RIDE_ENTRANCE_IN_THE_WAY; break; - case ENTRANCE_TYPE_RIDE_EXIT: + case EntranceType::rideExit: res.errorMessage = STR_RIDE_EXIT_IN_THE_WAY; break; - case ENTRANCE_TYPE_PARK_ENTRANCE: + case EntranceType::parkEntrance: res.errorMessage = STR_PARK_ENTRANCE_IN_THE_WAY; break; } diff --git a/src/openrct2/world/Entrance.cpp b/src/openrct2/world/Entrance.cpp index 63a9d54012..c18a1870b9 100644 --- a/src/openrct2/world/Entrance.cpp +++ b/src/openrct2/world/Entrance.cpp @@ -29,10 +29,10 @@ CoordsXYZD gRideEntranceExitGhostPosition; StationIndex gRideEntranceExitGhostStationIndex; static money64 RideEntranceExitPlaceGhost( - RideId rideIndex, const CoordsXY& entranceExitCoords, Direction direction, uint8_t placeType, StationIndex stationNum) + RideId rideIndex, const CoordsXY& entranceExitCoords, Direction direction, EntranceType placeType, StationIndex stationNum) { auto rideEntranceExitPlaceAction = GameActions::RideEntranceExitPlaceAction( - entranceExitCoords, direction, rideIndex, stationNum, placeType == ENTRANCE_TYPE_RIDE_EXIT); + entranceExitCoords, direction, rideIndex, stationNum, placeType == EntranceType::rideExit); rideEntranceExitPlaceAction.SetFlags({ CommandFlag::allowDuringPaused, CommandFlag::ghost }); auto res = GameActions::Execute(&rideEntranceExitPlaceAction, getGameState()); @@ -89,7 +89,7 @@ void OpenRCT2::RideEntranceExitRemoveGhost() { auto rideEntranceExitRemove = GameActions::RideEntranceExitRemoveAction( gRideEntranceExitGhostPosition, _currentRideIndex, gRideEntranceExitGhostStationIndex, - gRideEntranceExitPlaceType == ENTRANCE_TYPE_RIDE_EXIT); + gRideEntranceExitPlaceType == EntranceType::rideExit); rideEntranceExitRemove.SetFlags({ CommandFlag::ghost, CommandFlag::allowDuringPaused }); GameActions::Execute(&rideEntranceExitRemove, getGameState()); @@ -101,7 +101,7 @@ void OpenRCT2::RideEntranceExitRemoveGhost() * rct2: 0x006CA28C */ money64 OpenRCT2::RideEntranceExitPlaceGhost( - const Ride& ride, const CoordsXY& entranceExitCoords, Direction direction, int32_t placeType, StationIndex stationNum) + const Ride& ride, const CoordsXY& entranceExitCoords, Direction direction, EntranceType placeType, StationIndex stationNum) { RideConstructionRemoveGhosts(); money64 result = RideEntranceExitPlaceGhost(ride.id, entranceExitCoords, direction, placeType, stationNum); @@ -217,7 +217,7 @@ void ParkEntranceUpdateLocations() while (TileElementIteratorNext(&it)) { auto entranceElement = it.element->asEntrance(); - if (entranceElement != nullptr && entranceElement->getEntranceType() == ENTRANCE_TYPE_PARK_ENTRANCE + if (entranceElement != nullptr && entranceElement->getEntranceType() == EntranceType::parkEntrance && entranceElement->getSequenceIndex() == 0 && !entranceElement->isGhost()) { auto entrance = TileCoordsXYZD(it.x, it.y, it.element->baseHeight, it.element->getDirection()).ToCoordsXYZD(); diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index cd73e22d98..d36809877e 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -631,7 +631,7 @@ namespace OpenRCT2 } else { - if (tileElement->asEntrance()->getEntranceType() != ENTRANCE_TYPE_PARK_ENTRANCE) + if (tileElement->asEntrance()->getEntranceType() != EntranceType::parkEntrance) { FootpathQueueChainPush(tileElement->asEntrance()->getRideIndex()); } @@ -956,7 +956,7 @@ namespace OpenRCT2 { if (tileElement->getType() != TileElementType::entrance) continue; - if (tileElement->asEntrance()->getEntranceType() != ENTRANCE_TYPE_RIDE_ENTRANCE) + if (tileElement->asEntrance()->getEntranceType() != EntranceType::rideEntrance) continue; if (tileElement->asEntrance()->getRideIndex() != rideIndex) continue; @@ -1564,7 +1564,7 @@ namespace OpenRCT2 } else if (elementType == TileElementType::entrance) { - if (tileElement->asEntrance()->getEntranceType() == ENTRANCE_TYPE_RIDE_ENTRANCE) + if (tileElement->asEntrance()->getEntranceType() == EntranceType::rideEntrance) { FootpathQueueChainPush(tileElement->asEntrance()->getRideIndex()); FootpathChainRideQueue( diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 4c1a40b9b5..7ddaa9469c 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -1027,7 +1027,7 @@ namespace OpenRCT2 } break; case TileElementType::entrance: - if (it.element->asEntrance()->getEntranceType() == ENTRANCE_TYPE_PARK_ENTRANCE) + if (it.element->asEntrance()->getEntranceType() == EntranceType::parkEntrance) break; [[fallthrough]]; case TileElementType::track: @@ -1547,7 +1547,7 @@ namespace OpenRCT2 if (tileElement->baseHeight != entranceTileCoords.z) continue; - if (tileElement->asEntrance()->getEntranceType() != ENTRANCE_TYPE_PARK_ENTRANCE) + if (tileElement->asEntrance()->getEntranceType() != EntranceType::parkEntrance) continue; if (!ghost && tileElement->isGhost()) @@ -1573,7 +1573,7 @@ namespace OpenRCT2 if (tileElement->baseHeight != entranceTileCoords.z) continue; - if (tileElement->asEntrance()->getEntranceType() != ENTRANCE_TYPE_RIDE_ENTRANCE) + if (tileElement->asEntrance()->getEntranceType() != EntranceType::rideEntrance) continue; if (!ghost && tileElement->isGhost()) @@ -1599,7 +1599,7 @@ namespace OpenRCT2 if (tileElement->baseHeight != exitTileCoords.z) continue; - if (tileElement->asEntrance()->getEntranceType() != ENTRANCE_TYPE_RIDE_EXIT) + if (tileElement->asEntrance()->getEntranceType() != EntranceType::rideExit) continue; if (!ghost && tileElement->isGhost()) @@ -2128,7 +2128,7 @@ namespace OpenRCT2 auto type = tileElement->getType(); if (type == TileElementType::path || (type == TileElementType::entrance - && tileElement->asEntrance()->getEntranceType() == ENTRANCE_TYPE_PARK_ENTRANCE)) + && tileElement->asEntrance()->getEntranceType() == EntranceType::parkEntrance)) { destOwnership = OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED; // Do not own construction rights if too high/below surface diff --git a/src/openrct2/world/MapAnimation.cpp b/src/openrct2/world/MapAnimation.cpp index cc33f393c8..3980a8da0e 100644 --- a/src/openrct2/world/MapAnimation.cpp +++ b/src/openrct2/world/MapAnimation.cpp @@ -90,7 +90,7 @@ template static bool UpdateEntranceAnimation( const EntranceElement& entrance, const CoordsXYZ& loc, const int32_t baseZ, const Viewport* const viewport) { - if (entrance.getEntranceType() == ENTRANCE_TYPE_RIDE_ENTRANCE) + if (entrance.getEntranceType() == EntranceType::rideEntrance) { const auto* const ride = GetRide(entrance.getRideIndex()); if (ride != nullptr) @@ -108,7 +108,7 @@ static bool UpdateEntranceAnimation( } } } - else if (entrance.getEntranceType() == ENTRANCE_TYPE_PARK_ENTRANCE && entrance.getSequenceIndex() == 0) + else if (entrance.getEntranceType() == EntranceType::parkEntrance && entrance.getSequenceIndex() == 0) { if constexpr (invalidate) { @@ -559,11 +559,11 @@ static std::optional IsElementAnimated(const TileElementBase& elemen case TileElementType::entrance: { const auto* const entrance = element.asEntrance(); - if (entrance->getEntranceType() == ENTRANCE_TYPE_PARK_ENTRANCE && entrance->getSequenceIndex() == 0) + if (entrance->getEntranceType() == EntranceType::parkEntrance && entrance->getSequenceIndex() == 0) { return std::optional(UpdateType::invalidate); } - else if (entrance->getEntranceType() == ENTRANCE_TYPE_RIDE_ENTRANCE) + else if (entrance->getEntranceType() == EntranceType::rideEntrance) { return std::optional(UpdateType::invalidate); } diff --git a/src/openrct2/world/Park.cpp b/src/openrct2/world/Park.cpp index 5b2d3877e7..84cffdaf6e 100644 --- a/src/openrct2/world/Park.cpp +++ b/src/openrct2/world/Park.cpp @@ -653,7 +653,7 @@ namespace OpenRCT2::Park if (tileElement->getType() != TileElementType::entrance) continue; - if (tileElement->asEntrance()->getEntranceType() != ENTRANCE_TYPE_PARK_ENTRANCE) + if (tileElement->asEntrance()->getEntranceType() != EntranceType::parkEntrance) continue; if (!(tileElement->isGhost())) diff --git a/src/openrct2/world/TileInspector.cpp b/src/openrct2/world/TileInspector.cpp index 121737e044..f2f2cda597 100644 --- a/src/openrct2/world/TileInspector.cpp +++ b/src/openrct2/world/TileInspector.cpp @@ -241,17 +241,17 @@ namespace OpenRCT2::TileInspector auto& station = ride->getStation(stationIndex); auto entrance = station.Entrance; auto exit = station.Exit; - uint8_t entranceType = tileElement->asEntrance()->getEntranceType(); + auto entranceType = tileElement->asEntrance()->getEntranceType(); uint8_t z = tileElement->baseHeight; // Make sure this is the correct entrance or exit - if (entranceType == ENTRANCE_TYPE_RIDE_ENTRANCE && entrance.x == loc.x / kCoordsXYStep + if (entranceType == EntranceType::rideEntrance && 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 / kCoordsXYStep + entranceType == EntranceType::rideExit && exit.x == loc.x / kCoordsXYStep && exit.y == loc.y / kCoordsXYStep && exit.z == z) { station.Exit = { exit, newRotation }; @@ -460,8 +460,8 @@ namespace OpenRCT2::TileInspector { if (tileElement->getType() == TileElementType::entrance) { - uint8_t entranceType = tileElement->asEntrance()->getEntranceType(); - if (entranceType != ENTRANCE_TYPE_PARK_ENTRANCE) + auto entranceType = tileElement->asEntrance()->getEntranceType(); + if (entranceType != EntranceType::parkEntrance) { // Update the ride's known entrance or exit height auto ride = GetRide(tileElement->asEntrance()->getRideIndex()); @@ -474,9 +474,9 @@ namespace OpenRCT2::TileInspector uint8_t z = tileElement->baseHeight; // Make sure this is the correct entrance or exit - if (entranceType == ENTRANCE_TYPE_RIDE_ENTRANCE && entranceLoc == TileCoordsXYZ{ loc, z }) + if (entranceType == EntranceType::rideEntrance && entranceLoc == TileCoordsXYZ{ loc, z }) station.Entrance = { entranceLoc, z + heightOffset, entranceLoc.direction }; - else if (entranceType == ENTRANCE_TYPE_RIDE_EXIT && exitLoc == TileCoordsXYZ{ loc, z }) + else if (entranceType == EntranceType::rideExit && exitLoc == TileCoordsXYZ{ loc, z }) station.Exit = { exitLoc, z + heightOffset, exitLoc.direction }; } } @@ -655,12 +655,14 @@ namespace OpenRCT2::TileInspector switch (entranceElement->asEntrance()->getEntranceType()) { - case ENTRANCE_TYPE_RIDE_ENTRANCE: + case EntranceType::rideEntrance: station.Entrance = { loc, entranceElement->baseHeight, entranceElement->getDirection() }; break; - case ENTRANCE_TYPE_RIDE_EXIT: + case EntranceType::rideExit: station.Exit = { loc, entranceElement->baseHeight, entranceElement->getDirection() }; break; + default: + break; } } diff --git a/src/openrct2/world/tile_element/EntranceElement.cpp b/src/openrct2/world/tile_element/EntranceElement.cpp index 9a0274c2f9..23f293abb1 100644 --- a/src/openrct2/world/tile_element/EntranceElement.cpp +++ b/src/openrct2/world/tile_element/EntranceElement.cpp @@ -17,18 +17,18 @@ namespace OpenRCT2 { // rct2: 0x0097B974 - static constexpr uint16_t kEntranceDirections[] = { - (4), 0, 0, 0, 0, 0, 0, 0, // ENTRANCE_TYPE_RIDE_ENTRANCE, - (4), 0, 0, 0, 0, 0, 0, 0, // ENTRANCE_TYPE_RIDE_EXIT, - (4 | 1), 0, 0, 0, 0, 0, 0, 0, // ENTRANCE_TYPE_PARK_ENTRANCE - }; + static constexpr std::array, 3> kEntranceDirections = { { + { (4), 0, 0, 0, 0, 0, 0, 0 }, // EntranceType::rideEntrance, + { (4), 0, 0, 0, 0, 0, 0, 0 }, // EntranceType::rideExit, + { (4 | 1), 0, 0, 0, 0, 0, 0, 0 }, // EntranceType::parkEntrance + } }; - uint8_t EntranceElement::getEntranceType() const + EntranceType EntranceElement::getEntranceType() const { return entranceType; } - void EntranceElement::setEntranceType(uint8_t newType) + void EntranceElement::setEntranceType(EntranceType newType) { entranceType = newType; } @@ -129,7 +129,7 @@ namespace OpenRCT2 int32_t EntranceElement::getDirections() const { - return kEntranceDirections[(getEntranceType() * 8) + getSequenceIndex()]; + return kEntranceDirections[EnumValue(getEntranceType())][getSequenceIndex()]; } ObjectEntryIndex EntranceElement::getEntryIndex() const diff --git a/src/openrct2/world/tile_element/EntranceElement.h b/src/openrct2/world/tile_element/EntranceElement.h index 8c724e4d8c..89764c8e27 100644 --- a/src/openrct2/world/tile_element/EntranceElement.h +++ b/src/openrct2/world/tile_element/EntranceElement.h @@ -21,11 +21,11 @@ namespace OpenRCT2 class FootpathSurfaceObject; struct PathSurfaceDescriptor; - enum + enum class EntranceType : uint8_t { - ENTRANCE_TYPE_RIDE_ENTRANCE, - ENTRANCE_TYPE_RIDE_EXIT, - ENTRANCE_TYPE_PARK_ENTRANCE + rideEntrance, + rideExit, + parkEntrance }; enum @@ -47,7 +47,7 @@ namespace OpenRCT2 static constexpr TileElementType kElementType = TileElementType::entrance; private: - uint8_t entranceType; // 5 + EntranceType entranceType; // 5 uint8_t sequenceIndex; // 6. Only uses the lower nibble. StationIndex stationIndex; // 7 ObjectEntryIndex pathType; // 8 @@ -60,8 +60,8 @@ namespace OpenRCT2 #pragma clang diagnostic pop public: - uint8_t getEntranceType() const; - void setEntranceType(uint8_t newType); + EntranceType getEntranceType() const; + void setEntranceType(EntranceType newType); RideId getRideIndex() const; void setRideIndex(RideId newRideIndex);