From a2470c057354a0efe8cc46ee1ade07f7b69ffa9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Wed, 19 Jan 2022 15:17:11 +0200 Subject: [PATCH 1/9] Rename ride_id_t to RideId --- src/openrct2-ui/WindowManager.cpp | 10 +++--- .../windows/EditorObjectiveOptions.cpp | 4 +-- src/openrct2-ui/windows/Guest.cpp | 2 +- src/openrct2-ui/windows/GuestList.cpp | 6 ++-- src/openrct2-ui/windows/MazeConstruction.cpp | 2 +- src/openrct2-ui/windows/NewCampaign.cpp | 6 ++-- src/openrct2-ui/windows/Ride.cpp | 2 +- src/openrct2-ui/windows/RideConstruction.cpp | 22 ++++++------ src/openrct2-ui/windows/RideList.cpp | 2 +- src/openrct2-ui/windows/TileInspector.cpp | 4 +-- src/openrct2-ui/windows/TrackDesignPlace.cpp | 6 ++-- src/openrct2/actions/GameActionCompat.cpp | 4 +-- src/openrct2/actions/LandSetHeightAction.cpp | 2 +- .../actions/LargeSceneryPlaceAction.cpp | 2 +- src/openrct2/actions/ParkMarketingAction.cpp | 2 +- src/openrct2/actions/RideCreateAction.cpp | 4 +-- src/openrct2/actions/RideDemolishAction.cpp | 2 +- src/openrct2/actions/RideDemolishAction.h | 2 +- .../actions/RideEntranceExitPlaceAction.cpp | 2 +- .../actions/RideEntranceExitPlaceAction.h | 2 +- .../actions/RideEntranceExitRemoveAction.cpp | 4 +-- .../actions/RideEntranceExitRemoveAction.h | 2 +- .../actions/RideSetAppearanceAction.cpp | 2 +- .../actions/RideSetAppearanceAction.h | 2 +- src/openrct2/actions/RideSetNameAction.cpp | 2 +- src/openrct2/actions/RideSetNameAction.h | 2 +- src/openrct2/actions/RideSetPriceAction.cpp | 2 +- src/openrct2/actions/RideSetPriceAction.h | 2 +- src/openrct2/actions/RideSetSettingAction.cpp | 2 +- src/openrct2/actions/RideSetSettingAction.h | 2 +- src/openrct2/actions/RideSetStatusAction.cpp | 2 +- src/openrct2/actions/RideSetStatusAction.h | 2 +- src/openrct2/actions/RideSetVehicleAction.cpp | 2 +- src/openrct2/actions/RideSetVehicleAction.h | 2 +- src/openrct2/actions/SignSetNameAction.cpp | 2 +- src/openrct2/actions/TrackDesignAction.cpp | 8 ++--- src/openrct2/actions/TrackRemoveAction.cpp | 4 +-- src/openrct2/actions/WallPlaceAction.cpp | 2 +- src/openrct2/entity/Guest.cpp | 18 +++++----- src/openrct2/entity/Guest.h | 22 ++++++------ src/openrct2/entity/Peep.cpp | 2 +- src/openrct2/entity/Peep.h | 4 +-- src/openrct2/entity/Staff.cpp | 2 +- src/openrct2/entity/Staff.h | 2 +- src/openrct2/interface/InteractiveConsole.cpp | 14 ++++---- src/openrct2/interface/Window.h | 6 ++-- src/openrct2/interface/Window_internal.h | 2 +- src/openrct2/localisation/Formatter.h | 4 +-- src/openrct2/management/Marketing.cpp | 2 +- src/openrct2/management/Marketing.h | 4 +-- src/openrct2/management/NewsItem.cpp | 2 +- src/openrct2/network/NetworkTypes.h | 2 +- src/openrct2/park/ParkFile.cpp | 36 +++++++++---------- src/openrct2/peep/GuestPathfinding.cpp | 14 ++++---- src/openrct2/peep/GuestPathfinding.h | 2 +- src/openrct2/peep/RideUseSystem.h | 2 +- src/openrct2/rct1/S4Importer.cpp | 12 +++---- src/openrct2/rct12/RCT12.cpp | 4 +-- src/openrct2/rct12/RCT12.h | 8 ++--- src/openrct2/rct2/S6Importer.cpp | 10 +++--- src/openrct2/ride/Ride.cpp | 34 +++++++++--------- src/openrct2/ride/Ride.h | 26 +++++++------- src/openrct2/ride/RideAudio.cpp | 4 +-- src/openrct2/ride/RideConstruction.cpp | 12 +++---- src/openrct2/ride/RideConstruction.h | 6 ++-- src/openrct2/ride/RideRatings.cpp | 8 ++--- src/openrct2/ride/RideRatings.h | 2 +- src/openrct2/ride/RideTypes.h | 4 +-- src/openrct2/ride/Track.cpp | 10 +++--- src/openrct2/ride/Track.h | 6 ++-- src/openrct2/ride/TrackDesign.cpp | 6 ++-- src/openrct2/ride/TrackDesign.h | 6 ++-- src/openrct2/ride/TrackDesignSave.cpp | 12 +++---- src/openrct2/ride/TrackPaint.cpp | 2 +- src/openrct2/ride/Vehicle.cpp | 8 ++--- src/openrct2/ride/Vehicle.h | 2 +- src/openrct2/scripting/ScriptEngine.cpp | 2 +- .../scripting/bindings/entity/ScVehicle.cpp | 2 +- .../scripting/bindings/ride/ScRide.cpp | 2 +- .../scripting/bindings/ride/ScRide.hpp | 4 +-- .../scripting/bindings/ride/ScRideStation.cpp | 2 +- .../scripting/bindings/ride/ScRideStation.hpp | 4 +-- .../scripting/bindings/world/ScMap.cpp | 2 +- .../bindings/world/ScTileElement.cpp | 6 ++-- src/openrct2/windows/_legacy.cpp | 6 ++-- src/openrct2/world/Banner.cpp | 12 +++---- src/openrct2/world/Banner.h | 6 ++-- src/openrct2/world/Entrance.cpp | 10 +++--- src/openrct2/world/Footpath.cpp | 20 +++++------ src/openrct2/world/Footpath.h | 4 +-- src/openrct2/world/Map.cpp | 6 ++-- src/openrct2/world/Map.h | 6 ++-- src/openrct2/world/TileElement.cpp | 2 +- src/openrct2/world/TileElement.h | 20 +++++------ test/tests/Pathfinding.cpp | 2 +- 95 files changed, 287 insertions(+), 287 deletions(-) diff --git a/src/openrct2-ui/WindowManager.cpp b/src/openrct2-ui/WindowManager.cpp index 809f02ae25..254767854d 100644 --- a/src/openrct2-ui/WindowManager.cpp +++ b/src/openrct2-ui/WindowManager.cpp @@ -183,9 +183,9 @@ public: case WD_BANNER: return WindowBannerOpen(id); case WD_DEMOLISH_RIDE: - return WindowRideDemolishPromptOpen(get_ride(static_cast(id))); + return WindowRideDemolishPromptOpen(get_ride(static_cast(id))); case WD_REFURBISH_RIDE: - return WindowRideRefurbishPromptOpen(get_ride(static_cast(id))); + return WindowRideRefurbishPromptOpen(get_ride(static_cast(id))); case WD_NEW_CAMPAIGN: return WindowNewCampaignOpen(id); case WD_SIGN: @@ -263,7 +263,7 @@ public: } case WC_RIDE: { - const auto rideId = static_cast(intent->GetSIntExtra(INTENT_EXTRA_RIDE_ID)); + const auto rideId = static_cast(intent->GetSIntExtra(INTENT_EXTRA_RIDE_ID)); auto ride = get_ride(rideId); return ride == nullptr ? nullptr : WindowRideMainOpen(ride); } @@ -365,13 +365,13 @@ public: if (w == nullptr || w->number != rideIndex) { window_close_construction_windows(); - _currentRideIndex = static_cast(rideIndex); + _currentRideIndex = static_cast(rideIndex); OpenWindow(WC_RIDE_CONSTRUCTION); } else { ride_construction_invalidate_current_track(); - _currentRideIndex = static_cast(rideIndex); + _currentRideIndex = static_cast(rideIndex); } break; } diff --git a/src/openrct2-ui/windows/EditorObjectiveOptions.cpp b/src/openrct2-ui/windows/EditorObjectiveOptions.cpp index aae0c1a661..2f32668579 100644 --- a/src/openrct2-ui/windows/EditorObjectiveOptions.cpp +++ b/src/openrct2-ui/windows/EditorObjectiveOptions.cpp @@ -1006,7 +1006,7 @@ static void WindowEditorObjectiveOptionsRidesScrollmousedown( if (i < 0 || i >= w->no_list_items) return; - const auto rideId = static_cast(w->list_item_positions[i]); + const auto rideId = static_cast(w->list_item_positions[i]); auto ride = get_ride(rideId); if (ride != nullptr) { @@ -1100,7 +1100,7 @@ static void WindowEditorObjectiveOptionsRidesScrollpaint(rct_window* w, rct_draw } // Checkbox mark - const auto rideId = static_cast(w->list_item_positions[i]); + const auto rideId = static_cast(w->list_item_positions[i]); auto ride = get_ride(rideId); if (ride != nullptr) { diff --git a/src/openrct2-ui/windows/Guest.cpp b/src/openrct2-ui/windows/Guest.cpp index 5764c09940..7baa68b471 100644 --- a/src/openrct2-ui/windows/Guest.cpp +++ b/src/openrct2-ui/windows/Guest.cpp @@ -1638,7 +1638,7 @@ void WindowGuestRidesScrollPaint(rct_window* w, rct_drawpixelinfo* dpi, int32_t stringId = STR_WINDOW_COLOUR_2_STRINGID; } - const auto rideId = static_cast(w->list_item_positions[list_index]); + const auto rideId = static_cast(w->list_item_positions[list_index]); auto ride = get_ride(rideId); if (ride != nullptr) { diff --git a/src/openrct2-ui/windows/GuestList.cpp b/src/openrct2-ui/windows/GuestList.cpp index e97dcbb35e..0b458267f3 100644 --- a/src/openrct2-ui/windows/GuestList.cpp +++ b/src/openrct2-ui/windows/GuestList.cpp @@ -185,7 +185,7 @@ public: { case GuestListFilterType::GuestsOnRide: { - auto guestRide = get_ride(static_cast(index)); + auto guestRide = get_ride(static_cast(index)); if (guestRide != nullptr) { ft.Add( @@ -201,7 +201,7 @@ public: } case GuestListFilterType::GuestsInQueue: { - auto guestRide = get_ride(static_cast(index)); + auto guestRide = get_ride(static_cast(index)); if (guestRide != nullptr) { ft.Add(STR_QUEUING_FOR); @@ -216,7 +216,7 @@ public: } case GuestListFilterType::GuestsThinkingAboutRide: { - auto guestRide = get_ride(static_cast(index)); + auto guestRide = get_ride(static_cast(index)); if (guestRide != nullptr) { ft.Add(STR_NONE); diff --git a/src/openrct2-ui/windows/MazeConstruction.cpp b/src/openrct2-ui/windows/MazeConstruction.cpp index 91456031e3..51b1de3697 100644 --- a/src/openrct2-ui/windows/MazeConstruction.cpp +++ b/src/openrct2-ui/windows/MazeConstruction.cpp @@ -346,7 +346,7 @@ private: if (gRideEntranceExitPlaceDirection == INVALID_DIRECTION) return; - ride_id_t rideIndex = gRideEntranceExitPlaceRideIndex; + RideId rideIndex = gRideEntranceExitPlaceRideIndex; auto rideEntranceExitPlaceAction = RideEntranceExitPlaceAction( entranceOrExitCoords, direction_reverse(entranceOrExitCoords.direction), rideIndex, diff --git a/src/openrct2-ui/windows/NewCampaign.cpp b/src/openrct2-ui/windows/NewCampaign.cpp index da035f6443..83942d2676 100644 --- a/src/openrct2-ui/windows/NewCampaign.cpp +++ b/src/openrct2-ui/windows/NewCampaign.cpp @@ -60,10 +60,10 @@ static rct_widget window_new_campaign_widgets[] = { class NewCampaignWindow final : public Window { private: - std::vector RideList; + std::vector RideList; std::vector ShopItems; - static bool RideValueCompare(const ride_id_t& a, const ride_id_t& b) + static bool RideValueCompare(const RideId& a, const RideId& b) { auto valueA = 0; auto rideA = get_ride(a); @@ -78,7 +78,7 @@ private: return (valueB - valueA) < 0; } - static int32_t RideNameCompare(const ride_id_t& a, const ride_id_t& b) + static int32_t RideNameCompare(const RideId& a, const RideId& b) { std::string rideAName = ""; auto rideA = get_ride(a); diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index 73410ab600..be2efacdac 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -1559,7 +1559,7 @@ static void WindowRideAnchorBorderWidgets(rct_window* w) static std::optional GetStationIndexFromViewSelection(const rct_window& w) { - const auto* ride = get_ride(static_cast(w.number)); + const auto* ride = get_ride(static_cast(w.number)); if (ride == nullptr) return std::nullopt; diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index 0f83b00200..f9a063299a 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -190,10 +190,10 @@ static void WindowRideConstructionEntranceClick(rct_window* w); static void WindowRideConstructionExitClick(rct_window* w); static void WindowRideConstructionDrawTrackPiece( - rct_window* w, rct_drawpixelinfo* dpi, ride_id_t rideIndex, int32_t trackType, int32_t trackDirection, int32_t unknown, + rct_window* w, rct_drawpixelinfo* dpi, RideId rideIndex, int32_t trackType, int32_t trackDirection, int32_t unknown, int32_t width, int32_t height); static void Sub6CbcE2( - rct_drawpixelinfo* dpi, ride_id_t rideIndex, int32_t trackType, int32_t trackDirection, int32_t edx, + rct_drawpixelinfo* dpi, RideId rideIndex, int32_t trackType, int32_t trackDirection, int32_t edx, const CoordsXY& originCoords, int32_t originZ); static void WindowRideConstructionUpdateMapSelection(); static void WindowRideConstructionUpdatePossibleRideConfigurations(); @@ -226,7 +226,7 @@ static int32_t RideGetAlternativeType(Ride* ride) } /* move to ride.c */ -static void CloseRideWindowForConstruction(ride_id_t rideId) +static void CloseRideWindowForConstruction(RideId rideId) { rct_window* w = window_find_by_number(WC_RIDE, EnumValue(rideId)); if (w != nullptr && w->page == 1) @@ -239,7 +239,7 @@ static void CloseRideWindowForConstruction(ride_id_t rideId) */ rct_window* WindowRideConstructionOpen() { - ride_id_t rideIndex = _currentRideIndex; + RideId rideIndex = _currentRideIndex; CloseRideWindowForConstruction(rideIndex); auto ride = get_ride(rideIndex); @@ -1507,7 +1507,7 @@ static void RideConstructPlacedBackwardGameActionCallback(const GameAction* ga, */ static void WindowRideConstructionConstruct(rct_window* w) { - ride_id_t rideIndex; + RideId rideIndex; int32_t trackType, trackDirection, liftHillAndAlternativeState, properties; CoordsXYZ trackPos{}; @@ -2054,7 +2054,7 @@ static void WindowRideConstructionPaint(rct_window* w, rct_drawpixelinfo* dpi) if (widget->type == WindowWidgetType::Empty) return; - ride_id_t rideIndex; + RideId rideIndex; int32_t trackType, trackDirection, liftHillAndInvertedState; if (window_ride_construction_update_state( &trackType, &trackDirection, &rideIndex, &liftHillAndInvertedState, nullptr, nullptr)) @@ -2085,7 +2085,7 @@ static void WindowRideConstructionPaint(rct_window* w, rct_drawpixelinfo* dpi) } static void WindowRideConstructionDrawTrackPiece( - rct_window* w, rct_drawpixelinfo* dpi, ride_id_t rideIndex, int32_t trackType, int32_t trackDirection, + rct_window* w, rct_drawpixelinfo* dpi, RideId rideIndex, int32_t trackType, int32_t trackDirection, int32_t liftHillAndInvertedState, int32_t width, int32_t height) { auto ride = get_ride(rideIndex); @@ -2133,7 +2133,7 @@ static TileElement* _backupTileElementArrays[5]; * dh: trackType */ static void Sub6CbcE2( - rct_drawpixelinfo* dpi, ride_id_t rideIndex, int32_t trackType, int32_t trackDirection, int32_t liftHillAndInvertedState, + rct_drawpixelinfo* dpi, RideId rideIndex, int32_t trackType, int32_t trackDirection, int32_t liftHillAndInvertedState, const CoordsXY& originCoords, int32_t originZ) { paint_session* session = PaintSessionAlloc(dpi, 0); @@ -2273,7 +2273,7 @@ void WindowRideConstructionUpdateEnabledTrackPieces() */ void UpdateGhostTrackAndArrow() { - ride_id_t rideIndex; + RideId rideIndex; int32_t direction, type, liftHillAndAlternativeState; CoordsXYZ trackPos{}; @@ -3192,7 +3192,7 @@ void ride_construction_toolupdate_construct(const ScreenCoordsXY& screenCoords) gMapSelectionTiles.clear(); gMapSelectionTiles.push_back(*mapCoords); - ride_id_t rideIndex; + RideId rideIndex; int32_t trackType, trackDirection, liftHillAndAlternativeState; if (window_ride_construction_update_state( &trackType, &trackDirection, &rideIndex, &liftHillAndAlternativeState, nullptr, nullptr)) @@ -3412,7 +3412,7 @@ void ride_construction_toolupdate_entrance_exit(const ScreenCoordsXY& screenCoor void ride_construction_tooldown_construct(const ScreenCoordsXY& screenCoords) { const CursorState* state = context_get_cursor_state(); - ride_id_t rideIndex; + RideId rideIndex; int32_t trackType, trackDirection, liftHillAndAlternativeState, z, properties, highestZ; rct_window* w; diff --git a/src/openrct2-ui/windows/RideList.cpp b/src/openrct2-ui/windows/RideList.cpp index 0e949c4671..948684517e 100644 --- a/src/openrct2-ui/windows/RideList.cpp +++ b/src/openrct2-ui/windows/RideList.cpp @@ -149,7 +149,7 @@ class RideListWindow final : public Window private: bool _quickDemolishMode = false; int32_t _windowRideListInformationType = INFORMATION_TYPE_STATUS; - std::vector _rideList; + std::vector _rideList; public: void OnOpen() override diff --git a/src/openrct2-ui/windows/TileInspector.cpp b/src/openrct2-ui/windows/TileInspector.cpp index f00a6038ef..79a86784c6 100644 --- a/src/openrct2-ui/windows/TileInspector.cpp +++ b/src/openrct2-ui/windows/TileInspector.cpp @@ -1916,7 +1916,7 @@ static void WindowTileInspectorPaint(rct_window* w, rct_drawpixelinfo* dpi) case TileElementType::Track: { auto trackElement = tileElement->AsTrack(); - ride_id_t rideId = trackElement->GetRideIndex(); + RideId rideId = trackElement->GetRideIndex(); auto ride = get_ride(rideId); // Ride ID @@ -2091,7 +2091,7 @@ static void WindowTileInspectorPaint(rct_window* w, rct_drawpixelinfo* dpi) { // Ride ID ft = Formatter(); - ft.Add(tileElement->AsEntrance()->GetRideIndex()); + ft.Add(tileElement->AsEntrance()->GetRideIndex()); DrawTextBasic( dpi, screenCoords + ScreenCoordsXY{ 0, 22 }, STR_TILE_INSPECTOR_ENTRANCE_RIDE_ID, ft, { w->colours[1] }); diff --git a/src/openrct2-ui/windows/TrackDesignPlace.cpp b/src/openrct2-ui/windows/TrackDesignPlace.cpp index f2e7e0fbc1..a7c73439f9 100644 --- a/src/openrct2-ui/windows/TrackDesignPlace.cpp +++ b/src/openrct2-ui/windows/TrackDesignPlace.cpp @@ -97,7 +97,7 @@ static rct_window_event_list window_track_place_events([](auto& events) static std::vector _window_track_place_mini_preview; static CoordsXY _windowTrackPlaceLast; -static ride_id_t _window_track_place_ride_index; +static RideId _window_track_place_ride_index; static bool _window_track_place_last_was_valid; static CoordsXYZ _windowTrackPlaceLastValid; static money32 _window_track_place_last_cost; @@ -292,7 +292,7 @@ static void WindowTrackPlaceToolupdate(rct_window* w, rct_widgetindex widgetInde tdAction.SetCallback([trackLoc](const GameAction*, const GameActions::Result* result) { if (result->Error == GameActions::Status::Ok) { - _window_track_place_ride_index = result->GetData(); + _window_track_place_ride_index = result->GetData(); _windowTrackPlaceLastValid = trackLoc; _window_track_place_last_was_valid = true; } @@ -339,7 +339,7 @@ static void WindowTrackPlaceTooldown(rct_window* w, rct_widgetindex widgetIndex, tdAction.SetCallback([trackLoc](const GameAction*, const GameActions::Result* result) { if (result->Error == GameActions::Status::Ok) { - const auto rideId = result->GetData(); + const auto rideId = result->GetData(); auto ride = get_ride(rideId); if (ride != nullptr) { diff --git a/src/openrct2/actions/GameActionCompat.cpp b/src/openrct2/actions/GameActionCompat.cpp index 6fa88b3f59..2ccb75cad0 100644 --- a/src/openrct2/actions/GameActionCompat.cpp +++ b/src/openrct2/actions/GameActionCompat.cpp @@ -69,7 +69,7 @@ void ride_construct_new(RideSelection listItem) gameAction.SetCallback([](const GameAction* ga, const GameActions::Result* result) { if (result->Error != GameActions::Status::Ok) return; - const auto rideIndex = result->GetData(); + const auto rideIndex = result->GetData(); auto ride = get_ride(rideIndex); ride_construct(ride); }); @@ -118,7 +118,7 @@ void guest_set_name(uint16_t spriteIndex, const char* name) #pragma endregion #pragma region MazeSetTrack -money32 maze_set_track(const CoordsXYZD& loc, uint8_t flags, bool initialPlacement, ride_id_t rideIndex, uint8_t mode) +money32 maze_set_track(const CoordsXYZD& loc, uint8_t flags, bool initialPlacement, RideId rideIndex, uint8_t mode) { auto gameAction = MazeSetTrackAction(loc, initialPlacement, rideIndex, mode); gameAction.SetFlags(flags); diff --git a/src/openrct2/actions/LandSetHeightAction.cpp b/src/openrct2/actions/LandSetHeightAction.cpp index dd473f3764..ddaabf6243 100644 --- a/src/openrct2/actions/LandSetHeightAction.cpp +++ b/src/openrct2/actions/LandSetHeightAction.cpp @@ -272,7 +272,7 @@ rct_string_id LandSetHeightAction::CheckRideSupports() const { for (auto* trackElement : TileElementsView(_coords)) { - ride_id_t rideIndex = trackElement->GetRideIndex(); + RideId rideIndex = trackElement->GetRideIndex(); auto ride = get_ride(rideIndex); if (ride == nullptr) diff --git a/src/openrct2/actions/LargeSceneryPlaceAction.cpp b/src/openrct2/actions/LargeSceneryPlaceAction.cpp index 828bafac5a..abddc9176a 100644 --- a/src/openrct2/actions/LargeSceneryPlaceAction.cpp +++ b/src/openrct2/actions/LargeSceneryPlaceAction.cpp @@ -230,7 +230,7 @@ GameActions::Result LargeSceneryPlaceAction::Execute() const banner->type = 0; banner->position = TileCoordsXY(_loc); - ride_id_t rideIndex = banner_get_closest_ride_index({ _loc, maxHeight }); + RideId rideIndex = banner_get_closest_ride_index({ _loc, maxHeight }); if (rideIndex != RIDE_ID_NULL) { banner->ride_index = rideIndex; diff --git a/src/openrct2/actions/ParkMarketingAction.cpp b/src/openrct2/actions/ParkMarketingAction.cpp index 69e58b259d..57e81c936b 100644 --- a/src/openrct2/actions/ParkMarketingAction.cpp +++ b/src/openrct2/actions/ParkMarketingAction.cpp @@ -70,7 +70,7 @@ GameActions::Result ParkMarketingAction::Execute() const campaign.Flags = MarketingCampaignFlags::FIRST_WEEK; if (campaign.Type == ADVERTISING_CAMPAIGN_RIDE_FREE || campaign.Type == ADVERTISING_CAMPAIGN_RIDE) { - campaign.RideId = static_cast(_item); + campaign.RideId = static_cast(_item); } else if (campaign.Type == ADVERTISING_CAMPAIGN_FOOD_OR_DRINK_FREE) { diff --git a/src/openrct2/actions/RideCreateAction.cpp b/src/openrct2/actions/RideCreateAction.cpp index 5c27e7502f..368bfa79a5 100644 --- a/src/openrct2/actions/RideCreateAction.cpp +++ b/src/openrct2/actions/RideCreateAction.cpp @@ -110,7 +110,7 @@ GameActions::Result RideCreateAction::Query() const } auto res = GameActions::Result(); - res.SetData(ride_id_t{ rideIndex }); + res.SetData(RideId{ rideIndex }); return res; } @@ -310,7 +310,7 @@ GameActions::Result RideCreateAction::Execute() const window_invalidate_by_class(WC_RIDE_LIST); res.Expenditure = ExpenditureType::RideConstruction; - res.SetData(ride_id_t{ rideIndex }); + res.SetData(RideId{ rideIndex }); return res; } diff --git a/src/openrct2/actions/RideDemolishAction.cpp b/src/openrct2/actions/RideDemolishAction.cpp index b123814d14..f12cceae80 100644 --- a/src/openrct2/actions/RideDemolishAction.cpp +++ b/src/openrct2/actions/RideDemolishAction.cpp @@ -31,7 +31,7 @@ using namespace OpenRCT2; -RideDemolishAction::RideDemolishAction(ride_id_t rideIndex, uint8_t modifyType) +RideDemolishAction::RideDemolishAction(RideId rideIndex, uint8_t modifyType) : _rideIndex(rideIndex) , _modifyType(modifyType) { diff --git a/src/openrct2/actions/RideDemolishAction.h b/src/openrct2/actions/RideDemolishAction.h index d3a09b44ee..9deb0c3f39 100644 --- a/src/openrct2/actions/RideDemolishAction.h +++ b/src/openrct2/actions/RideDemolishAction.h @@ -19,7 +19,7 @@ private: public: RideDemolishAction() = default; - RideDemolishAction(ride_id_t rideIndex, uint8_t modifyType); + RideDemolishAction(RideId rideIndex, uint8_t modifyType); void AcceptParameters(GameActionParameterVisitor& visitor) override; diff --git a/src/openrct2/actions/RideEntranceExitPlaceAction.cpp b/src/openrct2/actions/RideEntranceExitPlaceAction.cpp index ecb6390f8e..7ac999eac9 100644 --- a/src/openrct2/actions/RideEntranceExitPlaceAction.cpp +++ b/src/openrct2/actions/RideEntranceExitPlaceAction.cpp @@ -17,7 +17,7 @@ #include "../world/MapAnimation.h" RideEntranceExitPlaceAction::RideEntranceExitPlaceAction( - const CoordsXY& loc, Direction direction, ride_id_t rideIndex, StationIndex stationNum, bool isExit) + const CoordsXY& loc, Direction direction, RideId rideIndex, StationIndex stationNum, bool isExit) : _loc(loc) , _direction(direction) , _rideIndex(rideIndex) diff --git a/src/openrct2/actions/RideEntranceExitPlaceAction.h b/src/openrct2/actions/RideEntranceExitPlaceAction.h index 58234cc2f9..2cca8c762f 100644 --- a/src/openrct2/actions/RideEntranceExitPlaceAction.h +++ b/src/openrct2/actions/RideEntranceExitPlaceAction.h @@ -24,7 +24,7 @@ private: public: RideEntranceExitPlaceAction() = default; RideEntranceExitPlaceAction( - const CoordsXY& loc, Direction direction, ride_id_t rideIndex, StationIndex stationNum, bool isExit); + const CoordsXY& loc, Direction direction, RideId rideIndex, StationIndex stationNum, bool isExit); void AcceptParameters(GameActionParameterVisitor& visitor) override; diff --git a/src/openrct2/actions/RideEntranceExitRemoveAction.cpp b/src/openrct2/actions/RideEntranceExitRemoveAction.cpp index 186cd9d90d..9ee4c52611 100644 --- a/src/openrct2/actions/RideEntranceExitRemoveAction.cpp +++ b/src/openrct2/actions/RideEntranceExitRemoveAction.cpp @@ -17,7 +17,7 @@ using namespace OpenRCT2; RideEntranceExitRemoveAction::RideEntranceExitRemoveAction( - const CoordsXY& loc, ride_id_t rideIndex, StationIndex stationNum, bool isExit) + const CoordsXY& loc, RideId rideIndex, StationIndex stationNum, bool isExit) : _loc(loc) , _rideIndex(rideIndex) , _stationNum(stationNum) @@ -46,7 +46,7 @@ void RideEntranceExitRemoveAction::Serialise(DataSerialiser& stream) } static TileElement* FindEntranceElement( - const CoordsXY& loc, ride_id_t rideIndex, int32_t stationNum, int32_t entranceType, uint32_t flags) + const CoordsXY& loc, RideId rideIndex, int32_t stationNum, int32_t entranceType, uint32_t flags) { const bool isGhost = flags & GAME_COMMAND_FLAG_GHOST; for (auto* entranceElement : TileElementsView(loc)) diff --git a/src/openrct2/actions/RideEntranceExitRemoveAction.h b/src/openrct2/actions/RideEntranceExitRemoveAction.h index ce06d0d1c6..455aca88c8 100644 --- a/src/openrct2/actions/RideEntranceExitRemoveAction.h +++ b/src/openrct2/actions/RideEntranceExitRemoveAction.h @@ -21,7 +21,7 @@ private: public: RideEntranceExitRemoveAction() = default; - RideEntranceExitRemoveAction(const CoordsXY& loc, ride_id_t rideIndex, StationIndex stationNum, bool isExit); + RideEntranceExitRemoveAction(const CoordsXY& loc, RideId rideIndex, StationIndex stationNum, bool isExit); void AcceptParameters(GameActionParameterVisitor& visitor) override; diff --git a/src/openrct2/actions/RideSetAppearanceAction.cpp b/src/openrct2/actions/RideSetAppearanceAction.cpp index 06cb0da04a..862c6a0350 100644 --- a/src/openrct2/actions/RideSetAppearanceAction.cpp +++ b/src/openrct2/actions/RideSetAppearanceAction.cpp @@ -22,7 +22,7 @@ #include "../world/Park.h" RideSetAppearanceAction::RideSetAppearanceAction( - ride_id_t rideIndex, RideSetAppearanceType type, uint16_t value, uint32_t index) + RideId rideIndex, RideSetAppearanceType type, uint16_t value, uint32_t index) : _rideIndex(rideIndex) , _type(type) , _value(value) diff --git a/src/openrct2/actions/RideSetAppearanceAction.h b/src/openrct2/actions/RideSetAppearanceAction.h index 10560405dc..42dd9a695a 100644 --- a/src/openrct2/actions/RideSetAppearanceAction.h +++ b/src/openrct2/actions/RideSetAppearanceAction.h @@ -34,7 +34,7 @@ private: public: RideSetAppearanceAction() = default; - RideSetAppearanceAction(ride_id_t rideIndex, RideSetAppearanceType type, uint16_t value, uint32_t index); + RideSetAppearanceAction(RideId rideIndex, RideSetAppearanceType type, uint16_t value, uint32_t index); void AcceptParameters(GameActionParameterVisitor& visitor) override; diff --git a/src/openrct2/actions/RideSetNameAction.cpp b/src/openrct2/actions/RideSetNameAction.cpp index 8a3c916ef6..7f4cb158f0 100644 --- a/src/openrct2/actions/RideSetNameAction.cpp +++ b/src/openrct2/actions/RideSetNameAction.cpp @@ -21,7 +21,7 @@ #include "../ui/WindowManager.h" #include "../world/Park.h" -RideSetNameAction::RideSetNameAction(ride_id_t rideIndex, const std::string& name) +RideSetNameAction::RideSetNameAction(RideId rideIndex, const std::string& name) : _rideIndex(rideIndex) , _name(name) { diff --git a/src/openrct2/actions/RideSetNameAction.h b/src/openrct2/actions/RideSetNameAction.h index 869a04ad26..d32a4dfa4f 100644 --- a/src/openrct2/actions/RideSetNameAction.h +++ b/src/openrct2/actions/RideSetNameAction.h @@ -19,7 +19,7 @@ private: public: RideSetNameAction() = default; - RideSetNameAction(ride_id_t rideIndex, const std::string& name); + RideSetNameAction(RideId rideIndex, const std::string& name); void AcceptParameters(GameActionParameterVisitor& visitor) override; diff --git a/src/openrct2/actions/RideSetPriceAction.cpp b/src/openrct2/actions/RideSetPriceAction.cpp index ad73c2a3ff..4bcf851c64 100644 --- a/src/openrct2/actions/RideSetPriceAction.cpp +++ b/src/openrct2/actions/RideSetPriceAction.cpp @@ -21,7 +21,7 @@ #include "../ride/ShopItem.h" #include "../world/Park.h" -RideSetPriceAction::RideSetPriceAction(ride_id_t rideIndex, money16 price, bool primaryPrice) +RideSetPriceAction::RideSetPriceAction(RideId rideIndex, money16 price, bool primaryPrice) : _rideIndex(rideIndex) , _price(price) , _primaryPrice(primaryPrice) diff --git a/src/openrct2/actions/RideSetPriceAction.h b/src/openrct2/actions/RideSetPriceAction.h index 6e24bd54e4..176f53527b 100644 --- a/src/openrct2/actions/RideSetPriceAction.h +++ b/src/openrct2/actions/RideSetPriceAction.h @@ -20,7 +20,7 @@ private: public: RideSetPriceAction() = default; - RideSetPriceAction(ride_id_t rideIndex, money16 price, bool primaryPrice); + RideSetPriceAction(RideId rideIndex, money16 price, bool primaryPrice); void AcceptParameters(GameActionParameterVisitor& visitor) override; diff --git a/src/openrct2/actions/RideSetSettingAction.cpp b/src/openrct2/actions/RideSetSettingAction.cpp index 07561aad5d..fba3a41115 100644 --- a/src/openrct2/actions/RideSetSettingAction.cpp +++ b/src/openrct2/actions/RideSetSettingAction.cpp @@ -14,7 +14,7 @@ #include "../ride/Ride.h" #include "../ride/RideData.h" -RideSetSettingAction::RideSetSettingAction(ride_id_t rideIndex, RideSetSetting setting, uint8_t value) +RideSetSettingAction::RideSetSettingAction(RideId rideIndex, RideSetSetting setting, uint8_t value) : _rideIndex(rideIndex) , _setting(setting) , _value(value) diff --git a/src/openrct2/actions/RideSetSettingAction.h b/src/openrct2/actions/RideSetSettingAction.h index b4d0ce48a1..30c736e1af 100644 --- a/src/openrct2/actions/RideSetSettingAction.h +++ b/src/openrct2/actions/RideSetSettingAction.h @@ -35,7 +35,7 @@ private: public: RideSetSettingAction() = default; - RideSetSettingAction(ride_id_t rideIndex, RideSetSetting setting, uint8_t value); + RideSetSettingAction(RideId rideIndex, RideSetSetting setting, uint8_t value); void AcceptParameters(GameActionParameterVisitor& visitor) override; diff --git a/src/openrct2/actions/RideSetStatusAction.cpp b/src/openrct2/actions/RideSetStatusAction.cpp index f06e2eb590..a2bf6ab907 100644 --- a/src/openrct2/actions/RideSetStatusAction.cpp +++ b/src/openrct2/actions/RideSetStatusAction.cpp @@ -29,7 +29,7 @@ static rct_string_id _StatusErrorTitles[] = { STR_CANT_SIMULATE, }; -RideSetStatusAction::RideSetStatusAction(ride_id_t rideIndex, RideStatus status) +RideSetStatusAction::RideSetStatusAction(RideId rideIndex, RideStatus status) : _rideIndex(rideIndex) , _status(status) { diff --git a/src/openrct2/actions/RideSetStatusAction.h b/src/openrct2/actions/RideSetStatusAction.h index 393391992b..9090310115 100644 --- a/src/openrct2/actions/RideSetStatusAction.h +++ b/src/openrct2/actions/RideSetStatusAction.h @@ -19,7 +19,7 @@ private: public: RideSetStatusAction() = default; - RideSetStatusAction(ride_id_t rideIndex, RideStatus status); + RideSetStatusAction(RideId rideIndex, RideStatus status); void AcceptParameters(GameActionParameterVisitor& visitor) override; diff --git a/src/openrct2/actions/RideSetVehicleAction.cpp b/src/openrct2/actions/RideSetVehicleAction.cpp index 209f4eb3ee..54a6f3c7cd 100644 --- a/src/openrct2/actions/RideSetVehicleAction.cpp +++ b/src/openrct2/actions/RideSetVehicleAction.cpp @@ -31,7 +31,7 @@ constexpr static rct_string_id SetVehicleTypeErrorTitle[] = { STR_RIDE_SET_VEHICLE_TYPE_FAIL, }; -RideSetVehicleAction::RideSetVehicleAction(ride_id_t rideIndex, RideSetVehicleType type, uint8_t value, uint8_t colour) +RideSetVehicleAction::RideSetVehicleAction(RideId rideIndex, RideSetVehicleType type, uint8_t value, uint8_t colour) : _rideIndex(rideIndex) , _type(type) , _value(value) diff --git a/src/openrct2/actions/RideSetVehicleAction.h b/src/openrct2/actions/RideSetVehicleAction.h index f96a32c886..4b88c7bea7 100644 --- a/src/openrct2/actions/RideSetVehicleAction.h +++ b/src/openrct2/actions/RideSetVehicleAction.h @@ -29,7 +29,7 @@ private: public: RideSetVehicleAction() = default; - RideSetVehicleAction(ride_id_t rideIndex, RideSetVehicleType type, uint8_t value, uint8_t colour = 0); + RideSetVehicleAction(RideId rideIndex, RideSetVehicleType type, uint8_t value, uint8_t colour = 0); void AcceptParameters(GameActionParameterVisitor& visitor) override; diff --git a/src/openrct2/actions/SignSetNameAction.cpp b/src/openrct2/actions/SignSetNameAction.cpp index 6534391923..0763dc5d1e 100644 --- a/src/openrct2/actions/SignSetNameAction.cpp +++ b/src/openrct2/actions/SignSetNameAction.cpp @@ -72,7 +72,7 @@ GameActions::Result SignSetNameAction::Execute() const else { // If empty name take closest ride name. - ride_id_t rideIndex = banner_get_closest_ride_index({ banner->position.ToCoordsXY(), 16 }); + RideId rideIndex = banner_get_closest_ride_index({ banner->position.ToCoordsXY(), 16 }); if (rideIndex == RIDE_ID_NULL) { banner->flags &= ~BANNER_FLAG_LINKED_TO_RIDE; diff --git a/src/openrct2/actions/TrackDesignAction.cpp b/src/openrct2/actions/TrackDesignAction.cpp index a6cd6017eb..33e5b234b9 100644 --- a/src/openrct2/actions/TrackDesignAction.cpp +++ b/src/openrct2/actions/TrackDesignAction.cpp @@ -84,7 +84,7 @@ GameActions::Result TrackDesignAction::Query() const return GameActions::Result(GameActions::Status::NoFreeElements, STR_CANT_CREATE_NEW_RIDE_ATTRACTION, STR_NONE); } - const auto rideIndex = r.GetData(); + const auto rideIndex = r.GetData(); auto ride = get_ride(rideIndex); if (ride == nullptr) { @@ -122,7 +122,7 @@ GameActions::Result TrackDesignAction::Query() const } res.Cost = queryRes.Cost; - res.SetData(ride_id_t{ RIDE_ID_NULL }); + res.SetData(RideId{ RIDE_ID_NULL }); return res; } @@ -156,7 +156,7 @@ GameActions::Result TrackDesignAction::Execute() const return GameActions::Result(GameActions::Status::NoFreeElements, STR_CANT_CREATE_NEW_RIDE_ATTRACTION, STR_NONE); } - const auto rideIndex = r.GetData(); + const auto rideIndex = r.GetData(); auto ride = get_ride(rideIndex); if (ride == nullptr) { @@ -273,7 +273,7 @@ GameActions::Result TrackDesignAction::Execute() const r = GameActions::ExecuteNested(&gameAction); } res.Cost = execRes.Cost; - res.SetData(ride_id_t{ ride->id }); + res.SetData(RideId{ ride->id }); return res; } diff --git a/src/openrct2/actions/TrackRemoveAction.cpp b/src/openrct2/actions/TrackRemoveAction.cpp index 44c2430eb2..916b4ee131 100644 --- a/src/openrct2/actions/TrackRemoveAction.cpp +++ b/src/openrct2/actions/TrackRemoveAction.cpp @@ -121,7 +121,7 @@ GameActions::Result TrackRemoveAction::Query() const STR_YOU_ARE_NOT_ALLOWED_TO_REMOVE_THIS_SECTION); } - ride_id_t rideIndex = tileElement->AsTrack()->GetRideIndex(); + RideId rideIndex = tileElement->AsTrack()->GetRideIndex(); const auto trackType = tileElement->AsTrack()->GetTrackType(); auto ride = get_ride(rideIndex); @@ -308,7 +308,7 @@ GameActions::Result TrackRemoveAction::Execute() const return GameActions::Result(GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_REMOVE_THIS, STR_NONE); } - ride_id_t rideIndex = tileElement->AsTrack()->GetRideIndex(); + RideId rideIndex = tileElement->AsTrack()->GetRideIndex(); const auto trackType = tileElement->AsTrack()->GetTrackType(); bool isLiftHill = tileElement->AsTrack()->HasChain(); diff --git a/src/openrct2/actions/WallPlaceAction.cpp b/src/openrct2/actions/WallPlaceAction.cpp index e5af0332c4..d5d27bb3d5 100644 --- a/src/openrct2/actions/WallPlaceAction.cpp +++ b/src/openrct2/actions/WallPlaceAction.cpp @@ -347,7 +347,7 @@ GameActions::Result WallPlaceAction::Execute() const banner->type = 0; // Banner must be deleted after this point in an early return banner->position = TileCoordsXY(_loc); - ride_id_t rideIndex = banner_get_closest_ride_index(targetLoc); + RideId rideIndex = banner_get_closest_ride_index(targetLoc); if (rideIndex != RIDE_ID_NULL) { banner->ride_index = rideIndex; diff --git a/src/openrct2/entity/Guest.cpp b/src/openrct2/entity/Guest.cpp index 6c265a488d..91d09e90d3 100644 --- a/src/openrct2/entity/Guest.cpp +++ b/src/openrct2/entity/Guest.cpp @@ -439,7 +439,7 @@ static void peep_decide_whether_to_leave_park(Guest* peep); static void peep_leave_park(Guest* peep); static void peep_head_for_nearest_ride_type(Guest* peep, int32_t rideType); static void peep_head_for_nearest_ride_with_flags(Guest* peep, int32_t rideTypeFlags); -bool loc_690FD0(Peep* peep, ride_id_t* rideToView, uint8_t* rideSeatToView, TileElement* tileElement); +bool loc_690FD0(Peep* peep, RideId* rideToView, uint8_t* rideSeatToView, TileElement* tileElement); template<> bool EntityBase::Is() const { @@ -3155,7 +3155,7 @@ template static void peep_head_for_nearest_ride(Guest* peep, bool co } // Filter the considered rides - ride_id_t potentialRides[OpenRCT2::Limits::MaxRidesInPark]; + RideId potentialRides[OpenRCT2::Limits::MaxRidesInPark]; size_t numPotentialRides = 0; for (auto& ride : GetRideManager()) { @@ -3271,7 +3271,7 @@ void Guest::StopPurchaseThought(uint8_t ride_type) * * rct2: 0x0069AEB7 */ -static bool peep_should_use_cash_machine(Guest* peep, ride_id_t rideIndex) +static bool peep_should_use_cash_machine(Guest* peep, RideId rideIndex) { if (gParkFlags & PARK_FLAGS_NO_MONEY) return false; @@ -5178,7 +5178,7 @@ void Guest::UpdateRide() } static void peep_update_walking_break_scenery(Guest* peep); -static bool peep_find_ride_to_look_at(Peep* peep, uint8_t edge, ride_id_t* rideToView, uint8_t* rideSeatToView); +static bool peep_find_ride_to_look_at(Peep* peep, uint8_t edge, RideId* rideToView, uint8_t* rideSeatToView); /** * @@ -5394,7 +5394,7 @@ void Guest::UpdateWalking() for (; !(edges & (1 << chosen_edge));) chosen_edge = (chosen_edge + 1) & 3; - ride_id_t ride_to_view; + RideId ride_to_view; uint8_t ride_seat_to_view; if (!peep_find_ride_to_look_at(this, chosen_edge, &ride_to_view, &ride_seat_to_view)) return; @@ -6197,7 +6197,7 @@ static bool peep_should_watch_ride(TileElement* tileElement) return true; } -bool loc_690FD0(Peep* peep, ride_id_t* rideToView, uint8_t* rideSeatToView, TileElement* tileElement) +bool loc_690FD0(Peep* peep, RideId* rideToView, uint8_t* rideSeatToView, TileElement* tileElement) { auto ride = get_ride(tileElement->AsTrack()->GetRideIndex()); if (ride == nullptr) @@ -6244,7 +6244,7 @@ bool loc_690FD0(Peep* peep, ride_id_t* rideToView, uint8_t* rideSeatToView, Tile * @param[out] rideSeatToView (ch) * @return !CF */ -static bool peep_find_ride_to_look_at(Peep* peep, uint8_t edge, ride_id_t* rideToView, uint8_t* rideSeatToView) +static bool peep_find_ride_to_look_at(Peep* peep, uint8_t edge, RideId* rideToView, uint8_t* rideSeatToView) { TileElement* tileElement; @@ -6822,7 +6822,7 @@ void Guest::InsertNewThought(PeepThoughtType thought_type, ShopItem shopItem) InsertNewThought(thought_type, static_cast(shopItem)); } -void Guest::InsertNewThought(PeepThoughtType thought_type, ride_id_t rideId) +void Guest::InsertNewThought(PeepThoughtType thought_type, RideId rideId) { InsertNewThought(thought_type, static_cast(rideId)); } @@ -7399,7 +7399,7 @@ static bool IsThoughtShopItemRelated(const PeepThoughtType type) return false; } -void Guest::RemoveRideFromMemory(ride_id_t rideId) +void Guest::RemoveRideFromMemory(RideId rideId) { if (State == PeepState::Watching) { diff --git a/src/openrct2/entity/Guest.h b/src/openrct2/entity/Guest.h index c5cba093fd..dcd7ea513e 100644 --- a/src/openrct2/entity/Guest.h +++ b/src/openrct2/entity/Guest.h @@ -191,7 +191,7 @@ struct PeepThought PeepThoughtType type; union { - ride_id_t rideId; + RideId rideId; ShopItem shopItem; uint16_t item; }; @@ -263,7 +263,7 @@ public: uint8_t GuestNumRides; uint16_t GuestNextInQueue; int32_t ParkEntryTime; - ride_id_t GuestHeadingToRideId; + RideId GuestHeadingToRideId; uint8_t GuestIsLostCountdown; uint8_t GuestTimeOnRide; money16 PaidToEnter; @@ -285,13 +285,13 @@ public: uint16_t TimeInQueue; money32 CashInPocket; money32 CashSpent; - ride_id_t Photo1RideRef; - ride_id_t Photo2RideRef; - ride_id_t Photo3RideRef; - ride_id_t Photo4RideRef; + RideId Photo1RideRef; + RideId Photo2RideRef; + RideId Photo3RideRef; + RideId Photo4RideRef; int8_t RejoinQueueTimeout; // whilst waiting for a free vehicle (or pair) in the entrance - ride_id_t PreviousRide; + RideId PreviousRide; uint16_t PreviousRideTimeOut; std::array Thoughts; // 0x3F Litter Count split into lots of 3 with time, 0xC0 Time since last recalc @@ -305,7 +305,7 @@ public: uint8_t VoucherType; union { - ride_id_t VoucherRideId; + RideId VoucherRideId; ShopItemIndex VoucherShopItem; }; uint8_t SurroundingsThoughtTimeout; @@ -315,7 +315,7 @@ public: uint8_t BalloonColour; uint8_t UmbrellaColour; uint8_t HatColour; - ride_id_t FavouriteRide; + RideId FavouriteRide; uint8_t FavouriteRideRating; uint64_t ItemFlags; @@ -358,7 +358,7 @@ public: void UpdateEasterEggInteractions(); void InsertNewThought(PeepThoughtType thought_type); void InsertNewThought(PeepThoughtType thought_type, ShopItem thought_arguments); - void InsertNewThought(PeepThoughtType thought_type, ride_id_t rideId); + void InsertNewThought(PeepThoughtType thought_type, RideId rideId); void InsertNewThought(PeepThoughtType thought_type, uint16_t thought_arguments); static Guest* Generate(const CoordsXYZ& coords); bool UpdateQueuePosition(PeepActionType previous_action); @@ -374,7 +374,7 @@ public: // Removes the ride from the guests memory, this includes // the history, thoughts, etc. - void RemoveRideFromMemory(ride_id_t rideId); + void RemoveRideFromMemory(RideId rideId); private: void UpdateRide(); diff --git a/src/openrct2/entity/Peep.cpp b/src/openrct2/entity/Peep.cpp index b1f052babe..eb1d23fe93 100644 --- a/src/openrct2/entity/Peep.cpp +++ b/src/openrct2/entity/Peep.cpp @@ -2188,7 +2188,7 @@ static void peep_interact_with_path(Peep* peep, const CoordsXYE& coords) */ static bool peep_interact_with_shop(Peep* peep, const CoordsXYE& coords) { - ride_id_t rideIndex = coords.element->AsTrack()->GetRideIndex(); + RideId rideIndex = coords.element->AsTrack()->GetRideIndex(); auto ride = get_ride(rideIndex); if (ride == nullptr || !ride->GetRideTypeDescriptor().HasFlag(RIDE_TYPE_FLAG_IS_SHOP)) return false; diff --git a/src/openrct2/entity/Peep.h b/src/openrct2/entity/Peep.h index 953555936a..97087a0182 100644 --- a/src/openrct2/entity/Peep.h +++ b/src/openrct2/entity/Peep.h @@ -332,7 +332,7 @@ struct Peep : EntityBase uint8_t EnergyTarget; uint8_t Mass; uint8_t WindowInvalidateFlags; - ride_id_t CurrentRide; + RideId CurrentRide; StationIndex CurrentRideStation; uint8_t CurrentTrain; union @@ -364,7 +364,7 @@ struct Peep : EntityBase uint8_t MazeLastEdge; Direction PeepDirection; // Direction ? }; - ride_id_t InteractionRideIndex; + RideId InteractionRideIndex; uint32_t Id; uint8_t PathCheckOptimisation; // see peep.checkForPath TileCoordsXYZD PathfindGoal; diff --git a/src/openrct2/entity/Staff.cpp b/src/openrct2/entity/Staff.cpp index 1b195b0a55..b3e5a93e82 100644 --- a/src/openrct2/entity/Staff.cpp +++ b/src/openrct2/entity/Staff.cpp @@ -2599,7 +2599,7 @@ bool Staff::UpdateFixingLeaveByEntranceExit(bool firstRun, const Ride* ride) /** * rct2: 0x6B7588 */ -void Staff::UpdateRideInspected(ride_id_t rideIndex) +void Staff::UpdateRideInspected(RideId rideIndex) { auto ride = get_ride(rideIndex); if (ride != nullptr) diff --git a/src/openrct2/entity/Staff.h b/src/openrct2/entity/Staff.h index ee9a72b088..dff443a1aa 100644 --- a/src/openrct2/entity/Staff.h +++ b/src/openrct2/entity/Staff.h @@ -94,7 +94,7 @@ private: bool UpdateFixingMoveToStationExit(bool firstRun, const Ride* ride); bool UpdateFixingFinishFixOrInspect(bool firstRun, int32_t steps, Ride* ride); bool UpdateFixingLeaveByEntranceExit(bool firstRun, const Ride* ride); - void UpdateRideInspected(ride_id_t rideIndex); + void UpdateRideInspected(RideId rideIndex); void UpdateHeadingToInspect(); bool DoHandymanPathFinding(); diff --git a/src/openrct2/interface/InteractiveConsole.cpp b/src/openrct2/interface/InteractiveConsole.cpp index bb18e60915..0db4bde6d5 100644 --- a/src/openrct2/interface/InteractiveConsole.cpp +++ b/src/openrct2/interface/InteractiveConsole.cpp @@ -196,7 +196,7 @@ static int32_t cc_rides(InteractiveConsole& console, const arguments_t& argv) } else { - int32_t res = set_operating_setting(static_cast(ride_index), RideSetSetting::RideType, type); + int32_t res = set_operating_setting(static_cast(ride_index), RideSetSetting::RideType, type); if (res == MONEY32_UNDEFINED) { if (!gCheatsAllowArbitraryRideTypeChanges) @@ -226,7 +226,7 @@ static int32_t cc_rides(InteractiveConsole& console, const arguments_t& argv) } else { - auto ride = get_ride(static_cast(ride_index)); + auto ride = get_ride(static_cast(ride_index)); if (mode >= static_cast(RideMode::Count)) { console.WriteFormatLine("Invalid ride mode."); @@ -258,7 +258,7 @@ static int32_t cc_rides(InteractiveConsole& console, const arguments_t& argv) } else { - auto ride = get_ride(static_cast(ride_index)); + auto ride = get_ride(static_cast(ride_index)); if (mass <= 0) { console.WriteFormatLine("Friction value must be strictly positive"); @@ -296,7 +296,7 @@ static int32_t cc_rides(InteractiveConsole& console, const arguments_t& argv) } else { - auto ride = get_ride(static_cast(ride_index)); + auto ride = get_ride(static_cast(ride_index)); if (excitement <= 0) { console.WriteFormatLine("Excitement value must be strictly positive"); @@ -327,7 +327,7 @@ static int32_t cc_rides(InteractiveConsole& console, const arguments_t& argv) } else { - auto ride = get_ride(static_cast(ride_index)); + auto ride = get_ride(static_cast(ride_index)); if (intensity <= 0) { console.WriteFormatLine("Intensity value must be strictly positive"); @@ -358,7 +358,7 @@ static int32_t cc_rides(InteractiveConsole& console, const arguments_t& argv) } else { - auto ride = get_ride(static_cast(ride_index)); + auto ride = get_ride(static_cast(ride_index)); if (nausea <= 0) { console.WriteFormatLine("Nausea value must be strictly positive"); @@ -428,7 +428,7 @@ static int32_t cc_rides(InteractiveConsole& console, const arguments_t& argv) } else { - auto rideSetPrice = RideSetPriceAction(static_cast(rideId), price, true); + auto rideSetPrice = RideSetPriceAction(static_cast(rideId), price, true); GameActions::Execute(&rideSetPrice); } } diff --git a/src/openrct2/interface/Window.h b/src/openrct2/interface/Window.h index 3596864749..cb01175199 100644 --- a/src/openrct2/interface/Window.h +++ b/src/openrct2/interface/Window.h @@ -269,7 +269,7 @@ struct campaign_variables int16_t no_weeks; // 0x482 union { - ride_id_t RideId; // 0x484 + RideId RideId; // 0x484 ObjectEntryIndex ShopItemId; // 0x484 }; uint32_t pad_486; @@ -858,10 +858,10 @@ void window_follow_sprite(rct_window* w, size_t spriteIndex); void window_unfollow_sprite(rct_window* w); bool window_ride_construction_update_state( - int32_t* trackType, int32_t* trackDirection, ride_id_t* rideIndex, int32_t* _liftHillAndAlternativeState, + int32_t* trackType, int32_t* trackDirection, RideId* rideIndex, int32_t* _liftHillAndAlternativeState, CoordsXYZ* trackPos, int32_t* properties); money32 place_provisional_track_piece( - ride_id_t rideIndex, int32_t trackType, int32_t trackDirection, int32_t liftHillAndAlternativeState, + RideId rideIndex, int32_t trackType, int32_t trackDirection, int32_t liftHillAndAlternativeState, const CoordsXYZ& trackPos); extern RideConstructionState _rideConstructionState2; diff --git a/src/openrct2/interface/Window_internal.h b/src/openrct2/interface/Window_internal.h index 7ed0b20d60..1e41e1b786 100644 --- a/src/openrct2/interface/Window_internal.h +++ b/src/openrct2/interface/Window_internal.h @@ -48,7 +48,7 @@ struct rct_window union { rct_windownumber number{}; - ride_id_t rideId; + RideId rideId; }; uint16_t flags{}; rct_scroll scrolls[3]; diff --git a/src/openrct2/localisation/Formatter.h b/src/openrct2/localisation/Formatter.h index a7203f2f00..1a9e35bcb5 100644 --- a/src/openrct2/localisation/Formatter.h +++ b/src/openrct2/localisation/Formatter.h @@ -17,7 +17,7 @@ #include extern thread_local uint8_t gCommonFormatArgs[80]; -enum class ride_id_t : uint16_t; +enum class RideId : uint16_t; class Formatter { @@ -91,7 +91,7 @@ public: std::is_same_v::type, int32_t> || std::is_same_v::type, money32> || std::is_same_v::type, money64> || - std::is_same_v::type, ride_id_t> || + std::is_same_v::type, RideId> || std::is_same_v::type, rct_string_id> || std::is_same_v::type, uint16_t> || std::is_same_v::type, uint32_t> || diff --git a/src/openrct2/management/Marketing.cpp b/src/openrct2/management/Marketing.cpp index adb8a0dd11..ded60a90ef 100644 --- a/src/openrct2/management/Marketing.cpp +++ b/src/openrct2/management/Marketing.cpp @@ -243,7 +243,7 @@ void marketing_new_campaign(const MarketingCampaign& campaign) } } -void MarketingCancelCampaignsForRide(const ride_id_t rideId) +void MarketingCancelCampaignsForRide(const RideId rideId) { auto isCampaignForRideFn = [&rideId](MarketingCampaign& campaign) { if (campaign.Type == ADVERTISING_CAMPAIGN_RIDE_FREE || campaign.Type == ADVERTISING_CAMPAIGN_RIDE) diff --git a/src/openrct2/management/Marketing.h b/src/openrct2/management/Marketing.h index aa110c1d0e..0ea501010f 100644 --- a/src/openrct2/management/Marketing.h +++ b/src/openrct2/management/Marketing.h @@ -50,7 +50,7 @@ struct MarketingCampaign uint8_t Flags{}; union { - ride_id_t RideId{}; + RideId RideId{}; ShopItemIndex ShopItemType; }; }; @@ -69,4 +69,4 @@ void marketing_set_guest_campaign(Guest* peep, int32_t campaign); bool marketing_is_campaign_type_applicable(int32_t campaignType); MarketingCampaign* marketing_get_campaign(int32_t campaignType); void marketing_new_campaign(const MarketingCampaign& campaign); -void MarketingCancelCampaignsForRide(const ride_id_t rideId); +void MarketingCancelCampaignsForRide(const RideId rideId); diff --git a/src/openrct2/management/NewsItem.cpp b/src/openrct2/management/NewsItem.cpp index 10d9544e0f..a2864fd157 100644 --- a/src/openrct2/management/NewsItem.cpp +++ b/src/openrct2/management/NewsItem.cpp @@ -213,7 +213,7 @@ std::optional News::GetSubjectLocation(News::ItemType type, int32_t s { case News::ItemType::Ride: { - Ride* ride = get_ride(static_cast(subject)); + Ride* ride = get_ride(static_cast(subject)); if (ride == nullptr || ride->overall_view.IsNull()) { break; diff --git a/src/openrct2/network/NetworkTypes.h b/src/openrct2/network/NetworkTypes.h index c173fbfb16..71c81beeb6 100644 --- a/src/openrct2/network/NetworkTypes.h +++ b/src/openrct2/network/NetworkTypes.h @@ -126,7 +126,7 @@ template struct NetworkObjectId_t }; #pragma pack(pop) -using NetworkRideId_t = ride_id_t; +using NetworkRideId_t = RideId; // NOTE: When adding new types make sure to have no duplicate _TypeID's otherwise // there is no way to specialize templates if they have the exact symbol. diff --git a/src/openrct2/park/ParkFile.cpp b/src/openrct2/park/ParkFile.cpp index ca1840f6d3..be6fbf246f 100644 --- a/src/openrct2/park/ParkFile.cpp +++ b/src/openrct2/park/ParkFile.cpp @@ -1051,7 +1051,7 @@ namespace OpenRCT2 { const auto version = os.GetHeader().TargetVersion; os.ReadWriteChunk(ParkFileChunkType::RIDES, [this, &version](OrcaStream::ChunkStream& cs) { - std::vector rideIds; + std::vector rideIds; if (cs.GetMode() == OrcaStream::Mode::READING) { ride_init_all(); @@ -1078,7 +1078,7 @@ namespace OpenRCT2 } } } - cs.ReadWriteVector(rideIds, [&cs, &version](ride_id_t& rideId) { + cs.ReadWriteVector(rideIds, [&cs, &version](RideId& rideId) { // Ride ID cs.ReadWrite(rideId); @@ -1356,14 +1356,14 @@ namespace OpenRCT2 } return ridesTypesBeenOn; } - static std::vector LegacyGetRidesBeenOn(const std::array& srcArray) + static std::vector LegacyGetRidesBeenOn(const std::array& srcArray) { - std::vector ridesBeenOn; + std::vector ridesBeenOn; for (uint16_t i = 0; i < RCT2::Limits::MaxRidesInPark; i++) { if (srcArray[i / 8] & (1 << (i % 8))) { - ridesBeenOn.push_back(static_cast(i)); + ridesBeenOn.push_back(static_cast(i)); } } return ridesBeenOn; @@ -1516,9 +1516,9 @@ namespace OpenRCT2 return true; }); cs.Ignore(); - cs.Ignore(); - cs.Ignore(); - cs.Ignore(); + cs.Ignore(); + cs.Ignore(); + cs.Ignore(); } } @@ -1610,7 +1610,7 @@ namespace OpenRCT2 cs.Ignore(); cs.ReadWrite(staff->HireDate); cs.Ignore(); - cs.Ignore(); + cs.Ignore(); cs.Ignore(); std::vector temp; @@ -1636,9 +1636,9 @@ namespace OpenRCT2 } else { - cs.Ignore(); + cs.Ignore(); cs.ReadWrite(staff->StaffOrders); - cs.Ignore(); + cs.Ignore(); } } @@ -1697,7 +1697,7 @@ namespace OpenRCT2 cs.Ignore(); cs.Ignore(); cs.Ignore(); - cs.Ignore(); + cs.Ignore(); cs.Ignore(); cs.Ignore(); cs.Ignore(); @@ -1705,7 +1705,7 @@ namespace OpenRCT2 cs.Ignore(); cs.Ignore(); cs.Ignore(); - cs.Ignore(); + cs.Ignore(); cs.Ignore(); } } @@ -1895,8 +1895,8 @@ namespace OpenRCT2 { if (cs.GetMode() == OrcaStream::Mode::READING) { - std::vector rideUse; - cs.ReadWriteVector(rideUse, [&cs](ride_id_t& rideId) { cs.ReadWrite(rideId); }); + std::vector rideUse; + cs.ReadWriteVector(rideUse, [&cs](RideId& rideId) { cs.ReadWrite(rideId); }); OpenRCT2::RideUse::GetHistory().Set(guest.sprite_index, std::move(rideUse)); std::vector rideTypeUse; cs.ReadWriteVector(rideTypeUse, [&cs](ObjectEntryIndex& rideType) { cs.ReadWrite(rideType); }); @@ -1907,12 +1907,12 @@ namespace OpenRCT2 auto* rideUse = OpenRCT2::RideUse::GetHistory().GetAll(guest.sprite_index); if (rideUse == nullptr) { - std::vector empty; - cs.ReadWriteVector(empty, [&cs](ride_id_t& rideId) { cs.ReadWrite(rideId); }); + std::vector empty; + cs.ReadWriteVector(empty, [&cs](RideId& rideId) { cs.ReadWrite(rideId); }); } else { - cs.ReadWriteVector(*rideUse, [&cs](ride_id_t& rideId) { cs.ReadWrite(rideId); }); + cs.ReadWriteVector(*rideUse, [&cs](RideId& rideId) { cs.ReadWrite(rideId); }); } auto* rideTypeUse = OpenRCT2::RideUse::GetTypeHistory().GetAll(guest.sprite_index); if (rideTypeUse == nullptr) diff --git a/src/openrct2/peep/GuestPathfinding.cpp b/src/openrct2/peep/GuestPathfinding.cpp index 782988c029..784e0cf8fa 100644 --- a/src/openrct2/peep/GuestPathfinding.cpp +++ b/src/openrct2/peep/GuestPathfinding.cpp @@ -34,7 +34,7 @@ static uint8_t _peepPathFindFewestNumSteps; TileCoordsXYZ gPeepPathFindGoalPosition; bool gPeepPathFindIgnoreForeignQueues; -ride_id_t gPeepPathFindQueueRideIndex; +RideId gPeepPathFindQueueRideIndex; #if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 // Use to guard calls to log messages @@ -322,7 +322,7 @@ static uint8_t footpath_element_next_in_direction(TileCoordsXYZ loc, PathElement * This is the recursive portion of footpath_element_destination_in_direction(). */ static uint8_t footpath_element_dest_in_dir( - TileCoordsXYZ loc, Direction chosenDirection, ride_id_t* outRideIndex, int32_t level) + TileCoordsXYZ loc, Direction chosenDirection, RideId* outRideIndex, int32_t level) { TileElement* tileElement; Direction direction; @@ -347,7 +347,7 @@ static uint8_t footpath_element_dest_in_dir( { if (loc.z != tileElement->base_height) continue; - ride_id_t rideIndex = tileElement->AsTrack()->GetRideIndex(); + RideId rideIndex = tileElement->AsTrack()->GetRideIndex(); auto ride = get_ride(rideIndex); if (ride != nullptr && ride->GetRideTypeDescriptor().HasFlag(RIDE_TYPE_FLAG_IS_SHOP)) { @@ -444,7 +444,7 @@ static uint8_t footpath_element_dest_in_dir( * width path, for example that leads from a ride exit back to the main path. */ static uint8_t footpath_element_destination_in_direction( - TileCoordsXYZ loc, PathElement* pathElement, Direction chosenDirection, ride_id_t* outRideIndex) + TileCoordsXYZ loc, PathElement* pathElement, Direction chosenDirection, RideId* outRideIndex) { if (pathElement->IsSloped()) { @@ -756,7 +756,7 @@ static void peep_pathfind_heuristic_search( if (tileElement->IsGhost()) continue; - ride_id_t rideIndex = RIDE_ID_NULL; + RideId rideIndex = RIDE_ID_NULL; switch (tileElement->GetType()) { case TileElementType::Track: @@ -2096,7 +2096,7 @@ int32_t guest_path_finding(Guest* peep) if (!(adjustedEdges & (1 << chosenDirection))) continue; - ride_id_t rideIndex = RIDE_ID_NULL; + RideId rideIndex = RIDE_ID_NULL; auto pathSearchResult = footpath_element_destination_in_direction(loc, pathElement, chosenDirection, &rideIndex); switch (pathSearchResult) { @@ -2156,7 +2156,7 @@ int32_t guest_path_finding(Guest* peep) } // Peep is heading for a ride. - ride_id_t rideIndex = peep->GuestHeadingToRideId; + RideId rideIndex = peep->GuestHeadingToRideId; auto ride = get_ride(rideIndex); if (ride == nullptr || ride->status != RideStatus::Open) { diff --git a/src/openrct2/peep/GuestPathfinding.h b/src/openrct2/peep/GuestPathfinding.h index 7804e2de60..5c7fde32b4 100644 --- a/src/openrct2/peep/GuestPathfinding.h +++ b/src/openrct2/peep/GuestPathfinding.h @@ -27,7 +27,7 @@ extern TileCoordsXYZ gPeepPathFindGoalPosition; // When the heuristic pathfinder is examining neighboring tiles, one possibility is that it finds a // queue tile; furthermore, this queue tile may or may not be for the ride that the peep is trying // to get to, if any. This first var is used to store the ride that the peep is currently headed to. -extern ride_id_t gPeepPathFindQueueRideIndex; +extern RideId gPeepPathFindQueueRideIndex; // Furthermore, staff members don't care about this stuff; even if they are e.g. a mechanic headed // to a particular ride, they have no issues with walking over queues for other rides to get there. diff --git a/src/openrct2/peep/RideUseSystem.h b/src/openrct2/peep/RideUseSystem.h index bc1971ef00..822f2d136c 100644 --- a/src/openrct2/peep/RideUseSystem.h +++ b/src/openrct2/peep/RideUseSystem.h @@ -13,7 +13,7 @@ namespace OpenRCT2::RideUse { - using RideHistory = GroupVector; + using RideHistory = GroupVector; using RideTypeHistory = GroupVector; RideHistory& GetHistory(); diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 77eee6211f..66139b6c6a 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -775,13 +775,13 @@ namespace RCT1 { if (_s4.rides[i].type != RideType::Null) { - const auto rideId = static_cast(i); + const auto rideId = static_cast(i); ImportRide(GetOrAllocateRide(rideId), &_s4.rides[i], rideId); } } } - void ImportRide(::Ride* dst, RCT1::Ride* src, ride_id_t rideIndex) + void ImportRide(::Ride* dst, RCT1::Ride* src, RideId rideIndex) { *dst = {}; dst->id = rideIndex; @@ -2518,7 +2518,7 @@ namespace RCT1 { if (_s4.scenario_slot_index == SC_URBAN_PARK && _isScenario) { - const auto merryGoRoundId = static_cast(0); + const auto merryGoRoundId = static_cast(0); // First, make the queuing peep exit for (auto peep : EntityList()) @@ -2588,7 +2588,7 @@ namespace RCT1 continue; } - ride_id_t rideIndex = tileElement->AsTrack()->GetRideIndex(); + RideId rideIndex = tileElement->AsTrack()->GetRideIndex(); auto ride = get_ride(rideIndex); if (ride != nullptr) { @@ -2704,13 +2704,13 @@ namespace RCT1 { auto* dst = CreateEntityAt<::Vehicle>(srcBase.sprite_index); auto* src = static_cast(&srcBase); - const auto* ride = get_ride(static_cast(src->ride)); + const auto* ride = get_ride(static_cast(src->ride)); if (ride == nullptr) return; uint8_t vehicleEntryIndex = RCT1::GetVehicleSubEntryIndex(src->vehicle_type); - dst->ride = static_cast(src->ride); + dst->ride = static_cast(src->ride); dst->ride_subtype = RCTEntryIndexToOpenRCT2EntryIndex(ride->subtype); dst->vehicle_type = vehicleEntryIndex; diff --git a/src/openrct2/rct12/RCT12.cpp b/src/openrct2/rct12/RCT12.cpp index d3d4bc2aaf..73e83ce140 100644 --- a/src/openrct2/rct12/RCT12.cpp +++ b/src/openrct2/rct12/RCT12.cpp @@ -487,12 +487,12 @@ ObjectEntryIndex RCTEntryIndexToOpenRCT2EntryIndex(const RCT12ObjectEntryIndex i return index; } -ride_id_t RCT12RideIdToOpenRCT2RideId(const RCT12RideId rideId) +RideId RCT12RideIdToOpenRCT2RideId(const RCT12RideId rideId) { if (rideId == RCT12_RIDE_ID_NULL) return RIDE_ID_NULL; - return static_cast(rideId); + return static_cast(rideId); } static bool RCT12IsFormatChar(codepoint_t c) diff --git a/src/openrct2/rct12/RCT12.h b/src/openrct2/rct12/RCT12.h index e9e0320d6e..ce7e833e10 100644 --- a/src/openrct2/rct12/RCT12.h +++ b/src/openrct2/rct12/RCT12.h @@ -847,7 +847,7 @@ assert_struct_size(RCT12ResearchItem, 5); #pragma pack(pop) ObjectEntryIndex RCTEntryIndexToOpenRCT2EntryIndex(const RCT12ObjectEntryIndex index); -ride_id_t RCT12RideIdToOpenRCT2RideId(const RCT12RideId rideId); +RideId RCT12RideIdToOpenRCT2RideId(const RCT12RideId rideId); bool IsLikelyUTF8(std::string_view s); std::string RCT12RemoveFormattingUTF8(std::string_view s); std::string ConvertFormattedStringToOpenRCT2(std::string_view buffer); @@ -874,14 +874,14 @@ template std::vector RCT12GetRideTypesBeenOn(T* srcPeep) } return ridesTypesBeenOn; } -template std::vector RCT12GetRidesBeenOn(T* srcPeep) +template std::vector RCT12GetRidesBeenOn(T* srcPeep) { - std::vector ridesBeenOn; + std::vector ridesBeenOn; for (uint16_t i = 0; i < RCT12::Limits::MaxRidesInPark; i++) { if (srcPeep->rides_been_on[i / 8] & (1 << (i % 8))) { - ridesBeenOn.push_back(static_cast(i)); + ridesBeenOn.push_back(static_cast(i)); } } return ridesBeenOn; diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index 5e8d597f58..71d1505b10 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -566,7 +566,7 @@ namespace RCT2 auto src = &_s6.rides[index]; if (src->type != RIDE_TYPE_NULL) { - const auto rideId = static_cast(index); + const auto rideId = static_cast(index); auto dst = GetOrAllocateRide(rideId); ImportRide(dst, src, rideId); } @@ -621,7 +621,7 @@ namespace RCT2 return _isFlatRide[rct12RideIndex]; } - void ImportRide(::Ride* dst, const RCT2::Ride* src, const ride_id_t rideIndex) + void ImportRide(::Ride* dst, const RCT2::Ride* src, const RideId rideIndex) { *dst = {}; dst->id = rideIndex; @@ -960,7 +960,7 @@ namespace RCT2 { if (src.ride_index != RCT12_RIDE_ID_NULL) { - const auto rideId = static_cast(src.ride_index); + const auto rideId = static_cast(src.ride_index); auto ride = get_ride(rideId); if (ride != nullptr) { @@ -1090,7 +1090,7 @@ namespace RCT2 } } - void ImportNumRiders(::Ride* dst, const ride_id_t rideIndex) + void ImportNumRiders(::Ride* dst, const RideId rideIndex) { // The number of riders might have overflown or underflown. Re-calculate the value. uint16_t numRiders = 0; @@ -1795,7 +1795,7 @@ namespace RCT2 dst->remaining_distance = src->remaining_distance; dst->velocity = src->velocity; dst->acceleration = src->acceleration; - dst->ride = static_cast(src->ride); + dst->ride = static_cast(src->ride); dst->vehicle_type = src->vehicle_type; dst->colours = src->colours; dst->track_progress = src->track_progress; diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index d090dfa80b..40552d5205 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -135,7 +135,7 @@ RideManager::Iterator RideManager::end() return RideManager::Iterator(*this, _rides.size(), _rides.size()); } -ride_id_t GetNextFreeRideId() +RideId GetNextFreeRideId() { size_t result = _rides.size(); for (size_t i = 0; i < _rides.size(); i++) @@ -150,10 +150,10 @@ ride_id_t GetNextFreeRideId() { return RIDE_ID_NULL; } - return static_cast(result); + return static_cast(result); } -Ride* GetOrAllocateRide(ride_id_t index) +Ride* GetOrAllocateRide(RideId index) { const auto idx = static_cast(index); if (_rides.size() <= idx) @@ -166,7 +166,7 @@ Ride* GetOrAllocateRide(ride_id_t index) return result; } -Ride* get_ride(ride_id_t index) +Ride* get_ride(RideId index) { const auto idx = static_cast(index); if (idx < _rides.size()) @@ -2553,7 +2553,7 @@ static StationIndex ride_mode_check_station_present(Ride* ride) * * rct2: 0x006B5872 */ -static int32_t ride_check_for_entrance_exit(ride_id_t rideIndex) +static int32_t ride_check_for_entrance_exit(RideId rideIndex) { auto ride = get_ride(rideIndex); if (ride == nullptr) @@ -2642,7 +2642,7 @@ void Ride::ChainQueues() const */ static int32_t ride_check_block_brakes(CoordsXYE* input, CoordsXYE* output) { - ride_id_t rideIndex = input->element->AsTrack()->GetRideIndex(); + RideId rideIndex = input->element->AsTrack()->GetRideIndex(); rct_window* w = window_find_by_class(WC_RIDE_CONSTRUCTION); if (w != nullptr && _rideConstructionState != RideConstructionState::State0 && _currentRideIndex == rideIndex) ride_construction_invalidate_current_track(); @@ -2702,7 +2702,7 @@ static bool ride_check_track_contains_inversions(CoordsXYE* input, CoordsXYE* ou if (trackElement == nullptr) return false; - ride_id_t rideIndex = trackElement->GetRideIndex(); + RideId rideIndex = trackElement->GetRideIndex(); auto ride = get_ride(rideIndex); if (ride != nullptr && ride->type == RIDE_TYPE_MAZE) return true; @@ -2864,7 +2864,7 @@ static bool ride_check_start_and_end_is_station(CoordsXYE* input) { CoordsXYE trackBack, trackFront; - ride_id_t rideIndex = input->element->AsTrack()->GetRideIndex(); + RideId rideIndex = input->element->AsTrack()->GetRideIndex(); auto ride = get_ride(rideIndex); if (ride == nullptr) return false; @@ -3014,7 +3014,7 @@ static void RideOpenBlockBrakes(CoordsXYE* startElement) * * rct2: 0x006B4D26 */ -static void ride_set_start_finish_points(ride_id_t rideIndex, CoordsXYE* startElement) +static void ride_set_start_finish_points(RideId rideIndex, CoordsXYE* startElement) { auto ride = get_ride(rideIndex); if (ride == nullptr) @@ -3073,7 +3073,7 @@ static constexpr const CoordsXY word_9A2A60[] = { * rct2: 0x006DD90D */ static Vehicle* vehicle_create_car( - ride_id_t rideIndex, int32_t vehicleEntryIndex, int32_t carIndex, int32_t vehicleIndex, const CoordsXYZ& carPosition, + RideId rideIndex, int32_t vehicleEntryIndex, int32_t carIndex, int32_t vehicleIndex, const CoordsXYZ& carPosition, int32_t* remainingDistance, TrackElement* trackElement) { if (trackElement == nullptr) @@ -3277,7 +3277,7 @@ static Vehicle* vehicle_create_car( * rct2: 0x006DD84C */ static train_ref vehicle_create_train( - ride_id_t rideIndex, const CoordsXYZ& trainPos, int32_t vehicleIndex, int32_t* remainingDistance, + RideId rideIndex, const CoordsXYZ& trainPos, int32_t vehicleIndex, int32_t* remainingDistance, TrackElement* trackElement) { train_ref train = { nullptr, nullptr }; @@ -3309,7 +3309,7 @@ static train_ref vehicle_create_train( return train; } -static bool vehicle_create_trains(ride_id_t rideIndex, const CoordsXYZ& trainsPos, TrackElement* trackElement) +static bool vehicle_create_trains(RideId rideIndex, const CoordsXYZ& trainsPos, TrackElement* trackElement) { auto ride = get_ride(rideIndex); if (ride == nullptr) @@ -3684,7 +3684,7 @@ static bool ride_initialise_cable_lift_track(Ride* ride, bool isApplying) * * rct2: 0x006DF4D4 */ -static bool ride_create_cable_lift(ride_id_t rideIndex, bool isApplying) +static bool ride_create_cable_lift(RideId rideIndex, bool isApplying) { auto ride = get_ride(rideIndex); if (ride == nullptr) @@ -4200,7 +4200,7 @@ static bool ride_with_colour_config_exists(uint8_t ride_type, const TrackColour* return false; } -bool Ride::NameExists(std::string_view name, ride_id_t excludeRideId) +bool Ride::NameExists(std::string_view name, RideId excludeRideId) { char buffer[256]{}; for (auto& ride : GetRideManager()) @@ -4947,7 +4947,7 @@ static int32_t ride_get_track_length(Ride* ride) if (!foundTrack) return 0; - ride_id_t rideIndex = tileElement->AsTrack()->GetRideIndex(); + RideId rideIndex = tileElement->AsTrack()->GetRideIndex(); rct_window* w = window_find_by_class(WC_RIDE_CONSTRUCTION); if (w != nullptr && _rideConstructionState != RideConstructionState::State0 && _currentRideIndex == rideIndex) @@ -5790,7 +5790,7 @@ void Ride::UpdateRideTypeForAllPieces() } } -std::vector GetTracklessRides() +std::vector GetTracklessRides() { // Iterate map and build list of seen ride IDs std::vector seen; @@ -5813,7 +5813,7 @@ std::vector GetTracklessRides() // Get all rides that did not get seen during map iteration const auto& rideManager = GetRideManager(); - std::vector result; + std::vector result; for (const auto& ride : rideManager) { if (seen.size() <= static_cast(ride.id) || !seen[static_cast(ride.id)]) diff --git a/src/openrct2/ride/Ride.h b/src/openrct2/ride/Ride.h index 9a82bdcbac..a6aa349fb0 100644 --- a/src/openrct2/ride/Ride.h +++ b/src/openrct2/ride/Ride.h @@ -105,7 +105,7 @@ enum class RideStatus : uint8_t; */ struct Ride { - ride_id_t id = RIDE_ID_NULL; + RideId id = RIDE_ID_NULL; uint8_t type = RIDE_TYPE_NULL; // pointer to static info. for example, wild mouse type is 0x36, subtype is // 0x4c. @@ -343,7 +343,7 @@ public: void FormatStatusTo(Formatter&) const; static void UpdateAll(); - static bool NameExists(std::string_view name, ride_id_t excludeRideId = RIDE_ID_NULL); + static bool NameExists(std::string_view name, RideId excludeRideId = RIDE_ID_NULL); [[nodiscard]] std::unique_ptr SaveToTrackDesign(TrackDesignState& tds) const; @@ -868,16 +868,16 @@ enum constexpr uint32_t CONSTRUCTION_LIFT_HILL_SELECTED = 1 << 0; constexpr uint32_t CONSTRUCTION_INVERTED_TRACK_SELECTED = 1 << 1; -Ride* get_ride(ride_id_t index); +Ride* get_ride(RideId index); struct RideManager { - const Ride* operator[](ride_id_t id) const + const Ride* operator[](RideId id) const { return get_ride(id); } - Ride* operator[](ride_id_t id) + Ride* operator[](RideId id) { return get_ride(id); } @@ -904,7 +904,7 @@ struct RideManager , _index(beginIndex) , _endIndex(endIndex) { - if (_index < _endIndex && (*_rideManager)[static_cast(_index)] == nullptr) + if (_index < _endIndex && (*_rideManager)[static_cast(_index)] == nullptr) { ++(*this); } @@ -916,7 +916,7 @@ struct RideManager do { _index++; - } while (_index < _endIndex && (*_rideManager)[static_cast(_index)] == nullptr); + } while (_index < _endIndex && (*_rideManager)[static_cast(_index)] == nullptr); return *this; } Iterator operator++(int) @@ -935,7 +935,7 @@ struct RideManager } Ride& operator*() { - return *(*_rideManager)[static_cast(_index)]; + return *(*_rideManager)[static_cast(_index)]; } }; @@ -953,8 +953,8 @@ struct RideManager }; RideManager GetRideManager(); -ride_id_t GetNextFreeRideId(); -Ride* GetOrAllocateRide(ride_id_t index); +RideId GetNextFreeRideId(); +Ride* GetOrAllocateRide(RideId index); rct_ride_entry* get_ride_entry(ObjectEntryIndex index); std::string_view get_ride_entry_name(ObjectEntryIndex index); @@ -1034,8 +1034,8 @@ void ride_update_vehicle_colours(Ride* ride); uint64_t ride_entry_get_supported_track_pieces(const rct_ride_entry* rideEntry); enum class RideSetSetting : uint8_t; -money32 set_operating_setting(ride_id_t rideId, RideSetSetting setting, uint8_t value); -money32 set_operating_setting_nested(ride_id_t rideId, RideSetSetting setting, uint8_t value, uint8_t flags); +money32 set_operating_setting(RideId rideId, RideSetSetting setting, uint8_t value); +money32 set_operating_setting_nested(RideId rideId, RideSetSetting setting, uint8_t value, uint8_t flags); void UpdateGhostTrackAndArrow(); @@ -1070,6 +1070,6 @@ void ride_action_modify(Ride* ride, int32_t modifyType, int32_t flags); void determine_ride_entrance_and_exit_locations(); void ride_clear_leftover_entrances(Ride* ride); -std::vector GetTracklessRides(); +std::vector GetTracklessRides(); void ride_remove_vehicles(Ride* ride); diff --git a/src/openrct2/ride/RideAudio.cpp b/src/openrct2/ride/RideAudio.cpp index e98d04249c..fa2af9bb85 100644 --- a/src/openrct2/ride/RideAudio.cpp +++ b/src/openrct2/ride/RideAudio.cpp @@ -35,7 +35,7 @@ namespace OpenRCT2::RideAudio */ struct ViewportRideMusicInstance { - ride_id_t RideId; + RideId RideId; uint8_t TrackIndex{}; size_t Offset{}; @@ -49,7 +49,7 @@ namespace OpenRCT2::RideAudio */ struct RideMusicChannel { - ride_id_t RideId{}; + RideId RideId{}; uint8_t TrackIndex{}; size_t Offset{}; diff --git a/src/openrct2/ride/RideConstruction.cpp b/src/openrct2/ride/RideConstruction.cpp index bd7534ca90..59517e9e32 100644 --- a/src/openrct2/ride/RideConstruction.cpp +++ b/src/openrct2/ride/RideConstruction.cpp @@ -59,7 +59,7 @@ uint16_t _numCurrentPossibleSpecialTrackPieces; uint32_t _currentTrackCurve; RideConstructionState _rideConstructionState; -ride_id_t _currentRideIndex; +RideId _currentRideIndex; CoordsXYZ _currentTrackBegin; @@ -86,7 +86,7 @@ CoordsXYZD _unkF440C5; ObjectEntryIndex gLastEntranceStyle; uint8_t gRideEntranceExitPlaceType; -ride_id_t gRideEntranceExitPlaceRideIndex; +RideId gRideEntranceExitPlaceRideIndex; StationIndex gRideEntranceExitPlaceStationIndex; RideConstructionState gRideEntranceExitPlacePreviousRideConstructionState; Direction gRideEntranceExitPlaceDirection; @@ -122,7 +122,7 @@ static int32_t ride_check_if_construction_allowed(Ride* ride) return 1; } -static rct_window* ride_create_or_find_construction_window(ride_id_t rideIndex) +static rct_window* ride_create_or_find_construction_window(RideId rideIndex) { auto windowManager = GetContext()->GetUiContext()->GetWindowManager(); auto intent = Intent(INTENT_ACTION_RIDE_CONSTRUCTION_FOCUS); @@ -463,7 +463,7 @@ void ride_restore_provisional_track_piece() { if (_currentTrackSelectionFlags & TRACK_SELECTION_FLAG_TRACK) { - ride_id_t rideIndex; + RideId rideIndex; int32_t direction, type, liftHillAndAlternativeState; CoordsXYZ trackPos; if (window_ride_construction_update_state( @@ -1187,14 +1187,14 @@ int32_t ride_get_refund_price(const Ride* ride) return cost; } -money32 set_operating_setting(ride_id_t rideId, RideSetSetting setting, uint8_t value) +money32 set_operating_setting(RideId rideId, RideSetSetting setting, uint8_t value) { auto rideSetSetting = RideSetSettingAction(rideId, setting, value); auto res = GameActions::Execute(&rideSetSetting); return res.Error == GameActions::Status::Ok ? 0 : MONEY32_UNDEFINED; } -money32 set_operating_setting_nested(ride_id_t rideId, RideSetSetting setting, uint8_t value, uint8_t flags) +money32 set_operating_setting_nested(RideId rideId, RideSetSetting setting, uint8_t value, uint8_t flags) { auto rideSetSetting = RideSetSettingAction(rideId, setting, value); rideSetSetting.SetFlags(flags); diff --git a/src/openrct2/ride/RideConstruction.h b/src/openrct2/ride/RideConstruction.h index bba56f4d8a..b1baa5616c 100644 --- a/src/openrct2/ride/RideConstruction.h +++ b/src/openrct2/ride/RideConstruction.h @@ -17,7 +17,7 @@ #include using track_type_t = uint16_t; -enum class ride_id_t : uint16_t; +enum class RideId : uint16_t; struct TileElement; struct CoordsXYE; @@ -44,7 +44,7 @@ extern uint16_t _numCurrentPossibleSpecialTrackPieces; extern uint32_t _currentTrackCurve; extern RideConstructionState _rideConstructionState; -extern ride_id_t _currentRideIndex; +extern RideId _currentRideIndex; extern CoordsXYZ _currentTrackBegin; @@ -69,7 +69,7 @@ extern uint8_t _currentSeatRotationAngle; extern CoordsXYZD _unkF440C5; extern uint8_t gRideEntranceExitPlaceType; -extern ride_id_t gRideEntranceExitPlaceRideIndex; +extern RideId gRideEntranceExitPlaceRideIndex; extern StationIndex gRideEntranceExitPlaceStationIndex; extern RideConstructionState gRideEntranceExitPlacePreviousRideConstructionState; extern uint8_t gRideEntranceExitPlaceDirection; diff --git a/src/openrct2/ride/RideRatings.cpp b/src/openrct2/ride/RideRatings.cpp index 4d0925064c..a131c39397 100644 --- a/src/openrct2/ride/RideRatings.cpp +++ b/src/openrct2/ride/RideRatings.cpp @@ -160,10 +160,10 @@ static void ride_ratings_update_state(RideRatingUpdateState& state) */ static void ride_ratings_update_state_0(RideRatingUpdateState& state) { - ride_id_t currentRide = state.CurrentRide; + RideId currentRide = state.CurrentRide; - currentRide = static_cast(EnumValue(currentRide) + 1); - if (currentRide >= static_cast(OpenRCT2::Limits::MaxRidesInPark)) + currentRide = static_cast(EnumValue(currentRide) + 1); + if (currentRide >= static_cast(OpenRCT2::Limits::MaxRidesInPark)) { currentRide = {}; } @@ -200,7 +200,7 @@ static void ride_ratings_update_state_1(RideRatingUpdateState& state) */ static void ride_ratings_update_state_2(RideRatingUpdateState& state) { - const ride_id_t rideIndex = state.CurrentRide; + const RideId rideIndex = state.CurrentRide; auto ride = get_ride(rideIndex); if (ride == nullptr || ride->status == RideStatus::Closed || ride->type >= RIDE_TYPE_COUNT) { diff --git a/src/openrct2/ride/RideRatings.h b/src/openrct2/ride/RideRatings.h index 449c42daa8..a40a335138 100644 --- a/src/openrct2/ride/RideRatings.h +++ b/src/openrct2/ride/RideRatings.h @@ -43,7 +43,7 @@ struct RideRatingUpdateState { CoordsXYZ Proximity; CoordsXYZ ProximityStart; - ride_id_t CurrentRide; + RideId CurrentRide; uint8_t State; track_type_t ProximityTrackType; uint8_t ProximityBaseHeight; diff --git a/src/openrct2/ride/RideTypes.h b/src/openrct2/ride/RideTypes.h index b9747b58c8..433b380cfc 100644 --- a/src/openrct2/ride/RideTypes.h +++ b/src/openrct2/ride/RideTypes.h @@ -15,10 +15,10 @@ #include #include -enum class ride_id_t : uint16_t; +enum class RideId : uint16_t; struct Ride; -constexpr const ride_id_t RIDE_ID_NULL = static_cast(std::numeric_limits>::max()); +constexpr const RideId RIDE_ID_NULL = static_cast(std::numeric_limits>::max()); using ride_type_t = uint16_t; diff --git a/src/openrct2/ride/Track.cpp b/src/openrct2/ride/Track.cpp index 6f97faa432..a764f41934 100644 --- a/src/openrct2/ride/Track.cpp +++ b/src/openrct2/ride/Track.cpp @@ -70,7 +70,7 @@ int32_t track_is_connected_by_shape(TileElement* a, TileElement* b) return aBank == bBank && aAngle == bAngle; } -static TileElement* find_station_element(const CoordsXYZD& loc, ride_id_t rideIndex) +static TileElement* find_station_element(const CoordsXYZD& loc, RideId rideIndex) { TileElement* tileElement = map_get_first_element_at(loc); if (tileElement == nullptr) @@ -111,7 +111,7 @@ static void ride_remove_station(Ride* ride, const CoordsXYZ& location) * * rct2: 0x006C4D89 */ -bool track_add_station_element(CoordsXYZD loc, ride_id_t rideIndex, int32_t flags, bool fromTrackDesign) +bool track_add_station_element(CoordsXYZD loc, RideId rideIndex, int32_t flags, bool fromTrackDesign) { auto ride = get_ride(rideIndex); if (ride == nullptr) @@ -262,7 +262,7 @@ bool track_add_station_element(CoordsXYZD loc, ride_id_t rideIndex, int32_t flag * * rct2: 0x006C494B */ -bool track_remove_station_element(const CoordsXYZD& loc, ride_id_t rideIndex, int32_t flags) +bool track_remove_station_element(const CoordsXYZD& loc, RideId rideIndex, int32_t flags) { auto ride = get_ride(rideIndex); if (ride == nullptr) @@ -783,12 +783,12 @@ void TrackElement::SetDoorBState(uint8_t newState) ColourScheme |= ((newState << 5) & TRACK_ELEMENT_COLOUR_DOOR_B_MASK); } -ride_id_t TrackElement::GetRideIndex() const +RideId TrackElement::GetRideIndex() const { return RideIndex; } -void TrackElement::SetRideIndex(ride_id_t newRideIndex) +void TrackElement::SetRideIndex(RideId newRideIndex) { RideIndex = newRideIndex; } diff --git a/src/openrct2/ride/Track.h b/src/openrct2/ride/Track.h index 7b9e78a007..3ded1796ca 100644 --- a/src/openrct2/ride/Track.h +++ b/src/openrct2/ride/Track.h @@ -574,9 +574,9 @@ roll_type_t track_get_actual_bank(TileElement* tileElement, roll_type_t bank); roll_type_t track_get_actual_bank_2(int32_t rideType, bool isInverted, roll_type_t bank); roll_type_t track_get_actual_bank_3(bool useInvertedSprites, TileElement* tileElement); -bool track_add_station_element(CoordsXYZD loc, ride_id_t rideIndex, int32_t flags, bool fromTrackDesign); -bool track_remove_station_element(const CoordsXYZD& loc, ride_id_t rideIndex, int32_t flags); +bool track_add_station_element(CoordsXYZD loc, RideId rideIndex, int32_t flags, bool fromTrackDesign); +bool track_remove_station_element(const CoordsXYZD& loc, RideId rideIndex, int32_t flags); -money32 maze_set_track(const CoordsXYZD& coords, uint8_t flags, bool initialPlacement, ride_id_t rideIndex, uint8_t mode); +money32 maze_set_track(const CoordsXYZD& coords, uint8_t flags, bool initialPlacement, RideId rideIndex, uint8_t mode); bool TrackTypeHasSpeedSetting(track_type_t trackType); diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index 26fc5d6505..1ba3450037 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -1917,7 +1917,7 @@ int32_t TrackDesignGetZPlacement(TrackDesign* td6, Ride* ride, const CoordsXYZ& return TrackDesignGetZPlacement(tds, td6, ride, coords); } -static money32 TrackDesignCreateRide(int32_t type, int32_t subType, int32_t flags, ride_id_t* outRideIndex) +static money32 TrackDesignCreateRide(int32_t type, int32_t subType, int32_t flags, RideId* outRideIndex) { // Don't set colours as will be set correctly later. auto gameAction = RideCreateAction(type, subType, 0, 0, gLastEntranceStyle); @@ -1931,7 +1931,7 @@ static money32 TrackDesignCreateRide(int32_t type, int32_t subType, int32_t flag return MONEY32_UNDEFINED; } - *outRideIndex = res.GetData(); + *outRideIndex = res.GetData(); return res.Cost; } @@ -1950,7 +1950,7 @@ static bool TrackDesignPlacePreview(TrackDesignState& tds, TrackDesign* td6, mon auto& objManager = GetContext()->GetObjectManager(); auto entry_index = objManager.GetLoadedObjectEntryIndex(td6->vehicle_object); - ride_id_t rideIndex; + RideId rideIndex; uint8_t rideCreateFlags = GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND; if (TrackDesignCreateRide(td6->type, entry_index, rideCreateFlags, &rideIndex) == MONEY32_UNDEFINED) { diff --git a/src/openrct2/ride/TrackDesign.h b/src/openrct2/ride/TrackDesign.h index 8a40b6ec66..9dee4ce1bd 100644 --- a/src/openrct2/ride/TrackDesign.h +++ b/src/openrct2/ride/TrackDesign.h @@ -208,7 +208,7 @@ enum MAZE_ELEMENT_TYPE_EXIT = (1 << 7) }; -static constexpr ride_id_t PreviewRideId = static_cast(0); +static constexpr RideId PreviewRideId = static_cast(0); extern bool gTrackDesignSceneryToggle; @@ -216,7 +216,7 @@ extern bool _trackDesignDrawingPreview; extern bool _trackDesignPlaceStateSceneryUnavailable; extern bool gTrackDesignSaveMode; -extern ride_id_t gTrackDesignSaveRideIndex; +extern RideId gTrackDesignSaveRideIndex; [[nodiscard]] std::unique_ptr TrackDesignImport(const utf8* path); @@ -238,7 +238,7 @@ void TrackDesignDrawPreview(TrackDesign* td6, uint8_t* pixels); void track_design_save_init(); void track_design_save_reset_scenery(); bool track_design_save_contains_tile_element(const TileElement* tileElement); -void track_design_save_select_nearby_scenery(ride_id_t rideIndex); +void track_design_save_select_nearby_scenery(RideId rideIndex); void track_design_save_select_tile_element( ViewportInteractionItem interactionType, const CoordsXY& loc, TileElement* tileElement, bool collect); diff --git a/src/openrct2/ride/TrackDesignSave.cpp b/src/openrct2/ride/TrackDesignSave.cpp index 0b549c0179..7db6483723 100644 --- a/src/openrct2/ride/TrackDesignSave.cpp +++ b/src/openrct2/ride/TrackDesignSave.cpp @@ -41,7 +41,7 @@ constexpr size_t TRACK_MAX_SAVED_TILE_ELEMENTS = 1500; constexpr int32_t TRACK_NEARBY_SCENERY_DISTANCE = 1; bool gTrackDesignSaveMode = false; -ride_id_t gTrackDesignSaveRideIndex = RIDE_ID_NULL; +RideId gTrackDesignSaveRideIndex = RIDE_ID_NULL; std::vector _trackSavedTileElements; std::vector _trackSavedTileElementsDesc; @@ -62,8 +62,8 @@ struct TrackDesignAddStatus } }; -static bool track_design_save_should_select_scenery_around(ride_id_t rideIndex, TileElement* tileElement); -static void track_design_save_select_nearby_scenery_for_tile(ride_id_t rideIndex, int32_t cx, int32_t cy); +static bool track_design_save_should_select_scenery_around(RideId rideIndex, TileElement* tileElement); +static void track_design_save_select_nearby_scenery_for_tile(RideId rideIndex, int32_t cx, int32_t cy); static TrackDesignAddStatus track_design_save_add_tile_element( ViewportInteractionItem interactionType, const CoordsXY& loc, TileElement* tileElement); static void track_design_save_remove_tile_element( @@ -106,7 +106,7 @@ void track_design_save_select_tile_element( * * rct2: 0x006D303D */ -void track_design_save_select_nearby_scenery(ride_id_t rideIndex) +void track_design_save_select_nearby_scenery(RideId rideIndex) { tile_element_iterator it; tile_element_iterator_begin(&it); @@ -583,7 +583,7 @@ static void track_design_save_remove_tile_element( } } -static bool track_design_save_should_select_scenery_around(ride_id_t rideIndex, TileElement* tileElement) +static bool track_design_save_should_select_scenery_around(RideId rideIndex, TileElement* tileElement) { switch (tileElement->GetType()) { @@ -610,7 +610,7 @@ static bool track_design_save_should_select_scenery_around(ride_id_t rideIndex, return false; } -static void track_design_save_select_nearby_scenery_for_tile(ride_id_t rideIndex, int32_t cx, int32_t cy) +static void track_design_save_select_nearby_scenery_for_tile(RideId rideIndex, int32_t cx, int32_t cy) { TileElement* tileElement; diff --git a/src/openrct2/ride/TrackPaint.cpp b/src/openrct2/ride/TrackPaint.cpp index de0b89511f..6ae7b8fa35 100644 --- a/src/openrct2/ride/TrackPaint.cpp +++ b/src/openrct2/ride/TrackPaint.cpp @@ -2189,7 +2189,7 @@ void track_paint_util_left_corkscrew_up_supports(paint_session& session, Directi */ void PaintTrack(paint_session& session, Direction direction, int32_t height, const TrackElement& trackElement) { - ride_id_t rideIndex = trackElement.GetRideIndex(); + RideId rideIndex = trackElement.GetRideIndex(); auto ride = get_ride(rideIndex); if (ride == nullptr) { diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index 292329e67f..f4497570de 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -2577,7 +2577,7 @@ void Vehicle::UpdateWaitingToDepart() struct rct_synchronised_vehicle { - ride_id_t ride_id; + RideId ride_id; StationIndex stationIndex; uint16_t vehicle_id; }; @@ -2765,7 +2765,7 @@ static bool ride_station_can_depart_synchronised(const Ride& ride, StationIndex if (!(sv_ride->stations[sv->stationIndex].Depart & STATION_DEPART_FLAG)) { sv = _synchronisedVehicles; - ride_id_t rideId = RIDE_ID_NULL; + RideId rideId = RIDE_ID_NULL; for (; sv < _lastSynchronisedVehicle; sv++) { if (rideId == RIDE_ID_NULL) @@ -2811,7 +2811,7 @@ static bool ride_station_can_depart_synchronised(const Ride& ride, StationIndex // Sync condition: there are at least 3 stations to sync return false; } - ride_id_t someRideIndex = _synchronisedVehicles[0].ride_id; + RideId someRideIndex = _synchronisedVehicles[0].ride_id; if (someRideIndex != ride.id) { // Sync condition: the first station to sync is a different ride @@ -6397,7 +6397,7 @@ bool Vehicle::DodgemsCarWouldCollideAt(const CoordsXY& coords, uint16_t* collide auto location = coords; - ride_id_t rideIndex = ride; + RideId rideIndex = ride; for (auto xy_offset : SurroundingTiles) { location += xy_offset; diff --git a/src/openrct2/ride/Vehicle.h b/src/openrct2/ride/Vehicle.h index 3c436afcad..7977c65153 100644 --- a/src/openrct2/ride/Vehicle.h +++ b/src/openrct2/ride/Vehicle.h @@ -106,7 +106,7 @@ struct Vehicle : EntityBase int32_t remaining_distance; int32_t velocity; int32_t acceleration; - ride_id_t ride; + RideId ride; uint8_t vehicle_type; rct_vehicle_colour colours; union diff --git a/src/openrct2/scripting/ScriptEngine.cpp b/src/openrct2/scripting/ScriptEngine.cpp index ba39a9138e..b5f79f831f 100644 --- a/src/openrct2/scripting/ScriptEngine.cpp +++ b/src/openrct2/scripting/ScriptEngine.cpp @@ -891,7 +891,7 @@ DukValue ScriptEngine::GameActionResultToDuk(const GameAction& action, const Gam { if (result.Error == GameActions::Status::Ok) { - const auto rideIndex = result.GetData(); + const auto rideIndex = result.GetData(); obj.Set("ride", EnumValue(rideIndex)); } } diff --git a/src/openrct2/scripting/bindings/entity/ScVehicle.cpp b/src/openrct2/scripting/bindings/entity/ScVehicle.cpp index 2f4be2efcb..82cc5ea551 100644 --- a/src/openrct2/scripting/bindings/entity/ScVehicle.cpp +++ b/src/openrct2/scripting/bindings/entity/ScVehicle.cpp @@ -146,7 +146,7 @@ namespace OpenRCT2::Scripting auto vehicle = GetVehicle(); if (vehicle != nullptr) { - vehicle->ride = static_cast(value); + vehicle->ride = static_cast(value); } } diff --git a/src/openrct2/scripting/bindings/ride/ScRide.cpp b/src/openrct2/scripting/bindings/ride/ScRide.cpp index 6bdd07b4f7..b0f7b211a4 100644 --- a/src/openrct2/scripting/bindings/ride/ScRide.cpp +++ b/src/openrct2/scripting/bindings/ride/ScRide.cpp @@ -20,7 +20,7 @@ namespace OpenRCT2::Scripting { - ScRide::ScRide(ride_id_t rideId) + ScRide::ScRide(RideId rideId) : _rideId(rideId) { } diff --git a/src/openrct2/scripting/bindings/ride/ScRide.hpp b/src/openrct2/scripting/bindings/ride/ScRide.hpp index 0ee26d3d46..cc2c5e10b9 100644 --- a/src/openrct2/scripting/bindings/ride/ScRide.hpp +++ b/src/openrct2/scripting/bindings/ride/ScRide.hpp @@ -60,10 +60,10 @@ namespace OpenRCT2::Scripting class ScRide { private: - ride_id_t _rideId = RIDE_ID_NULL; + RideId _rideId = RIDE_ID_NULL; public: - ScRide(ride_id_t rideId); + ScRide(RideId rideId); private: int32_t id_get() const; diff --git a/src/openrct2/scripting/bindings/ride/ScRideStation.cpp b/src/openrct2/scripting/bindings/ride/ScRideStation.cpp index 1168d96060..5471c545b7 100644 --- a/src/openrct2/scripting/bindings/ride/ScRideStation.cpp +++ b/src/openrct2/scripting/bindings/ride/ScRideStation.cpp @@ -20,7 +20,7 @@ namespace OpenRCT2::Scripting { - ScRideStation::ScRideStation(ride_id_t rideId, StationIndex stationIndex) + ScRideStation::ScRideStation(RideId rideId, StationIndex stationIndex) : _rideId(rideId) , _stationIndex(stationIndex) { diff --git a/src/openrct2/scripting/bindings/ride/ScRideStation.hpp b/src/openrct2/scripting/bindings/ride/ScRideStation.hpp index 7b8c1804b9..c78ef5fe49 100644 --- a/src/openrct2/scripting/bindings/ride/ScRideStation.hpp +++ b/src/openrct2/scripting/bindings/ride/ScRideStation.hpp @@ -21,11 +21,11 @@ namespace OpenRCT2::Scripting class ScRideStation { private: - ride_id_t _rideId = RIDE_ID_NULL; + RideId _rideId = RIDE_ID_NULL; StationIndex _stationIndex{}; public: - ScRideStation(ride_id_t rideId, StationIndex stationIndex); + ScRideStation(RideId rideId, StationIndex stationIndex); static void Register(duk_context* ctx); diff --git a/src/openrct2/scripting/bindings/world/ScMap.cpp b/src/openrct2/scripting/bindings/world/ScMap.cpp index 2b16f0f0d8..3cb2c7f535 100644 --- a/src/openrct2/scripting/bindings/world/ScMap.cpp +++ b/src/openrct2/scripting/bindings/world/ScMap.cpp @@ -69,7 +69,7 @@ namespace OpenRCT2::Scripting std::shared_ptr ScMap::getRide(int32_t id) const { auto rideManager = GetRideManager(); - auto ride = rideManager[static_cast(id)]; + auto ride = rideManager[static_cast(id)]; if (ride != nullptr) { return std::make_shared(ride->id); diff --git a/src/openrct2/scripting/bindings/world/ScTileElement.cpp b/src/openrct2/scripting/bindings/world/ScTileElement.cpp index 5718f8e7eb..590c7bd3ad 100644 --- a/src/openrct2/scripting/bindings/world/ScTileElement.cpp +++ b/src/openrct2/scripting/bindings/world/ScTileElement.cpp @@ -488,7 +488,7 @@ namespace OpenRCT2::Scripting if (el->IsQueue()) { if (value.type() == DukValue::Type::NUMBER) - el->SetRideIndex(static_cast(value.as_uint())); + el->SetRideIndex(static_cast(value.as_uint())); else el->SetRideIndex(RIDE_ID_NULL); Invalidate(); @@ -500,7 +500,7 @@ namespace OpenRCT2::Scripting if (value.type() == DukValue::Type::NUMBER) { auto el = _element->AsTrack(); - el->SetRideIndex(static_cast(value.as_uint())); + el->SetRideIndex(static_cast(value.as_uint())); Invalidate(); } break; @@ -510,7 +510,7 @@ namespace OpenRCT2::Scripting if (value.type() == DukValue::Type::NUMBER) { auto el = _element->AsEntrance(); - el->SetRideIndex(static_cast(value.as_uint())); + el->SetRideIndex(static_cast(value.as_uint())); Invalidate(); } break; diff --git a/src/openrct2/windows/_legacy.cpp b/src/openrct2/windows/_legacy.cpp index 3b81ee6a2d..b77c16c0c0 100644 --- a/src/openrct2/windows/_legacy.cpp +++ b/src/openrct2/windows/_legacy.cpp @@ -44,7 +44,7 @@ bool _deferClose; * rct2: 0x006CA162 */ money32 place_provisional_track_piece( - ride_id_t rideIndex, int32_t trackType, int32_t trackDirection, int32_t liftHillAndAlternativeState, + RideId rideIndex, int32_t trackType, int32_t trackDirection, int32_t liftHillAndAlternativeState, const CoordsXYZ& trackPos) { auto ride = get_ride(rideIndex); @@ -238,10 +238,10 @@ static std::tuple window_ride_construction_update_state_get_ * @return (CF) */ bool window_ride_construction_update_state( - int32_t* _trackType, int32_t* _trackDirection, ride_id_t* _rideIndex, int32_t* _liftHillAndInvertedState, + int32_t* _trackType, int32_t* _trackDirection, RideId* _rideIndex, int32_t* _liftHillAndInvertedState, CoordsXYZ* _trackPos, int32_t* _properties) { - ride_id_t rideIndex; + RideId rideIndex; uint8_t trackDirection; uint16_t x, y, liftHillAndInvertedState, properties; diff --git a/src/openrct2/world/Banner.cpp b/src/openrct2/world/Banner.cpp index 2f5ebfd711..a848e3efc8 100644 --- a/src/openrct2/world/Banner.cpp +++ b/src/openrct2/world/Banner.cpp @@ -87,10 +87,10 @@ void Banner::FormatTextTo(Formatter& ft) const * * rct2: 0x006B7EAB */ -static ride_id_t banner_get_ride_index_at(const CoordsXYZ& bannerCoords) +static RideId banner_get_ride_index_at(const CoordsXYZ& bannerCoords) { TileElement* tileElement = map_get_first_element_at(bannerCoords); - ride_id_t resultRideIndex = RIDE_ID_NULL; + RideId resultRideIndex = RIDE_ID_NULL; if (tileElement == nullptr) return resultRideIndex; do @@ -98,7 +98,7 @@ static ride_id_t banner_get_ride_index_at(const CoordsXYZ& bannerCoords) if (tileElement->GetType() != TileElementType::Track) continue; - ride_id_t rideIndex = tileElement->AsTrack()->GetRideIndex(); + RideId rideIndex = tileElement->AsTrack()->GetRideIndex(); auto ride = get_ride(rideIndex); if (ride == nullptr || ride->GetRideTypeDescriptor().HasFlag(RIDE_TYPE_FLAG_IS_SHOP)) continue; @@ -193,7 +193,7 @@ WallElement* banner_get_scrolling_wall_tile_element(BannerIndex bannerIndex) * * rct2: 0x006B7D86 */ -ride_id_t banner_get_closest_ride_index(const CoordsXYZ& mapPos) +RideId banner_get_closest_ride_index(const CoordsXYZ& mapPos) { static constexpr const std::array NeighbourCheckOrder = { CoordsXY{ COORDS_XY_STEP, 0 }, @@ -209,7 +209,7 @@ ride_id_t banner_get_closest_ride_index(const CoordsXYZ& mapPos) for (const auto& neighhbourCoords : NeighbourCheckOrder) { - ride_id_t rideIndex = banner_get_ride_index_at({ CoordsXY{ mapPos } + neighhbourCoords, mapPos.z }); + RideId rideIndex = banner_get_ride_index_at({ CoordsXY{ mapPos } + neighhbourCoords, mapPos.z }); if (rideIndex != RIDE_ID_NULL) { return rideIndex; @@ -371,7 +371,7 @@ void UnlinkAllRideBanners() } } -void UnlinkAllBannersForRide(ride_id_t rideId) +void UnlinkAllBannersForRide(RideId rideId) { for (auto& banner : _banners) { diff --git a/src/openrct2/world/Banner.h b/src/openrct2/world/Banner.h index 4be4ddb115..35ac5a7839 100644 --- a/src/openrct2/world/Banner.h +++ b/src/openrct2/world/Banner.h @@ -32,7 +32,7 @@ struct Banner uint8_t flags{}; std::string text; uint8_t colour{}; - ride_id_t ride_index{}; + RideId ride_index{}; uint8_t text_colour{}; TileCoordsXY position; @@ -57,11 +57,11 @@ enum BANNER_FLAGS void banner_init(); TileElement* banner_get_tile_element(BannerIndex bannerIndex); WallElement* banner_get_scrolling_wall_tile_element(BannerIndex bannerIndex); -ride_id_t banner_get_closest_ride_index(const CoordsXYZ& mapPos); +RideId banner_get_closest_ride_index(const CoordsXYZ& mapPos); void banner_reset_broken_index(); void fix_duplicated_banners(); void UnlinkAllRideBanners(); -void UnlinkAllBannersForRide(ride_id_t rideId); +void UnlinkAllBannersForRide(RideId rideId); Banner* GetBanner(BannerIndex id); Banner* GetOrCreateBanner(BannerIndex id); Banner* CreateBanner(); diff --git a/src/openrct2/world/Entrance.cpp b/src/openrct2/world/Entrance.cpp index 3043a4aaf7..f35f60099a 100644 --- a/src/openrct2/world/Entrance.cpp +++ b/src/openrct2/world/Entrance.cpp @@ -40,7 +40,7 @@ CoordsXYZD gRideEntranceExitGhostPosition; StationIndex gRideEntranceExitGhostStationIndex; static money32 RideEntranceExitPlaceGhost( - ride_id_t rideIndex, const CoordsXY& entranceExitCoords, Direction direction, uint8_t placeType, StationIndex stationNum) + RideId rideIndex, const CoordsXY& entranceExitCoords, Direction direction, uint8_t placeType, StationIndex stationNum) { auto rideEntranceExitPlaceAction = RideEntranceExitPlaceAction( entranceExitCoords, direction, rideIndex, stationNum, placeType == ENTRANCE_TYPE_RIDE_EXIT); @@ -137,7 +137,7 @@ void maze_entrance_hedge_replacement(const CoordsXYE& entrance) int32_t direction = entrance.element->GetDirection(); auto hedgePos = entrance + CoordsDirectionDelta[direction]; int32_t z = entrance.element->GetBaseZ(); - ride_id_t rideIndex = entrance.element->AsEntrance()->GetRideIndex(); + RideId rideIndex = entrance.element->AsEntrance()->GetRideIndex(); auto tileElement = map_get_first_element_at(hedgePos); if (tileElement == nullptr) @@ -174,7 +174,7 @@ void maze_entrance_hedge_removal(const CoordsXYE& entrance) int32_t direction = entrance.element->GetDirection(); auto hedgePos = entrance + CoordsDirectionDelta[direction]; int32_t z = entrance.element->GetBaseZ(); - ride_id_t rideIndex = entrance.element->AsEntrance()->GetRideIndex(); + RideId rideIndex = entrance.element->AsEntrance()->GetRideIndex(); auto tileElement = map_get_first_element_at(hedgePos); if (tileElement == nullptr) @@ -255,12 +255,12 @@ void EntranceElement::SetEntranceType(uint8_t newType) entranceType = newType; } -ride_id_t EntranceElement::GetRideIndex() const +RideId EntranceElement::GetRideIndex() const { return rideIndex; } -void EntranceElement::SetRideIndex(ride_id_t newRideIndex) +void EntranceElement::SetRideIndex(RideId newRideIndex) { rideIndex = newRideIndex; } diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index 1eed7fddbd..cb5d37b485 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -51,8 +51,8 @@ CoordsXYZ gFootpathConstructFromPosition; uint8_t gFootpathConstructSlope; uint8_t gFootpathGroundFlags; -static ride_id_t* _footpathQueueChainNext; -static ride_id_t _footpathQueueChain[64]; +static RideId* _footpathQueueChainNext; +static RideId _footpathQueueChain[64]; // This is the coordinates that a user of the bin should move to // rct2: 0x00992A4C @@ -583,7 +583,7 @@ struct rct_neighbour { uint8_t order; uint8_t direction; - ride_id_t ride_index; + RideId ride_index; uint8_t entrance_index; }; @@ -617,7 +617,7 @@ static void neighbour_list_init(rct_neighbour_list* neighbourList) } static void neighbour_list_push( - rct_neighbour_list* neighbourList, int32_t order, int32_t direction, ride_id_t rideIndex, uint8_t entrance_index) + rct_neighbour_list* neighbourList, int32_t order, int32_t direction, RideId rideIndex, uint8_t entrance_index) { Guard::Assert(neighbourList->count < std::size(neighbourList->items)); neighbourList->items[neighbourList->count].order = order; @@ -1038,7 +1038,7 @@ void footpath_connect_edges(const CoordsXY& footpathPos, TileElement* tileElemen if (tileElement->GetType() == TileElementType::Path && tileElement->AsPath()->IsQueue()) { - ride_id_t rideIndex = RIDE_ID_NULL; + RideId rideIndex = RIDE_ID_NULL; uint8_t entranceIndex = 255; for (size_t i = 0; i < neighbourList.count; i++) { @@ -1081,7 +1081,7 @@ void footpath_connect_edges(const CoordsXY& footpathPos, TileElement* tileElemen * rct2: 0x006A742F */ void footpath_chain_ride_queue( - ride_id_t rideIndex, int32_t entranceIndex, const CoordsXY& initialFootpathPos, TileElement* const initialTileElement, + RideId rideIndex, int32_t entranceIndex, const CoordsXY& initialFootpathPos, TileElement* const initialTileElement, int32_t direction) { TileElement *lastPathElement, *lastQueuePathElement; @@ -1210,7 +1210,7 @@ void footpath_queue_chain_reset() * * rct2: 0x006A76E9 */ -void footpath_queue_chain_push(ride_id_t rideIndex) +void footpath_queue_chain_push(RideId rideIndex) { if (rideIndex != RIDE_ID_NULL) { @@ -1230,7 +1230,7 @@ void footpath_update_queue_chains() { for (auto* queueChainPtr = _footpathQueueChain; queueChainPtr < _footpathQueueChainNext; queueChainPtr++) { - ride_id_t rideIndex = *queueChainPtr; + RideId rideIndex = *queueChainPtr; auto ride = get_ride(rideIndex); if (ride == nullptr) continue; @@ -2379,12 +2379,12 @@ const FootpathRailingsObject* GetPathRailingsEntry(ObjectEntryIndex entryIndex) return static_cast(obj); } -ride_id_t PathElement::GetRideIndex() const +RideId PathElement::GetRideIndex() const { return rideIndex; } -void PathElement::SetRideIndex(ride_id_t newRideIndex) +void PathElement::SetRideIndex(RideId newRideIndex) { rideIndex = newRideIndex; } diff --git a/src/openrct2/world/Footpath.h b/src/openrct2/world/Footpath.h index ce058ec45b..834c2bed30 100644 --- a/src/openrct2/world/Footpath.h +++ b/src/openrct2/world/Footpath.h @@ -245,7 +245,7 @@ void footpath_connect_edges(const CoordsXY& footpathPos, TileElement* tileElemen void footpath_update_queue_chains(); bool fence_in_the_way(const CoordsXYRangedZ& fencePos, int32_t direction); void footpath_chain_ride_queue( - ride_id_t rideIndex, int32_t entranceIndex, const CoordsXY& footpathPos, TileElement* tileElement, int32_t direction); + RideId rideIndex, int32_t entranceIndex, const CoordsXY& footpathPos, TileElement* tileElement, int32_t direction); void footpath_update_path_wide_flags(const CoordsXY& footpathPos); bool footpath_is_blocked_by_vehicle(const TileCoordsXYZ& position); @@ -257,4 +257,4 @@ const FootpathSurfaceObject* GetPathSurfaceEntry(ObjectEntryIndex entryIndex); const FootpathRailingsObject* GetPathRailingsEntry(ObjectEntryIndex entryIndex); void footpath_queue_chain_reset(); -void footpath_queue_chain_push(ride_id_t rideIndex); +void footpath_queue_chain_push(RideId rideIndex); diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 1f1aaaa8e7..6cecb6ad27 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -2133,7 +2133,7 @@ TrackElement* map_get_track_element_at_of_type_seq(const CoordsXYZD& location, t * @param y y units, not tiles. * @param z Base height. */ -TileElement* map_get_track_element_at_of_type_from_ride(const CoordsXYZ& trackPos, track_type_t trackType, ride_id_t rideIndex) +TileElement* map_get_track_element_at_of_type_from_ride(const CoordsXYZ& trackPos, track_type_t trackType, RideId rideIndex) { TileElement* tileElement = map_get_first_element_at(trackPos); if (tileElement == nullptr) @@ -2162,7 +2162,7 @@ TileElement* map_get_track_element_at_of_type_from_ride(const CoordsXYZ& trackPo * @param y y units, not tiles. * @param z Base height. */ -TileElement* map_get_track_element_at_from_ride(const CoordsXYZ& trackPos, ride_id_t rideIndex) +TileElement* map_get_track_element_at_from_ride(const CoordsXYZ& trackPos, RideId rideIndex) { TileElement* tileElement = map_get_first_element_at(trackPos); if (tileElement == nullptr) @@ -2190,7 +2190,7 @@ TileElement* map_get_track_element_at_from_ride(const CoordsXYZ& trackPos, ride_ * @param z Base height. * @param direction The direction (0 - 3). */ -TileElement* map_get_track_element_at_with_direction_from_ride(const CoordsXYZD& trackPos, ride_id_t rideIndex) +TileElement* map_get_track_element_at_with_direction_from_ride(const CoordsXYZD& trackPos, RideId rideIndex) { TileElement* tileElement = map_get_first_element_at(trackPos); if (tileElement == nullptr) diff --git a/src/openrct2/world/Map.h b/src/openrct2/world/Map.h index 50ebadefb7..59491ba6f1 100644 --- a/src/openrct2/world/Map.h +++ b/src/openrct2/world/Map.h @@ -248,9 +248,9 @@ TileElement* map_get_track_element_at_of_type(const CoordsXYZ& trackPos, track_t TileElement* map_get_track_element_at_of_type_seq(const CoordsXYZ& trackPos, track_type_t trackType, int32_t sequence); TrackElement* map_get_track_element_at_of_type(const CoordsXYZD& location, track_type_t trackType); TrackElement* map_get_track_element_at_of_type_seq(const CoordsXYZD& location, track_type_t trackType, int32_t sequence); -TileElement* map_get_track_element_at_of_type_from_ride(const CoordsXYZ& trackPos, track_type_t trackType, ride_id_t rideIndex); -TileElement* map_get_track_element_at_from_ride(const CoordsXYZ& trackPos, ride_id_t rideIndex); -TileElement* map_get_track_element_at_with_direction_from_ride(const CoordsXYZD& trackPos, ride_id_t rideIndex); +TileElement* map_get_track_element_at_of_type_from_ride(const CoordsXYZ& trackPos, track_type_t trackType, RideId rideIndex); +TileElement* map_get_track_element_at_from_ride(const CoordsXYZ& trackPos, RideId rideIndex); +TileElement* map_get_track_element_at_with_direction_from_ride(const CoordsXYZD& trackPos, RideId rideIndex); bool map_is_location_at_edge(const CoordsXY& loc); diff --git a/src/openrct2/world/TileElement.cpp b/src/openrct2/world/TileElement.cpp index e76b22f0b5..7a83557e76 100644 --- a/src/openrct2/world/TileElement.cpp +++ b/src/openrct2/world/TileElement.cpp @@ -86,7 +86,7 @@ void TileElement::RemoveBannerEntry() } } -ride_id_t TileElement::GetRideIndex() const +RideId TileElement::GetRideIndex() const { switch (GetType()) { diff --git a/src/openrct2/world/TileElement.h b/src/openrct2/world/TileElement.h index 92fc42d18a..57b72a4284 100644 --- a/src/openrct2/world/TileElement.h +++ b/src/openrct2/world/TileElement.h @@ -176,7 +176,7 @@ struct TileElement : public TileElementBase void ClearAs(TileElementType newType); - ride_id_t GetRideIndex() const; + RideId GetRideIndex() const; void SetBannerIndex(BannerIndex newIndex); void RemoveBannerEntry(); @@ -245,7 +245,7 @@ private: union { uint8_t AdditionStatus; // 13, only used for litter bins - ride_id_t rideIndex; // 13 + RideId rideIndex; // 13 }; ::StationIndex StationIndex; // 15 @@ -275,8 +275,8 @@ public: Direction GetSlopeDirection() const; void SetSlopeDirection(Direction newSlope); - ride_id_t GetRideIndex() const; - void SetRideIndex(ride_id_t newRideIndex); + RideId GetRideIndex() const; + void SetRideIndex(RideId newRideIndex); ::StationIndex GetStationIndex() const; void SetStationIndex(::StationIndex newStationIndex); @@ -350,7 +350,7 @@ private: }; }; uint8_t Flags2; - ride_id_t RideIndex; + RideId RideIndex; ride_type_t RideType; public: @@ -363,8 +363,8 @@ public: uint8_t GetSequenceIndex() const; void SetSequenceIndex(uint8_t newSequenceIndex); - ride_id_t GetRideIndex() const; - void SetRideIndex(ride_id_t newRideIndex); + RideId GetRideIndex() const; + void SetRideIndex(RideId newRideIndex); uint8_t GetColourScheme() const; void SetColourScheme(uint8_t newColourScheme); @@ -547,7 +547,7 @@ private: uint8_t SequenceIndex; // 6. Only uses the lower nibble. uint8_t StationIndex; // 7 ObjectEntryIndex PathType; // 8 - ride_id_t rideIndex; // A + RideId rideIndex; // A uint8_t flags2; // C #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-private-field" @@ -558,8 +558,8 @@ public: uint8_t GetEntranceType() const; void SetEntranceType(uint8_t newType); - ride_id_t GetRideIndex() const; - void SetRideIndex(ride_id_t newRideIndex); + RideId GetRideIndex() const; + void SetRideIndex(RideId newRideIndex); uint8_t GetStationIndex() const; void SetStationIndex(uint8_t newStationIndex); diff --git a/test/tests/Pathfinding.cpp b/test/tests/Pathfinding.cpp index 01d0a12bfd..d49face68e 100644 --- a/test/tests/Pathfinding.cpp +++ b/test/tests/Pathfinding.cpp @@ -64,7 +64,7 @@ protected: return nullptr; } - static bool FindPath(TileCoordsXYZ* pos, const TileCoordsXYZ& goal, int expectedSteps, ride_id_t targetRideID) + static bool FindPath(TileCoordsXYZ* pos, const TileCoordsXYZ& goal, int expectedSteps, RideId targetRideID) { // Our start position is in tile coordinates, but we need to give the peep spawn // position in actual world coords (32 units per tile X/Y, 8 per Z level). From 2c72940cfd10826cc6102e2c91ba414e8aea54b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Wed, 19 Jan 2022 15:39:43 +0200 Subject: [PATCH 2/9] Use TIdentifier for RideId --- src/openrct2/Identifiers.h | 2 ++ src/openrct2/ride/RideTypes.h | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/openrct2/Identifiers.h b/src/openrct2/Identifiers.h index aa008e87d9..53e5eb4c3b 100644 --- a/src/openrct2/Identifiers.h +++ b/src/openrct2/Identifiers.h @@ -17,3 +17,5 @@ using ParkEntranceIndex = TIdentifier::max(), struct ParkEntranceIndexTag>; using BannerIndex = TIdentifier::max(), struct BannerIndexTag>; + +using RideId = TIdentifier::max(), struct RideIdTag>; diff --git a/src/openrct2/ride/RideTypes.h b/src/openrct2/ride/RideTypes.h index 433b380cfc..582c661dfd 100644 --- a/src/openrct2/ride/RideTypes.h +++ b/src/openrct2/ride/RideTypes.h @@ -9,16 +9,16 @@ #pragma once +#include "../Identifiers.h" #include "../object/Object.h" #include #include #include -enum class RideId : uint16_t; struct Ride; -constexpr const RideId RIDE_ID_NULL = static_cast(std::numeric_limits>::max()); +constexpr auto RIDE_ID_NULL = RideId::GetNull(); using ride_type_t = uint16_t; From 0656df4a653ad74985220cd9fa2af1e461c62655 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Wed, 19 Jan 2022 16:54:04 +0200 Subject: [PATCH 3/9] Fix passing RideId to Formatter --- src/openrct2/localisation/Formatter.h | 32 +++++++++++++++------------ 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/openrct2/localisation/Formatter.h b/src/openrct2/localisation/Formatter.h index 1a9e35bcb5..bc67042eaf 100644 --- a/src/openrct2/localisation/Formatter.h +++ b/src/openrct2/localisation/Formatter.h @@ -9,6 +9,7 @@ #pragma once +#include "../Identifiers.h" #include "../common.h" #include "../core/Guard.hpp" #include "../core/String.hpp" @@ -17,7 +18,6 @@ #include extern thread_local uint8_t gCommonFormatArgs[80]; -enum class RideId : uint16_t; class Formatter { @@ -85,23 +85,27 @@ public: // clang-format off static_assert( - std::is_same_v::type, char*> || - std::is_same_v::type, const char*> || - std::is_same_v::type, int16_t> || - std::is_same_v::type, int32_t> || - std::is_same_v::type, money32> || - std::is_same_v::type, money64> || - std::is_same_v::type, RideId> || - std::is_same_v::type, rct_string_id> || - std::is_same_v::type, uint16_t> || - std::is_same_v::type, uint32_t> || - std::is_same_v::type, utf8*> || - std::is_same_v::type, const utf8*> + std::is_same_v, char*> || + std::is_same_v, const char*> || + std::is_same_v, int16_t> || + std::is_same_v, int32_t> || + std::is_same_v, money32> || + std::is_same_v, money64> || + std::is_same_v, RideId> || + std::is_same_v, rct_string_id> || + std::is_same_v, uint16_t> || + std::is_same_v, uint32_t> || + std::is_same_v, utf8*> || + std::is_same_v, const utf8*> ); // clang-format on uint64_t convertedValue; - if constexpr (std::is_integral_v || std::is_enum_v) + if constexpr (std::is_same_v, RideId>) + { + convertedValue = static_cast(value.ToUnderlying()); + } + else if constexpr (std::is_integral_v || std::is_enum_v) { convertedValue = static_cast(value); } From 4554d6d88371414f0bf972fe64ae624c3ecb9d77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Wed, 19 Jan 2022 16:54:57 +0200 Subject: [PATCH 4/9] Fix all uses of RideId --- src/openrct2-ui/WindowManager.cpp | 12 ++--- .../windows/EditorObjectiveOptions.cpp | 6 +-- src/openrct2-ui/windows/Guest.cpp | 4 +- src/openrct2-ui/windows/GuestList.cpp | 6 +-- src/openrct2-ui/windows/MazeConstruction.cpp | 2 +- src/openrct2-ui/windows/NewCampaign.cpp | 2 +- src/openrct2-ui/windows/Ride.cpp | 16 +++---- src/openrct2-ui/windows/RideConstruction.cpp | 4 +- src/openrct2-ui/windows/RideList.cpp | 2 +- src/openrct2-ui/windows/TrackDesignPlace.cpp | 2 +- src/openrct2/actions/ParkMarketingAction.cpp | 2 +- src/openrct2/actions/RideDemolishAction.cpp | 14 +++--- .../actions/RideEntranceExitPlaceAction.cpp | 4 +- .../actions/RideEntranceExitRemoveAction.cpp | 8 ++-- .../actions/RideSetAppearanceAction.cpp | 9 ++-- src/openrct2/actions/RideSetNameAction.cpp | 4 +- src/openrct2/actions/RideSetPriceAction.cpp | 10 ++-- src/openrct2/actions/RideSetSettingAction.cpp | 6 +-- src/openrct2/actions/RideSetStatusAction.cpp | 14 +++--- src/openrct2/actions/RideSetVehicleAction.cpp | 6 +-- src/openrct2/actions/TrackPlaceAction.cpp | 10 ++-- src/openrct2/entity/Guest.cpp | 20 ++++---- src/openrct2/interface/InteractiveConsole.cpp | 14 +++--- src/openrct2/management/NewsItem.cpp | 2 +- src/openrct2/park/ParkFile.cpp | 2 +- src/openrct2/rct1/S4Importer.cpp | 8 ++-- src/openrct2/rct12/RCT12.cpp | 2 +- src/openrct2/rct12/RCT12.h | 2 +- src/openrct2/rct2/S6Importer.cpp | 8 ++-- src/openrct2/ride/Ride.cpp | 47 ++++++++++--------- src/openrct2/ride/Ride.h | 14 +++--- src/openrct2/ride/RideConstruction.cpp | 4 +- src/openrct2/ride/RideConstruction.h | 2 +- src/openrct2/ride/RideRatings.cpp | 16 +++---- src/openrct2/ride/TrackDesign.h | 2 +- src/openrct2/ride/Vehicle.cpp | 10 ++-- src/openrct2/scripting/ScriptEngine.cpp | 2 +- .../scripting/bindings/entity/ScVehicle.cpp | 4 +- .../scripting/bindings/ride/ScRide.cpp | 2 +- .../scripting/bindings/world/ScMap.cpp | 2 +- .../bindings/world/ScTileElement.cpp | 12 ++--- 41 files changed, 159 insertions(+), 159 deletions(-) diff --git a/src/openrct2-ui/WindowManager.cpp b/src/openrct2-ui/WindowManager.cpp index 254767854d..5d3f4d978a 100644 --- a/src/openrct2-ui/WindowManager.cpp +++ b/src/openrct2-ui/WindowManager.cpp @@ -183,9 +183,9 @@ public: case WD_BANNER: return WindowBannerOpen(id); case WD_DEMOLISH_RIDE: - return WindowRideDemolishPromptOpen(get_ride(static_cast(id))); + return WindowRideDemolishPromptOpen(get_ride(RideId::FromUnderlying(id))); case WD_REFURBISH_RIDE: - return WindowRideRefurbishPromptOpen(get_ride(static_cast(id))); + return WindowRideRefurbishPromptOpen(get_ride(RideId::FromUnderlying(id))); case WD_NEW_CAMPAIGN: return WindowNewCampaignOpen(id); case WD_SIGN: @@ -263,7 +263,7 @@ public: } case WC_RIDE: { - const auto rideId = static_cast(intent->GetSIntExtra(INTENT_EXTRA_RIDE_ID)); + const auto rideId = RideId::FromUnderlying(intent->GetSIntExtra(INTENT_EXTRA_RIDE_ID)); auto ride = get_ride(rideId); return ride == nullptr ? nullptr : WindowRideMainOpen(ride); } @@ -365,13 +365,13 @@ public: if (w == nullptr || w->number != rideIndex) { window_close_construction_windows(); - _currentRideIndex = static_cast(rideIndex); + _currentRideIndex = RideId::FromUnderlying(rideIndex); OpenWindow(WC_RIDE_CONSTRUCTION); } else { ride_construction_invalidate_current_track(); - _currentRideIndex = static_cast(rideIndex); + _currentRideIndex = RideId::FromUnderlying(rideIndex); } break; } @@ -417,7 +417,7 @@ public: case INTENT_ACTION_INVALIDATE_VEHICLE_WINDOW: { auto vehicle = static_cast(intent.GetPointerExtra(INTENT_EXTRA_VEHICLE)); - auto w = window_find_by_number(WC_RIDE, EnumValue(vehicle->ride)); + auto* w = window_find_by_number(WC_RIDE, vehicle->ride.ToUnderlying()); if (w == nullptr) return; diff --git a/src/openrct2-ui/windows/EditorObjectiveOptions.cpp b/src/openrct2-ui/windows/EditorObjectiveOptions.cpp index 2f32668579..fc6990a260 100644 --- a/src/openrct2-ui/windows/EditorObjectiveOptions.cpp +++ b/src/openrct2-ui/windows/EditorObjectiveOptions.cpp @@ -973,7 +973,7 @@ static void WindowEditorObjectiveOptionsRidesUpdate(rct_window* w) { if (ride.IsRide()) { - w->list_item_positions[numItems] = EnumValue(ride.id); + w->list_item_positions[numItems] = ride.id.ToUnderlying(); numItems++; } } @@ -1006,7 +1006,7 @@ static void WindowEditorObjectiveOptionsRidesScrollmousedown( if (i < 0 || i >= w->no_list_items) return; - const auto rideId = static_cast(w->list_item_positions[i]); + const auto rideId = RideId::FromUnderlying(w->list_item_positions[i]); auto ride = get_ride(rideId); if (ride != nullptr) { @@ -1100,7 +1100,7 @@ static void WindowEditorObjectiveOptionsRidesScrollpaint(rct_window* w, rct_draw } // Checkbox mark - const auto rideId = static_cast(w->list_item_positions[i]); + const auto rideId = RideId::FromUnderlying(w->list_item_positions[i]); auto ride = get_ride(rideId); if (ride != nullptr) { diff --git a/src/openrct2-ui/windows/Guest.cpp b/src/openrct2-ui/windows/Guest.cpp index 7baa68b471..4e7fa4c518 100644 --- a/src/openrct2-ui/windows/Guest.cpp +++ b/src/openrct2-ui/windows/Guest.cpp @@ -1487,7 +1487,7 @@ void WindowGuestRidesUpdate(rct_window* w) { if (ride.IsRide() && guest->HasRidden(&ride)) { - w->list_item_positions[curr_list_position] = EnumValue(ride.id); + w->list_item_positions[curr_list_position] = ride.id.ToUnderlying(); curr_list_position++; } } @@ -1638,7 +1638,7 @@ void WindowGuestRidesScrollPaint(rct_window* w, rct_drawpixelinfo* dpi, int32_t stringId = STR_WINDOW_COLOUR_2_STRINGID; } - const auto rideId = static_cast(w->list_item_positions[list_index]); + const auto rideId = RideId::FromUnderlying(w->list_item_positions[list_index]); auto ride = get_ride(rideId); if (ride != nullptr) { diff --git a/src/openrct2-ui/windows/GuestList.cpp b/src/openrct2-ui/windows/GuestList.cpp index 0b458267f3..545912e2a1 100644 --- a/src/openrct2-ui/windows/GuestList.cpp +++ b/src/openrct2-ui/windows/GuestList.cpp @@ -185,7 +185,7 @@ public: { case GuestListFilterType::GuestsOnRide: { - auto guestRide = get_ride(static_cast(index)); + auto guestRide = get_ride(RideId::FromUnderlying(index)); if (guestRide != nullptr) { ft.Add( @@ -201,7 +201,7 @@ public: } case GuestListFilterType::GuestsInQueue: { - auto guestRide = get_ride(static_cast(index)); + auto guestRide = get_ride(RideId::FromUnderlying(index)); if (guestRide != nullptr) { ft.Add(STR_QUEUING_FOR); @@ -216,7 +216,7 @@ public: } case GuestListFilterType::GuestsThinkingAboutRide: { - auto guestRide = get_ride(static_cast(index)); + auto guestRide = get_ride(RideId::FromUnderlying(index)); if (guestRide != nullptr) { ft.Add(STR_NONE); diff --git a/src/openrct2-ui/windows/MazeConstruction.cpp b/src/openrct2-ui/windows/MazeConstruction.cpp index 51b1de3697..cc10083bf5 100644 --- a/src/openrct2-ui/windows/MazeConstruction.cpp +++ b/src/openrct2-ui/windows/MazeConstruction.cpp @@ -130,7 +130,7 @@ public: else { auto intent = Intent(WC_RIDE); - intent.putExtra(INTENT_EXTRA_RIDE_ID, EnumValue(currentRide->id)); + intent.putExtra(INTENT_EXTRA_RIDE_ID, currentRide->id.ToUnderlying()); context_open_intent(&intent); } } diff --git a/src/openrct2-ui/windows/NewCampaign.cpp b/src/openrct2-ui/windows/NewCampaign.cpp index 83942d2676..65cd068d94 100644 --- a/src/openrct2-ui/windows/NewCampaign.cpp +++ b/src/openrct2-ui/windows/NewCampaign.cpp @@ -259,7 +259,7 @@ public: case WIDX_START_BUTTON: { auto gameAction = ParkMarketingAction( - campaign.campaign_type, static_cast(campaign.RideId), campaign.no_weeks); + campaign.campaign_type, campaign.RideId.ToUnderlying(), campaign.no_weeks); gameAction.SetCallback([](const GameAction* ga, const GameActions::Result* result) { if (result->Error == GameActions::Status::Ok) { diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index be2efacdac..c4e99f1870 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -1195,7 +1195,7 @@ static void WindowRideUpdateOverallView(Ride* ride) max.z = std::max(max.z, clearZ); } - const auto rideIndex = EnumValue(ride->id); + const auto rideIndex = ride->id.ToUnderlying(); if (rideIndex >= ride_overall_views.size()) { ride_overall_views.resize(rideIndex + 1); @@ -1267,7 +1267,7 @@ rct_window* WindowRideMainOpen(Ride* ride) return nullptr; } - rct_window* w = window_bring_to_front_by_number(WC_RIDE, EnumValue(ride->id)); + rct_window* w = window_bring_to_front_by_number(WC_RIDE, ride->id.ToUnderlying()); if (w == nullptr) { w = WindowRideOpen(ride); @@ -1308,7 +1308,7 @@ static rct_window* WindowRideOpenStation(Ride* ride, StationIndex stationIndex) if (ride->GetRideTypeDescriptor().HasFlag(RIDE_TYPE_FLAG_NO_VEHICLES)) return WindowRideMainOpen(ride); - auto w = window_bring_to_front_by_number(WC_RIDE, EnumValue(ride->id)); + auto w = window_bring_to_front_by_number(WC_RIDE, ride->id.ToUnderlying()); if (w == nullptr) { w = WindowRideOpen(ride); @@ -1414,7 +1414,7 @@ rct_window* WindowRideOpenVehicle(Vehicle* vehicle) view++; } - rct_window* w = window_find_by_number(WC_RIDE, EnumValue(ride->id)); + rct_window* w = window_find_by_number(WC_RIDE, ride->id.ToUnderlying()); if (w != nullptr) { w->Invalidate(); @@ -1449,8 +1449,8 @@ rct_window* WindowRideOpenVehicle(Vehicle* vehicle) } } - w = openedPeepWindow ? window_find_by_number(WC_RIDE, EnumValue(ride->id)) - : window_bring_to_front_by_number(WC_RIDE, EnumValue(ride->id)); + w = openedPeepWindow ? window_find_by_number(WC_RIDE, ride->id.ToUnderlying()) + : window_bring_to_front_by_number(WC_RIDE, ride->id.ToUnderlying()); } if (w == nullptr) @@ -1559,7 +1559,7 @@ static void WindowRideAnchorBorderWidgets(rct_window* w) static std::optional GetStationIndexFromViewSelection(const rct_window& w) { - const auto* ride = get_ride(static_cast(w.number)); + const auto* ride = get_ride(RideId::FromUnderlying(w.number)); if (ride == nullptr) return std::nullopt; @@ -1727,7 +1727,7 @@ static void WindowRideMainMouseup(rct_window* w, rct_widgetindex widgetIndex) if (ride != nullptr) { ride_construct(ride); - if (window_find_by_number(WC_RIDE_CONSTRUCTION, EnumValue(ride->id)) != nullptr) + if (window_find_by_number(WC_RIDE_CONSTRUCTION, ride->id.ToUnderlying()) != nullptr) { window_close(w); } diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index f9a063299a..5b4f87263a 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -228,7 +228,7 @@ static int32_t RideGetAlternativeType(Ride* ride) /* move to ride.c */ static void CloseRideWindowForConstruction(RideId rideId) { - rct_window* w = window_find_by_number(WC_RIDE, EnumValue(rideId)); + rct_window* w = window_find_by_number(WC_RIDE, rideId.ToUnderlying()); if (w != nullptr && w->page == 1) window_close(w); } @@ -351,7 +351,7 @@ static void WindowRideConstructionClose(rct_window* w) ride->SetToDefaultInspectionInterval(); auto intent = Intent(WC_RIDE); - intent.putExtra(INTENT_EXTRA_RIDE_ID, EnumValue(ride->id)); + intent.putExtra(INTENT_EXTRA_RIDE_ID, ride->id.ToUnderlying()); context_open_intent(&intent); } else diff --git a/src/openrct2-ui/windows/RideList.cpp b/src/openrct2-ui/windows/RideList.cpp index 948684517e..a70e8ce9de 100644 --- a/src/openrct2-ui/windows/RideList.cpp +++ b/src/openrct2-ui/windows/RideList.cpp @@ -407,7 +407,7 @@ public: else { auto intent = Intent(WC_RIDE); - intent.putExtra(INTENT_EXTRA_RIDE_ID, EnumValue(rideIndex)); + intent.putExtra(INTENT_EXTRA_RIDE_ID, rideIndex.ToUnderlying()); context_open_intent(&intent); } } diff --git a/src/openrct2-ui/windows/TrackDesignPlace.cpp b/src/openrct2-ui/windows/TrackDesignPlace.cpp index a7c73439f9..1ec0ebf457 100644 --- a/src/openrct2-ui/windows/TrackDesignPlace.cpp +++ b/src/openrct2-ui/windows/TrackDesignPlace.cpp @@ -350,7 +350,7 @@ static void WindowTrackPlaceTooldown(rct_window* w, rct_widgetindex widgetIndex, if (track_design_are_entrance_and_exit_placed()) { auto intent = Intent(WC_RIDE); - intent.putExtra(INTENT_EXTRA_RIDE_ID, static_cast(rideId)); + intent.putExtra(INTENT_EXTRA_RIDE_ID, rideId.ToUnderlying()); context_open_intent(&intent); auto wnd = window_find_by_class(WC_TRACK_DESIGN_PLACE); window_close(wnd); diff --git a/src/openrct2/actions/ParkMarketingAction.cpp b/src/openrct2/actions/ParkMarketingAction.cpp index 57e81c936b..59dc0eec13 100644 --- a/src/openrct2/actions/ParkMarketingAction.cpp +++ b/src/openrct2/actions/ParkMarketingAction.cpp @@ -70,7 +70,7 @@ GameActions::Result ParkMarketingAction::Execute() const campaign.Flags = MarketingCampaignFlags::FIRST_WEEK; if (campaign.Type == ADVERTISING_CAMPAIGN_RIDE_FREE || campaign.Type == ADVERTISING_CAMPAIGN_RIDE) { - campaign.RideId = static_cast(_item); + campaign.RideId = RideId::FromUnderlying(_item); } else if (campaign.Type == ADVERTISING_CAMPAIGN_FOOD_OR_DRINK_FREE) { diff --git a/src/openrct2/actions/RideDemolishAction.cpp b/src/openrct2/actions/RideDemolishAction.cpp index f12cceae80..afe6f3186c 100644 --- a/src/openrct2/actions/RideDemolishAction.cpp +++ b/src/openrct2/actions/RideDemolishAction.cpp @@ -60,7 +60,7 @@ GameActions::Result RideDemolishAction::Query() const auto ride = get_ride(_rideIndex); if (ride == nullptr) { - log_warning("Invalid game command for ride %u", uint32_t(_rideIndex)); + log_warning("Invalid game command for ride %u", _rideIndex.ToUnderlying()); return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_DEMOLISH_RIDE, STR_NONE); } @@ -104,7 +104,7 @@ GameActions::Result RideDemolishAction::Execute() const auto ride = get_ride(_rideIndex); if (ride == nullptr) { - log_warning("Invalid game command for ride %u", uint32_t(_rideIndex)); + log_warning("Invalid game command for ride %u", _rideIndex.ToUnderlying()); return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_DEMOLISH_RIDE, STR_NONE); } @@ -131,7 +131,7 @@ GameActions::Result RideDemolishAction::DemolishRide(Ride* ride) const ride_clear_leftover_entrances(ride); const auto rideId = ride->id; - News::DisableNewsItems(News::ItemType::Ride, EnumValue(rideId)); + News::DisableNewsItems(News::ItemType::Ride, rideId.ToUnderlying()); UnlinkAllBannersForRide(ride->id); @@ -157,9 +157,9 @@ GameActions::Result RideDemolishAction::DemolishRide(Ride* ride) const gParkValue = GetContext()->GetGameState()->GetPark().CalculateParkValue(); // Close windows related to the demolished ride - window_close_by_number(WC_RIDE_CONSTRUCTION, EnumValue(rideId)); - window_close_by_number(WC_RIDE, EnumValue(rideId)); - window_close_by_number(WC_DEMOLISH_RIDE_PROMPT, EnumValue(rideId)); + window_close_by_number(WC_RIDE_CONSTRUCTION, rideId.ToUnderlying()); + window_close_by_number(WC_RIDE, rideId.ToUnderlying()); + window_close_by_number(WC_DEMOLISH_RIDE_PROMPT, rideId.ToUnderlying()); window_close_by_class(WC_NEW_CAMPAIGN); // Refresh windows that display the ride name @@ -277,7 +277,7 @@ GameActions::Result RideDemolishAction::RefurbishRide(Ride* ride) const res.Position = { location, tile_element_height(location) }; } - window_close_by_number(WC_DEMOLISH_RIDE_PROMPT, EnumValue(_rideIndex)); + window_close_by_number(WC_DEMOLISH_RIDE_PROMPT, _rideIndex.ToUnderlying()); return res; } diff --git a/src/openrct2/actions/RideEntranceExitPlaceAction.cpp b/src/openrct2/actions/RideEntranceExitPlaceAction.cpp index 7ac999eac9..6c5da7146b 100644 --- a/src/openrct2/actions/RideEntranceExitPlaceAction.cpp +++ b/src/openrct2/actions/RideEntranceExitPlaceAction.cpp @@ -55,7 +55,7 @@ GameActions::Result RideEntranceExitPlaceAction::Query() const auto ride = get_ride(_rideIndex); if (ride == nullptr) { - log_warning("Invalid game command for ride %d", EnumValue(_rideIndex)); + log_warning("Invalid game command for ride %u", _rideIndex.ToUnderlying()); return GameActions::Result(GameActions::Status::InvalidParameters, errorTitle, STR_NONE); } @@ -135,7 +135,7 @@ GameActions::Result RideEntranceExitPlaceAction::Execute() const auto ride = get_ride(_rideIndex); if (ride == nullptr) { - log_warning("Invalid game command for ride %d", EnumValue(_rideIndex)); + log_warning("Invalid game command for ride %u", _rideIndex.ToUnderlying()); return GameActions::Result(GameActions::Status::InvalidParameters, errorTitle, STR_NONE); } diff --git a/src/openrct2/actions/RideEntranceExitRemoveAction.cpp b/src/openrct2/actions/RideEntranceExitRemoveAction.cpp index 9ee4c52611..893c2ea545 100644 --- a/src/openrct2/actions/RideEntranceExitRemoveAction.cpp +++ b/src/openrct2/actions/RideEntranceExitRemoveAction.cpp @@ -74,7 +74,7 @@ GameActions::Result RideEntranceExitRemoveAction::Query() const auto ride = get_ride(_rideIndex); if (ride == nullptr) { - log_warning("Invalid ride id %d for entrance/exit removal", EnumValue(_rideIndex)); + log_warning("Invalid ride id %u for entrance/exit removal", _rideIndex.ToUnderlying()); return GameActions::Result(GameActions::Status::InvalidParameters, STR_NONE, STR_NONE); } @@ -99,7 +99,7 @@ GameActions::Result RideEntranceExitRemoveAction::Query() const if (entranceElement == nullptr) { log_warning( - "Track Element not found. x = %d, y = %d, ride = %d, station = %d", _loc.x, _loc.y, EnumValue(_rideIndex), + "Track Element not found. x = %d, y = %d, ride = %u, station = %d", _loc.x, _loc.y, _rideIndex.ToUnderlying(), _stationNum); return GameActions::Result(GameActions::Status::InvalidParameters, STR_NONE, STR_NONE); } @@ -112,7 +112,7 @@ GameActions::Result RideEntranceExitRemoveAction::Execute() const auto ride = get_ride(_rideIndex); if (ride == nullptr) { - log_warning("Invalid ride id %d for entrance/exit removal", EnumValue(_rideIndex)); + log_warning("Invalid ride id %u for entrance/exit removal", _rideIndex.ToUnderlying()); return GameActions::Result(GameActions::Status::InvalidParameters, STR_NONE, STR_NONE); } @@ -130,7 +130,7 @@ GameActions::Result RideEntranceExitRemoveAction::Execute() const if (entranceElement == nullptr) { log_warning( - "Track Element not found. x = %d, y = %d, ride = %d, station = %d", _loc.x, _loc.y, EnumValue(_rideIndex), + "Track Element not found. x = %d, y = %d, ride = %u, station = %d", _loc.x, _loc.y, _rideIndex.ToUnderlying(), _stationNum); return GameActions::Result(GameActions::Status::InvalidParameters, STR_NONE, STR_NONE); } diff --git a/src/openrct2/actions/RideSetAppearanceAction.cpp b/src/openrct2/actions/RideSetAppearanceAction.cpp index 862c6a0350..511484691f 100644 --- a/src/openrct2/actions/RideSetAppearanceAction.cpp +++ b/src/openrct2/actions/RideSetAppearanceAction.cpp @@ -21,8 +21,7 @@ #include "../ui/WindowManager.h" #include "../world/Park.h" -RideSetAppearanceAction::RideSetAppearanceAction( - RideId rideIndex, RideSetAppearanceType type, uint16_t value, uint32_t index) +RideSetAppearanceAction::RideSetAppearanceAction(RideId rideIndex, RideSetAppearanceType type, uint16_t value, uint32_t index) : _rideIndex(rideIndex) , _type(type) , _value(value) @@ -54,7 +53,7 @@ GameActions::Result RideSetAppearanceAction::Query() const auto ride = get_ride(_rideIndex); if (ride == nullptr) { - log_warning("Invalid game command, ride_id = %u", uint32_t(_rideIndex)); + log_warning("Invalid game command, ride_id = %u", _rideIndex.ToUnderlying()); return GameActions::Result(GameActions::Status::InvalidParameters, STR_NONE, STR_NONE); } @@ -94,7 +93,7 @@ GameActions::Result RideSetAppearanceAction::Execute() const auto ride = get_ride(_rideIndex); if (ride == nullptr) { - log_warning("Invalid game command, ride_id = %u", uint32_t(_rideIndex)); + log_warning("Invalid game command, ride_id = %u", _rideIndex.ToUnderlying()); return GameActions::Result(GameActions::Status::InvalidParameters, STR_NONE, STR_NONE); } @@ -138,7 +137,7 @@ GameActions::Result RideSetAppearanceAction::Execute() const gfx_invalidate_screen(); break; } - window_invalidate_by_number(WC_RIDE, EnumValue(_rideIndex)); + window_invalidate_by_number(WC_RIDE, _rideIndex.ToUnderlying()); auto res = GameActions::Result(); if (!ride->overall_view.IsNull()) diff --git a/src/openrct2/actions/RideSetNameAction.cpp b/src/openrct2/actions/RideSetNameAction.cpp index 7f4cb158f0..db9a25678e 100644 --- a/src/openrct2/actions/RideSetNameAction.cpp +++ b/src/openrct2/actions/RideSetNameAction.cpp @@ -50,7 +50,7 @@ GameActions::Result RideSetNameAction::Query() const auto ride = get_ride(_rideIndex); if (ride == nullptr) { - log_warning("Invalid game command for ride %u", uint32_t(_rideIndex)); + log_warning("Invalid game command for ride %u", _rideIndex.ToUnderlying()); return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_RENAME_RIDE_ATTRACTION, STR_NONE); } @@ -68,7 +68,7 @@ GameActions::Result RideSetNameAction::Execute() const auto ride = get_ride(_rideIndex); if (ride == nullptr) { - log_warning("Invalid game command for ride %u", uint32_t(_rideIndex)); + log_warning("Invalid game command for ride %u", _rideIndex.ToUnderlying()); return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_RENAME_RIDE_ATTRACTION, STR_NONE); } diff --git a/src/openrct2/actions/RideSetPriceAction.cpp b/src/openrct2/actions/RideSetPriceAction.cpp index 4bcf851c64..d51088e3c9 100644 --- a/src/openrct2/actions/RideSetPriceAction.cpp +++ b/src/openrct2/actions/RideSetPriceAction.cpp @@ -54,14 +54,14 @@ GameActions::Result RideSetPriceAction::Query() const auto ride = get_ride(_rideIndex); if (ride == nullptr) { - log_warning("Invalid game command, ride_id = %u", uint32_t(_rideIndex)); + log_warning("Invalid game command, ride_id = %u", _rideIndex.ToUnderlying()); return GameActions::Result(GameActions::Status::InvalidParameters, STR_NONE, STR_NONE); } rct_ride_entry* rideEntry = get_ride_entry(ride->subtype); if (rideEntry == nullptr) { - log_warning("Invalid game command for ride %u", uint32_t(_rideIndex)); + log_warning("Invalid game command for ride %u", _rideIndex.ToUnderlying()); return GameActions::Result(GameActions::Status::InvalidParameters, STR_NONE, STR_NONE); } @@ -76,14 +76,14 @@ GameActions::Result RideSetPriceAction::Execute() const auto ride = get_ride(_rideIndex); if (ride == nullptr) { - log_warning("Invalid game command, ride_id = %u", uint32_t(_rideIndex)); + log_warning("Invalid game command, ride_id = %u", _rideIndex.ToUnderlying()); return GameActions::Result(GameActions::Status::InvalidParameters, STR_NONE, STR_NONE); } rct_ride_entry* rideEntry = get_ride_entry(ride->subtype); if (rideEntry == nullptr) { - log_warning("Invalid game command for ride %u", uint32_t(_rideIndex)); + log_warning("Invalid game command for ride %u", _rideIndex.ToUnderlying()); return GameActions::Result(GameActions::Status::InvalidParameters, STR_NONE, STR_NONE); } @@ -180,7 +180,7 @@ void RideSetPriceAction::RideSetCommonPrice(ShopItem shopItem) const } if (invalidate) { - window_invalidate_by_number(WC_RIDE, EnumValue(ride.id)); + window_invalidate_by_number(WC_RIDE, ride.id.ToUnderlying()); } } } diff --git a/src/openrct2/actions/RideSetSettingAction.cpp b/src/openrct2/actions/RideSetSettingAction.cpp index fba3a41115..6d1c87b421 100644 --- a/src/openrct2/actions/RideSetSettingAction.cpp +++ b/src/openrct2/actions/RideSetSettingAction.cpp @@ -45,7 +45,7 @@ GameActions::Result RideSetSettingAction::Query() const auto ride = get_ride(_rideIndex); if (ride == nullptr) { - log_warning("Invalid ride: #%d.", EnumValue(_rideIndex)); + log_warning("Invalid ride: #%u.", _rideIndex.ToUnderlying()); return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_CHANGE_OPERATING_MODE, STR_NONE); } @@ -155,7 +155,7 @@ GameActions::Result RideSetSettingAction::Execute() const auto ride = get_ride(_rideIndex); if (ride == nullptr) { - log_warning("Invalid ride: #%d.", EnumValue(_rideIndex)); + log_warning("Invalid ride: #%u.", _rideIndex.ToUnderlying()); return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_CHANGE_OPERATING_MODE, STR_NONE); } @@ -236,7 +236,7 @@ GameActions::Result RideSetSettingAction::Execute() const auto location = ride->overall_view.ToTileCentre(); res.Position = { location, tile_element_height(location) }; } - window_invalidate_by_number(WC_RIDE, EnumValue(_rideIndex)); + window_invalidate_by_number(WC_RIDE, _rideIndex.ToUnderlying()); return res; } diff --git a/src/openrct2/actions/RideSetStatusAction.cpp b/src/openrct2/actions/RideSetStatusAction.cpp index a2bf6ab907..6892bba763 100644 --- a/src/openrct2/actions/RideSetStatusAction.cpp +++ b/src/openrct2/actions/RideSetStatusAction.cpp @@ -60,7 +60,7 @@ GameActions::Result RideSetStatusAction::Query() const auto ride = get_ride(_rideIndex); if (ride == nullptr) { - log_warning("Invalid game command for ride %u", EnumValue(_rideIndex)); + log_warning("Invalid game command for ride %u", _rideIndex.ToUnderlying()); res.Error = GameActions::Status::InvalidParameters; res.ErrorTitle = STR_RIDE_DESCRIPTION_UNKNOWN; res.ErrorMessage = STR_NONE; @@ -69,7 +69,7 @@ GameActions::Result RideSetStatusAction::Query() const if (_status >= RideStatus::Count) { - log_warning("Invalid ride status %u for ride %u", EnumValue(_status), EnumValue(_rideIndex)); + log_warning("Invalid ride status %u for ride %u", EnumValue(_status), _rideIndex.ToUnderlying()); res.Error = GameActions::Status::InvalidParameters; res.ErrorTitle = STR_RIDE_DESCRIPTION_UNKNOWN; res.ErrorMessage = STR_NONE; @@ -121,7 +121,7 @@ GameActions::Result RideSetStatusAction::Execute() const auto ride = get_ride(_rideIndex); if (ride == nullptr) { - log_warning("Invalid game command for ride %u", uint32_t(_rideIndex)); + log_warning("Invalid game command for ride %u", _rideIndex.ToUnderlying()); res.Error = GameActions::Status::InvalidParameters; res.ErrorTitle = STR_RIDE_DESCRIPTION_UNKNOWN; res.ErrorMessage = STR_NONE; @@ -156,7 +156,7 @@ GameActions::Result RideSetStatusAction::Execute() const ride->lifecycle_flags &= ~RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING; ride->race_winner = SPRITE_INDEX_NULL; ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_MAIN | RIDE_INVALIDATE_RIDE_LIST; - window_invalidate_by_number(WC_RIDE, EnumValue(_rideIndex)); + window_invalidate_by_number(WC_RIDE, _rideIndex.ToUnderlying()); break; case RideStatus::Simulating: { @@ -178,7 +178,7 @@ GameActions::Result RideSetStatusAction::Execute() const ride->last_issue_time = 0; ride->GetMeasurement(); ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_MAIN | RIDE_INVALIDATE_RIDE_LIST; - window_invalidate_by_number(WC_RIDE, EnumValue(_rideIndex)); + window_invalidate_by_number(WC_RIDE, _rideIndex.ToUnderlying()); break; } case RideStatus::Testing: @@ -197,7 +197,7 @@ GameActions::Result RideSetStatusAction::Execute() const // Fix #3183: Make sure we close the construction window so the ride finishes any editing code before opening // otherwise vehicles get added to the ride incorrectly (such as to a ghost station) - rct_window* constructionWindow = window_find_by_number(WC_RIDE_CONSTRUCTION, EnumValue(_rideIndex)); + rct_window* constructionWindow = window_find_by_number(WC_RIDE_CONSTRUCTION, _rideIndex.ToUnderlying()); if (constructionWindow != nullptr) { window_close(constructionWindow); @@ -225,7 +225,7 @@ GameActions::Result RideSetStatusAction::Execute() const ride->last_issue_time = 0; ride->GetMeasurement(); ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_MAIN | RIDE_INVALIDATE_RIDE_LIST; - window_invalidate_by_number(WC_RIDE, EnumValue(_rideIndex)); + window_invalidate_by_number(WC_RIDE, _rideIndex.ToUnderlying()); break; } default: diff --git a/src/openrct2/actions/RideSetVehicleAction.cpp b/src/openrct2/actions/RideSetVehicleAction.cpp index 54a6f3c7cd..5a9b351ab8 100644 --- a/src/openrct2/actions/RideSetVehicleAction.cpp +++ b/src/openrct2/actions/RideSetVehicleAction.cpp @@ -69,7 +69,7 @@ GameActions::Result RideSetVehicleAction::Query() const auto ride = get_ride(_rideIndex); if (ride == nullptr) { - log_warning("Invalid game command, ride_id = %u", uint32_t(_rideIndex)); + log_warning("Invalid game command, ride_id = %u", _rideIndex.ToUnderlying()); return GameActions::Result(GameActions::Status::InvalidParameters, errTitle, STR_NONE); } @@ -126,7 +126,7 @@ GameActions::Result RideSetVehicleAction::Execute() const auto ride = get_ride(_rideIndex); if (ride == nullptr) { - log_warning("Invalid game command, ride_id = %u", uint32_t(_rideIndex)); + log_warning("Invalid game command, ride_id = %u", _rideIndex.ToUnderlying()); return GameActions::Result(GameActions::Status::InvalidParameters, errTitle, STR_NONE); } @@ -200,7 +200,7 @@ GameActions::Result RideSetVehicleAction::Execute() const } auto intent = Intent(INTENT_ACTION_RIDE_PAINT_RESET_VEHICLE); - intent.putExtra(INTENT_EXTRA_RIDE_ID, EnumValue(_rideIndex)); + intent.putExtra(INTENT_EXTRA_RIDE_ID, _rideIndex.ToUnderlying()); context_broadcast_intent(&intent); gfx_invalidate_screen(); diff --git a/src/openrct2/actions/TrackPlaceAction.cpp b/src/openrct2/actions/TrackPlaceAction.cpp index 02b2bb4257..8bd29cbb21 100644 --- a/src/openrct2/actions/TrackPlaceAction.cpp +++ b/src/openrct2/actions/TrackPlaceAction.cpp @@ -70,14 +70,14 @@ GameActions::Result TrackPlaceAction::Query() const auto ride = get_ride(_rideIndex); if (ride == nullptr) { - log_warning("Invalid ride for track placement, rideIndex = %d", EnumValue(_rideIndex)); + log_warning("Invalid ride for track placement, rideIndex = %d", _rideIndex.ToUnderlying()); return GameActions::Result( GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_NONE); } rct_ride_entry* rideEntry = get_ride_entry(ride->subtype); if (rideEntry == nullptr) { - log_warning("Invalid ride subtype for track placement, rideIndex = %d", EnumValue(_rideIndex)); + log_warning("Invalid ride subtype for track placement, rideIndex = %d", _rideIndex.ToUnderlying()); return GameActions::Result( GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_NONE); } @@ -411,7 +411,7 @@ GameActions::Result TrackPlaceAction::Execute() const auto ride = get_ride(_rideIndex); if (ride == nullptr) { - log_warning("Invalid ride for track placement, rideIndex = %d", EnumValue(_rideIndex)); + log_warning("Invalid ride for track placement, rideIndex = %d", _rideIndex.ToUnderlying()); return GameActions::Result( GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_NONE); } @@ -419,7 +419,7 @@ GameActions::Result TrackPlaceAction::Execute() const rct_ride_entry* rideEntry = get_ride_entry(ride->subtype); if (rideEntry == nullptr) { - log_warning("Invalid ride subtype for track placement, rideIndex = %d", EnumValue(_rideIndex)); + log_warning("Invalid ride subtype for track placement, rideIndex = %d", _rideIndex.ToUnderlying()); return GameActions::Result( GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_NONE); } @@ -588,7 +588,7 @@ GameActions::Result TrackPlaceAction::Execute() const auto* trackElement = TileElementInsert(mapLoc, quarterTile.GetBaseQuarterOccupied()); if (trackElement == nullptr) { - log_warning("Cannot create track element for ride = %d", EnumValue(_rideIndex)); + log_warning("Cannot create track element for ride = %d", _rideIndex.ToUnderlying()); return GameActions::Result( GameActions::Status::NoFreeElements, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_TILE_ELEMENT_LIMIT_REACHED); diff --git a/src/openrct2/entity/Guest.cpp b/src/openrct2/entity/Guest.cpp index 91d09e90d3..d08113c5f2 100644 --- a/src/openrct2/entity/Guest.cpp +++ b/src/openrct2/entity/Guest.cpp @@ -1838,7 +1838,7 @@ Ride* Guest::FindBestRideToGoOn() Ride* mostExcitingRide = nullptr; for (auto& ride : GetRideManager()) { - const auto rideIndex = EnumValue(ride.id); + const auto rideIndex = ride.id.ToUnderlying(); if (rideConsideration.size() > rideIndex && rideConsideration[rideIndex]) { if (!(ride.lifecycle_flags & RIDE_LIFECYCLE_QUEUE_FULL)) @@ -1870,7 +1870,7 @@ BitSet Guest::FindRidesToGoOn() { if (!HasRidden(&ride)) { - rideConsideration[EnumValue(ride.id)] = true; + rideConsideration[ride.id.ToUnderlying()] = true; } } } @@ -1893,7 +1893,7 @@ BitSet Guest::FindRidesToGoOn() auto rideIndex = trackElement->GetRideIndex(); if (rideIndex != RIDE_ID_NULL) { - rideConsideration[EnumValue(rideIndex)] = true; + rideConsideration[rideIndex.ToUnderlying()] = true; } } } @@ -1904,7 +1904,7 @@ BitSet Guest::FindRidesToGoOn() { if (ride.highest_drop_height > 66 || ride.excitement >= RIDE_RATING(8, 00)) { - rideConsideration[EnumValue(ride.id)] = true; + rideConsideration[ride.id.ToUnderlying()] = true; } } } @@ -3120,7 +3120,7 @@ template static void peep_head_for_nearest_ride(Guest* peep, bool co { if (predicate(ride)) { - rideConsideration[EnumValue(ride.id)] = true; + rideConsideration[ride.id.ToUnderlying()] = true; } } } @@ -3148,7 +3148,7 @@ template static void peep_head_for_nearest_ride(Guest* peep, bool co if (!predicate(*ride)) continue; - rideConsideration[EnumValue(ride->id)] = true; + rideConsideration[ride->id.ToUnderlying()] = true; } } } @@ -3159,7 +3159,7 @@ template static void peep_head_for_nearest_ride(Guest* peep, bool co size_t numPotentialRides = 0; for (auto& ride : GetRideManager()) { - if (rideConsideration[EnumValue(ride.id)]) + if (rideConsideration[ride.id.ToUnderlying()]) { if (!(ride.lifecycle_flags & RIDE_LIFECYCLE_QUEUE_FULL)) { @@ -3671,7 +3671,7 @@ void Guest::UpdateRideAdvanceThroughEntrance() ride->FormatNameTo(ft); if (gConfigNotifications.ride_warnings) { - News::AddItemToQueue(News::ItemType::Ride, STR_GUESTS_GETTING_STUCK_ON_RIDE, EnumValue(CurrentRide), ft); + News::AddItemToQueue(News::ItemType::Ride, STR_GUESTS_GETTING_STUCK_ON_RIDE, CurrentRide.ToUnderlying(), ft); } } @@ -3824,7 +3824,7 @@ void Guest::UpdateRideFreeVehicleEnterRide(Ride* ride) if (queueTime != ride->stations[CurrentRideStation].QueueTime) { ride->stations[CurrentRideStation].QueueTime = queueTime; - window_invalidate_by_number(WC_RIDE, EnumValue(CurrentRide)); + window_invalidate_by_number(WC_RIDE, CurrentRide.ToUnderlying()); } if (PeepFlags & PEEP_FLAGS_TRACKING) @@ -6824,7 +6824,7 @@ void Guest::InsertNewThought(PeepThoughtType thought_type, ShopItem shopItem) void Guest::InsertNewThought(PeepThoughtType thought_type, RideId rideId) { - InsertNewThought(thought_type, static_cast(rideId)); + InsertNewThought(thought_type, rideId.ToUnderlying()); } /** * diff --git a/src/openrct2/interface/InteractiveConsole.cpp b/src/openrct2/interface/InteractiveConsole.cpp index 0db4bde6d5..0ef9aedee9 100644 --- a/src/openrct2/interface/InteractiveConsole.cpp +++ b/src/openrct2/interface/InteractiveConsole.cpp @@ -196,7 +196,7 @@ static int32_t cc_rides(InteractiveConsole& console, const arguments_t& argv) } else { - int32_t res = set_operating_setting(static_cast(ride_index), RideSetSetting::RideType, type); + int32_t res = set_operating_setting(RideId::FromUnderlying(ride_index), RideSetSetting::RideType, type); if (res == MONEY32_UNDEFINED) { if (!gCheatsAllowArbitraryRideTypeChanges) @@ -226,7 +226,7 @@ static int32_t cc_rides(InteractiveConsole& console, const arguments_t& argv) } else { - auto ride = get_ride(static_cast(ride_index)); + auto ride = get_ride(RideId::FromUnderlying(ride_index)); if (mode >= static_cast(RideMode::Count)) { console.WriteFormatLine("Invalid ride mode."); @@ -258,7 +258,7 @@ static int32_t cc_rides(InteractiveConsole& console, const arguments_t& argv) } else { - auto ride = get_ride(static_cast(ride_index)); + auto ride = get_ride(RideId::FromUnderlying(ride_index)); if (mass <= 0) { console.WriteFormatLine("Friction value must be strictly positive"); @@ -296,7 +296,7 @@ static int32_t cc_rides(InteractiveConsole& console, const arguments_t& argv) } else { - auto ride = get_ride(static_cast(ride_index)); + auto ride = get_ride(RideId::FromUnderlying(ride_index)); if (excitement <= 0) { console.WriteFormatLine("Excitement value must be strictly positive"); @@ -327,7 +327,7 @@ static int32_t cc_rides(InteractiveConsole& console, const arguments_t& argv) } else { - auto ride = get_ride(static_cast(ride_index)); + auto ride = get_ride(RideId::FromUnderlying(ride_index)); if (intensity <= 0) { console.WriteFormatLine("Intensity value must be strictly positive"); @@ -358,7 +358,7 @@ static int32_t cc_rides(InteractiveConsole& console, const arguments_t& argv) } else { - auto ride = get_ride(static_cast(ride_index)); + auto ride = get_ride(RideId::FromUnderlying(ride_index)); if (nausea <= 0) { console.WriteFormatLine("Nausea value must be strictly positive"); @@ -428,7 +428,7 @@ static int32_t cc_rides(InteractiveConsole& console, const arguments_t& argv) } else { - auto rideSetPrice = RideSetPriceAction(static_cast(rideId), price, true); + auto rideSetPrice = RideSetPriceAction(RideId::FromUnderlying(rideId), price, true); GameActions::Execute(&rideSetPrice); } } diff --git a/src/openrct2/management/NewsItem.cpp b/src/openrct2/management/NewsItem.cpp index a2864fd157..abc06f42ba 100644 --- a/src/openrct2/management/NewsItem.cpp +++ b/src/openrct2/management/NewsItem.cpp @@ -213,7 +213,7 @@ std::optional News::GetSubjectLocation(News::ItemType type, int32_t s { case News::ItemType::Ride: { - Ride* ride = get_ride(static_cast(subject)); + Ride* ride = get_ride(RideId::FromUnderlying(subject)); if (ride == nullptr || ride->overall_view.IsNull()) { break; diff --git a/src/openrct2/park/ParkFile.cpp b/src/openrct2/park/ParkFile.cpp index be6fbf246f..91dcef23ac 100644 --- a/src/openrct2/park/ParkFile.cpp +++ b/src/openrct2/park/ParkFile.cpp @@ -1363,7 +1363,7 @@ namespace OpenRCT2 { if (srcArray[i / 8] & (1 << (i % 8))) { - ridesBeenOn.push_back(static_cast(i)); + ridesBeenOn.push_back(RideId::FromUnderlying(i)); } } return ridesBeenOn; diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 66139b6c6a..f7789918a7 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -775,7 +775,7 @@ namespace RCT1 { if (_s4.rides[i].type != RideType::Null) { - const auto rideId = static_cast(i); + const auto rideId = RideId::FromUnderlying(i); ImportRide(GetOrAllocateRide(rideId), &_s4.rides[i], rideId); } } @@ -2518,7 +2518,7 @@ namespace RCT1 { if (_s4.scenario_slot_index == SC_URBAN_PARK && _isScenario) { - const auto merryGoRoundId = static_cast(0); + const auto merryGoRoundId = RideId::FromUnderlying(0); // First, make the queuing peep exit for (auto peep : EntityList()) @@ -2704,13 +2704,13 @@ namespace RCT1 { auto* dst = CreateEntityAt<::Vehicle>(srcBase.sprite_index); auto* src = static_cast(&srcBase); - const auto* ride = get_ride(static_cast(src->ride)); + const auto* ride = get_ride(RideId::FromUnderlying(src->ride)); if (ride == nullptr) return; uint8_t vehicleEntryIndex = RCT1::GetVehicleSubEntryIndex(src->vehicle_type); - dst->ride = static_cast(src->ride); + dst->ride = RideId::FromUnderlying(src->ride); dst->ride_subtype = RCTEntryIndexToOpenRCT2EntryIndex(ride->subtype); dst->vehicle_type = vehicleEntryIndex; diff --git a/src/openrct2/rct12/RCT12.cpp b/src/openrct2/rct12/RCT12.cpp index 73e83ce140..76ce4ea95d 100644 --- a/src/openrct2/rct12/RCT12.cpp +++ b/src/openrct2/rct12/RCT12.cpp @@ -492,7 +492,7 @@ RideId RCT12RideIdToOpenRCT2RideId(const RCT12RideId rideId) if (rideId == RCT12_RIDE_ID_NULL) return RIDE_ID_NULL; - return static_cast(rideId); + return RideId::FromUnderlying(rideId); } static bool RCT12IsFormatChar(codepoint_t c) diff --git a/src/openrct2/rct12/RCT12.h b/src/openrct2/rct12/RCT12.h index ce7e833e10..b122afd3be 100644 --- a/src/openrct2/rct12/RCT12.h +++ b/src/openrct2/rct12/RCT12.h @@ -881,7 +881,7 @@ template std::vector RCT12GetRidesBeenOn(T* srcPeep) { if (srcPeep->rides_been_on[i / 8] & (1 << (i % 8))) { - ridesBeenOn.push_back(static_cast(i)); + ridesBeenOn.push_back(RideId::FromUnderlying(i)); } } return ridesBeenOn; diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index 71d1505b10..a23f5fecbb 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -566,7 +566,7 @@ namespace RCT2 auto src = &_s6.rides[index]; if (src->type != RIDE_TYPE_NULL) { - const auto rideId = static_cast(index); + const auto rideId = RideId::FromUnderlying(index); auto dst = GetOrAllocateRide(rideId); ImportRide(dst, src, rideId); } @@ -960,7 +960,7 @@ namespace RCT2 { if (src.ride_index != RCT12_RIDE_ID_NULL) { - const auto rideId = static_cast(src.ride_index); + const auto rideId = RideId::FromUnderlying(src.ride_index); auto ride = get_ride(rideId); if (ride != nullptr) { @@ -1098,7 +1098,7 @@ namespace RCT2 { if (sprite.unknown.sprite_identifier == RCT12SpriteIdentifier::Peep) { - if (sprite.peep.current_ride == static_cast(rideIndex) + if (sprite.peep.current_ride == static_cast(rideIndex.ToUnderlying()) && (static_cast(sprite.peep.state) == PeepState::OnRide || static_cast(sprite.peep.state) == PeepState::EnteringRide)) { @@ -1795,7 +1795,7 @@ namespace RCT2 dst->remaining_distance = src->remaining_distance; dst->velocity = src->velocity; dst->acceleration = src->acceleration; - dst->ride = static_cast(src->ride); + dst->ride = RideId::FromUnderlying(src->ride); dst->vehicle_type = src->vehicle_type; dst->colours = src->colours; dst->track_progress = src->track_progress; diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index 40552d5205..44e950a045 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -127,18 +127,20 @@ size_t RideManager::size() const RideManager::Iterator RideManager::begin() { - return RideManager::Iterator(*this, 0, _rides.size()); + const auto endIndex = static_cast(_rides.size()); + return RideManager::Iterator(*this, 0u, endIndex); } RideManager::Iterator RideManager::end() { - return RideManager::Iterator(*this, _rides.size(), _rides.size()); + const auto endIndex = static_cast(_rides.size()); + return RideManager::Iterator(*this, endIndex, endIndex); } RideId GetNextFreeRideId() { - size_t result = _rides.size(); - for (size_t i = 0; i < _rides.size(); i++) + auto result = static_cast(_rides.size()); + for (RideId::UnderlyingType i = 0; i < _rides.size(); i++) { if (_rides[i].type == RIDE_TYPE_NULL) { @@ -150,12 +152,12 @@ RideId GetNextFreeRideId() { return RIDE_ID_NULL; } - return static_cast(result); + return RideId::FromUnderlying(result); } Ride* GetOrAllocateRide(RideId index) { - const auto idx = static_cast(index); + const auto idx = index.ToUnderlying(); if (_rides.size() <= idx) { _rides.resize(idx + 1); @@ -168,7 +170,7 @@ Ride* GetOrAllocateRide(RideId index) Ride* get_ride(RideId index) { - const auto idx = static_cast(index); + const auto idx = index.ToUnderlying(); if (idx < _rides.size()) { auto& ride = _rides[idx]; @@ -1039,7 +1041,7 @@ void Ride::Update() // with the increased MAX_RIDES the update is tied to the first byte of the id this allows // for identical balance with vanilla. const auto updatingRideByte = static_cast((gCurrentTicks / 2) & 0xFF); - if (updatingRideByte == static_cast(id)) + if (updatingRideByte == static_cast(id.ToUnderlying())) ride_breakdown_status_update(this); } @@ -1522,7 +1524,7 @@ void ride_breakdown_add_news_item(Ride* ride) { Formatter ft; ride->FormatNameTo(ft); - News::AddItemToQueue(News::ItemType::Ride, STR_RIDE_IS_BROKEN_DOWN, EnumValue(ride->id), ft); + News::AddItemToQueue(News::ItemType::Ride, STR_RIDE_IS_BROKEN_DOWN, ride->id.ToUnderlying(), ft); } } @@ -1549,7 +1551,7 @@ static void ride_breakdown_status_update(Ride* ride) { Formatter ft; ride->FormatNameTo(ft); - News::AddItemToQueue(News::ItemType::Ride, STR_RIDE_IS_STILL_NOT_FIXED, EnumValue(ride->id), ft); + News::AddItemToQueue(News::ItemType::Ride, STR_RIDE_IS_STILL_NOT_FIXED, ride->id.ToUnderlying(), ft); } } } @@ -2237,7 +2239,7 @@ static void ride_entrance_exit_connected(Ride* ride) ride->FormatNameTo(ft); if (gConfigNotifications.ride_warnings) { - News::AddItemToQueue(News::ItemType::Ride, STR_ENTRANCE_NOT_CONNECTED, EnumValue(ride->id), ft); + News::AddItemToQueue(News::ItemType::Ride, STR_ENTRANCE_NOT_CONNECTED, ride->id.ToUnderlying(), ft); } ride->connected_message_throttle = 3; } @@ -2249,7 +2251,7 @@ static void ride_entrance_exit_connected(Ride* ride) ride->FormatNameTo(ft); if (gConfigNotifications.ride_warnings) { - News::AddItemToQueue(News::ItemType::Ride, STR_EXIT_NOT_CONNECTED, EnumValue(ride->id), ft); + News::AddItemToQueue(News::ItemType::Ride, STR_EXIT_NOT_CONNECTED, ride->id.ToUnderlying(), ft); } ride->connected_message_throttle = 3; } @@ -2318,7 +2320,7 @@ static void ride_shop_connected(Ride* ride) { Formatter ft; ride->FormatNameTo(ft); - News::AddItemToQueue(News::ItemType::Ride, STR_ENTRANCE_NOT_CONNECTED, EnumValue(ride->id), ft); + News::AddItemToQueue(News::ItemType::Ride, STR_ENTRANCE_NOT_CONNECTED, ride->id.ToUnderlying(), ft); } ride->connected_message_throttle = 3; @@ -3858,13 +3860,13 @@ bool Ride::Test(RideStatus newStatus, bool isApplying) if (type == RIDE_TYPE_NULL) { - log_warning("Invalid ride type for ride %u", EnumValue(id)); + log_warning("Invalid ride type for ride %u", id.ToUnderlying()); return false; } if (newStatus != RideStatus::Simulating) { - window_close_by_number(WC_RIDE_CONSTRUCTION, EnumValue(id)); + window_close_by_number(WC_RIDE_CONSTRUCTION, id.ToUnderlying()); } StationIndex stationIndex = ride_mode_check_station_present(this); @@ -3991,10 +3993,10 @@ bool Ride::Open(bool isApplying) // to set the track to its final state and clean up ghosts. // We can't just call close as it would cause a stack overflow during shop creation // with auto open on. - if (WC_RIDE_CONSTRUCTION == gCurrentToolWidget.window_classification && EnumValue(id) == gCurrentToolWidget.window_number + if (WC_RIDE_CONSTRUCTION == gCurrentToolWidget.window_classification && id.ToUnderlying() == gCurrentToolWidget.window_number && (input_test_flag(INPUT_FLAG_TOOL_ACTIVE))) { - window_close_by_number(WC_RIDE_CONSTRUCTION, EnumValue(id)); + window_close_by_number(WC_RIDE_CONSTRUCTION, id.ToUnderlying()); } StationIndex stationIndex = ride_mode_check_station_present(this); @@ -4700,7 +4702,7 @@ void invalidate_test_results(Ride* ride) } } } - window_invalidate_by_number(WC_RIDE, static_cast(ride->id)); + window_invalidate_by_number(WC_RIDE, ride->id.ToUnderlying()); } /** @@ -5133,7 +5135,7 @@ void Ride::UpdateMaxVehicles() { num_cars_per_train = numCarsPerTrain; num_vehicles = numVehicles; - window_invalidate_by_number(WC_RIDE, EnumValue(id)); + window_invalidate_by_number(WC_RIDE, id.ToUnderlying()); } } @@ -5202,7 +5204,7 @@ void Ride::Crash(uint8_t vehicleIndex) { Formatter ft; FormatNameTo(ft); - News::AddItemToQueue(News::ItemType::Ride, STR_RIDE_HAS_CRASHED, EnumValue(id), ft); + News::AddItemToQueue(News::ItemType::Ride, STR_RIDE_HAS_CRASHED, id.ToUnderlying(), ft); } } @@ -5802,7 +5804,7 @@ std::vector GetTracklessRides() auto trackEl = it.element->AsTrack(); if (trackEl != nullptr && !trackEl->IsGhost()) { - auto rideId = static_cast(trackEl->GetRideIndex()); + auto rideId = trackEl->GetRideIndex().ToUnderlying(); if (rideId >= seen.size()) { seen.resize(rideId + 1); @@ -5816,7 +5818,8 @@ std::vector GetTracklessRides() std::vector result; for (const auto& ride : rideManager) { - if (seen.size() <= static_cast(ride.id) || !seen[static_cast(ride.id)]) + const auto rideIndex = ride.id.ToUnderlying(); + if (seen.size() <= rideIndex || !seen[rideIndex]) { result.push_back(ride.id); } diff --git a/src/openrct2/ride/Ride.h b/src/openrct2/ride/Ride.h index a6aa349fb0..29137fca0e 100644 --- a/src/openrct2/ride/Ride.h +++ b/src/openrct2/ride/Ride.h @@ -888,8 +888,8 @@ struct RideManager private: RideManager* _rideManager; - size_t _index{}; - size_t _endIndex{}; + RideId::UnderlyingType _index{}; + RideId::UnderlyingType _endIndex{}; public: using difference_type = intptr_t; @@ -901,10 +901,10 @@ struct RideManager private: Iterator(RideManager& rideManager, size_t beginIndex, size_t endIndex) : _rideManager(&rideManager) - , _index(beginIndex) - , _endIndex(endIndex) + , _index(static_cast(beginIndex)) + , _endIndex(static_cast(endIndex)) { - if (_index < _endIndex && (*_rideManager)[static_cast(_index)] == nullptr) + if (_index < _endIndex && (*_rideManager)[RideId::FromUnderlying(_index)] == nullptr) { ++(*this); } @@ -916,7 +916,7 @@ struct RideManager do { _index++; - } while (_index < _endIndex && (*_rideManager)[static_cast(_index)] == nullptr); + } while (_index < _endIndex && (*_rideManager)[RideId::FromUnderlying(_index)] == nullptr); return *this; } Iterator operator++(int) @@ -935,7 +935,7 @@ struct RideManager } Ride& operator*() { - return *(*_rideManager)[static_cast(_index)]; + return *(*_rideManager)[RideId::FromUnderlying(_index)]; } }; diff --git a/src/openrct2/ride/RideConstruction.cpp b/src/openrct2/ride/RideConstruction.cpp index 59517e9e32..d8dd456703 100644 --- a/src/openrct2/ride/RideConstruction.cpp +++ b/src/openrct2/ride/RideConstruction.cpp @@ -126,7 +126,7 @@ static rct_window* ride_create_or_find_construction_window(RideId rideIndex) { auto windowManager = GetContext()->GetUiContext()->GetWindowManager(); auto intent = Intent(INTENT_ACTION_RIDE_CONSTRUCTION_FOCUS); - intent.putExtra(INTENT_EXTRA_RIDE_ID, EnumValue(rideIndex)); + intent.putExtra(INTENT_EXTRA_RIDE_ID, rideIndex.ToUnderlying()); windowManager->BroadcastIntent(intent); return window_find_by_class(WC_RIDE_CONSTRUCTION); } @@ -243,7 +243,7 @@ void ride_clear_for_construction(Ride* ride) ride->RemoveVehicles(); ride_clear_blocked_tiles(ride); - auto w = window_find_by_number(WC_RIDE, EnumValue(ride->id)); + auto w = window_find_by_number(WC_RIDE, ride->id.ToUnderlying()); if (w != nullptr) window_event_resize_call(w); } diff --git a/src/openrct2/ride/RideConstruction.h b/src/openrct2/ride/RideConstruction.h index b1baa5616c..3417f1b0fd 100644 --- a/src/openrct2/ride/RideConstruction.h +++ b/src/openrct2/ride/RideConstruction.h @@ -9,6 +9,7 @@ #pragma once +#include "../Identifiers.h" #include "../common.h" #include "../world/Location.hpp" #include "Station.h" @@ -17,7 +18,6 @@ #include using track_type_t = uint16_t; -enum class RideId : uint16_t; struct TileElement; struct CoordsXYE; diff --git a/src/openrct2/ride/RideRatings.cpp b/src/openrct2/ride/RideRatings.cpp index a131c39397..804356c8c6 100644 --- a/src/openrct2/ride/RideRatings.cpp +++ b/src/openrct2/ride/RideRatings.cpp @@ -160,20 +160,18 @@ static void ride_ratings_update_state(RideRatingUpdateState& state) */ static void ride_ratings_update_state_0(RideRatingUpdateState& state) { - RideId currentRide = state.CurrentRide; - - currentRide = static_cast(EnumValue(currentRide) + 1); - if (currentRide >= static_cast(OpenRCT2::Limits::MaxRidesInPark)) + auto nextRide = RideId::FromUnderlying(state.CurrentRide.ToUnderlying() + 1); + if (nextRide.ToUnderlying() >= OpenRCT2::Limits::MaxRidesInPark) { - currentRide = {}; + nextRide = {}; } - auto ride = get_ride(currentRide); + auto ride = get_ride(nextRide); if (ride != nullptr && ride->status != RideStatus::Closed && !(ride->lifecycle_flags & RIDE_LIFECYCLE_FIXED_RATINGS)) { state.State = RIDE_RATINGS_STATE_INITIALISE; } - state.CurrentRide = currentRide; + state.CurrentRide = nextRide; } /** @@ -288,7 +286,7 @@ static void ride_ratings_update_state_3(RideRatingUpdateState& state) ride_ratings_calculate(state, ride); ride_ratings_calculate_value(ride); - window_invalidate_by_number(WC_RIDE, EnumValue(state.CurrentRide)); + window_invalidate_by_number(WC_RIDE, state.CurrentRide.ToUnderlying()); state.State = RIDE_RATINGS_STATE_FIND_NEXT_RIDE; } @@ -753,7 +751,7 @@ static void ride_ratings_calculate(RideRatingUpdateState& state, Ride* ride) // Create event args object auto obj = DukObject(ctx); - obj.Set("rideId", EnumValue(ride->id)); + obj.Set("rideId", ride->id.ToUnderlying()); obj.Set("excitement", originalExcitement); obj.Set("intensity", originalIntensity); obj.Set("nausea", originalNausea); diff --git a/src/openrct2/ride/TrackDesign.h b/src/openrct2/ride/TrackDesign.h index 9dee4ce1bd..fb50db872a 100644 --- a/src/openrct2/ride/TrackDesign.h +++ b/src/openrct2/ride/TrackDesign.h @@ -208,7 +208,7 @@ enum MAZE_ELEMENT_TYPE_EXIT = (1 << 7) }; -static constexpr RideId PreviewRideId = static_cast(0); +static constexpr RideId PreviewRideId = RideId::FromUnderlying(0); extern bool gTrackDesignSceneryToggle; diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index f4497570de..98048d854a 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -1427,7 +1427,7 @@ void Vehicle::UpdateMeasurements() curRide->lifecycle_flags |= RIDE_LIFECYCLE_NO_RAW_STATS; curRide->lifecycle_flags &= ~RIDE_LIFECYCLE_TEST_IN_PROGRESS; ClearUpdateFlag(VEHICLE_UPDATE_FLAG_TESTING); - window_invalidate_by_number(WC_RIDE, EnumValue(ride)); + window_invalidate_by_number(WC_RIDE, ride.ToUnderlying()); return; } @@ -2937,7 +2937,7 @@ static void test_finish(Ride& ride) totalTime = std::max(totalTime, 1u); ride.average_speed = ride.average_speed / totalTime; - window_invalidate_by_number(WC_RIDE, EnumValue(ride.id)); + window_invalidate_by_number(WC_RIDE, ride.id.ToUnderlying()); } void Vehicle::UpdateTestFinish() @@ -2987,7 +2987,7 @@ static void test_reset(Ride& ride, StationIndex curStation) } ride.total_air_time = 0; ride.current_test_station = curStation; - window_invalidate_by_number(WC_RIDE, EnumValue(ride.id)); + window_invalidate_by_number(WC_RIDE, ride.id.ToUnderlying()); } void Vehicle::TestReset() @@ -3393,7 +3393,7 @@ void Vehicle::CheckIfMissing() curRide->FormatNameTo(ft); ft.Add(GetRideComponentName(GetRideTypeDescriptor(curRide->type).NameConvention.station).singular); - News::AddItemToQueue(News::ItemType::Ride, STR_NEWS_VEHICLE_HAS_STALLED, EnumValue(ride), ft); + News::AddItemToQueue(News::ItemType::Ride, STR_NEWS_VEHICLE_HAS_STALLED, ride.ToUnderlying(), ft); } } @@ -5127,7 +5127,7 @@ static void ride_train_crash(Ride* ride, uint16_t numFatalities) { ride->FormatNameTo(ft); News::AddItemToQueue( - News::ItemType::Ride, numFatalities == 1 ? STR_X_PERSON_DIED_ON_X : STR_X_PEOPLE_DIED_ON_X, EnumValue(ride->id), + News::ItemType::Ride, numFatalities == 1 ? STR_X_PERSON_DIED_ON_X : STR_X_PEOPLE_DIED_ON_X, ride->id.ToUnderlying(), ft); } diff --git a/src/openrct2/scripting/ScriptEngine.cpp b/src/openrct2/scripting/ScriptEngine.cpp index b5f79f831f..c3dd1e68b7 100644 --- a/src/openrct2/scripting/ScriptEngine.cpp +++ b/src/openrct2/scripting/ScriptEngine.cpp @@ -892,7 +892,7 @@ DukValue ScriptEngine::GameActionResultToDuk(const GameAction& action, const Gam if (result.Error == GameActions::Status::Ok) { const auto rideIndex = result.GetData(); - obj.Set("ride", EnumValue(rideIndex)); + obj.Set("ride", rideIndex.ToUnderlying()); } } else if (action.GetType() == GameCommand::HireNewStaffMember) diff --git a/src/openrct2/scripting/bindings/entity/ScVehicle.cpp b/src/openrct2/scripting/bindings/entity/ScVehicle.cpp index 82cc5ea551..6e3ecded33 100644 --- a/src/openrct2/scripting/bindings/entity/ScVehicle.cpp +++ b/src/openrct2/scripting/bindings/entity/ScVehicle.cpp @@ -138,7 +138,7 @@ namespace OpenRCT2::Scripting int32_t ScVehicle::ride_get() const { auto vehicle = GetVehicle(); - return EnumValue(vehicle != nullptr ? vehicle->ride : RIDE_ID_NULL); + return (vehicle != nullptr ? vehicle->ride : RIDE_ID_NULL).ToUnderlying(); } void ScVehicle::ride_set(int32_t value) { @@ -146,7 +146,7 @@ namespace OpenRCT2::Scripting auto vehicle = GetVehicle(); if (vehicle != nullptr) { - vehicle->ride = static_cast(value); + vehicle->ride = RideId::FromUnderlying(value); } } diff --git a/src/openrct2/scripting/bindings/ride/ScRide.cpp b/src/openrct2/scripting/bindings/ride/ScRide.cpp index b0f7b211a4..6e83c7d850 100644 --- a/src/openrct2/scripting/bindings/ride/ScRide.cpp +++ b/src/openrct2/scripting/bindings/ride/ScRide.cpp @@ -27,7 +27,7 @@ namespace OpenRCT2::Scripting int32_t ScRide::id_get() const { - return EnumValue(_rideId); + return _rideId.ToUnderlying(); } std::shared_ptr ScRide::object_get() diff --git a/src/openrct2/scripting/bindings/world/ScMap.cpp b/src/openrct2/scripting/bindings/world/ScMap.cpp index 3cb2c7f535..dec9bec14d 100644 --- a/src/openrct2/scripting/bindings/world/ScMap.cpp +++ b/src/openrct2/scripting/bindings/world/ScMap.cpp @@ -69,7 +69,7 @@ namespace OpenRCT2::Scripting std::shared_ptr ScMap::getRide(int32_t id) const { auto rideManager = GetRideManager(); - auto ride = rideManager[static_cast(id)]; + auto ride = rideManager[RideId::FromUnderlying(id)]; if (ride != nullptr) { return std::make_shared(ride->id); diff --git a/src/openrct2/scripting/bindings/world/ScTileElement.cpp b/src/openrct2/scripting/bindings/world/ScTileElement.cpp index 590c7bd3ad..d152c87d28 100644 --- a/src/openrct2/scripting/bindings/world/ScTileElement.cpp +++ b/src/openrct2/scripting/bindings/world/ScTileElement.cpp @@ -452,7 +452,7 @@ namespace OpenRCT2::Scripting { auto el = _element->AsPath(); if (el->IsQueue() && el->GetRideIndex() != RIDE_ID_NULL) - duk_push_int(ctx, EnumValue(el->GetRideIndex())); + duk_push_int(ctx, el->GetRideIndex().ToUnderlying()); else duk_push_null(ctx); break; @@ -460,13 +460,13 @@ namespace OpenRCT2::Scripting case TileElementType::Track: { auto el = _element->AsTrack(); - duk_push_int(ctx, EnumValue(el->GetRideIndex())); + duk_push_int(ctx, el->GetRideIndex().ToUnderlying()); break; } case TileElementType::Entrance: { auto el = _element->AsEntrance(); - duk_push_int(ctx, EnumValue(el->GetRideIndex())); + duk_push_int(ctx, el->GetRideIndex().ToUnderlying()); break; } default: @@ -488,7 +488,7 @@ namespace OpenRCT2::Scripting if (el->IsQueue()) { if (value.type() == DukValue::Type::NUMBER) - el->SetRideIndex(static_cast(value.as_uint())); + el->SetRideIndex(RideId::FromUnderlying(value.as_uint())); else el->SetRideIndex(RIDE_ID_NULL); Invalidate(); @@ -500,7 +500,7 @@ namespace OpenRCT2::Scripting if (value.type() == DukValue::Type::NUMBER) { auto el = _element->AsTrack(); - el->SetRideIndex(static_cast(value.as_uint())); + el->SetRideIndex(RideId::FromUnderlying(value.as_uint())); Invalidate(); } break; @@ -510,7 +510,7 @@ namespace OpenRCT2::Scripting if (value.type() == DukValue::Type::NUMBER) { auto el = _element->AsEntrance(); - el->SetRideIndex(static_cast(value.as_uint())); + el->SetRideIndex(RideId::FromUnderlying(value.as_uint())); Invalidate(); } break; From 06e430157f66eec03318cd1bb3b701a90ecedfee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Wed, 19 Jan 2022 18:24:23 +0200 Subject: [PATCH 5/9] Use RideId::GetNull and RideId::IsNull over constant --- src/openrct2-ui/windows/NewCampaign.cpp | 2 +- src/openrct2-ui/windows/Ride.cpp | 2 +- src/openrct2/Game.cpp | 4 +- src/openrct2/actions/FootpathPlaceAction.cpp | 2 +- .../actions/FootpathPlaceFromTrackAction.cpp | 2 +- .../actions/LargeSceneryPlaceAction.cpp | 2 +- src/openrct2/actions/MazePlaceTrackAction.h | 2 +- src/openrct2/actions/MazeSetTrackAction.h | 2 +- src/openrct2/actions/RideCreateAction.cpp | 2 +- src/openrct2/actions/RideDemolishAction.h | 2 +- .../actions/RideEntranceExitPlaceAction.h | 2 +- .../actions/RideEntranceExitRemoveAction.h | 2 +- .../actions/RideSetAppearanceAction.h | 2 +- src/openrct2/actions/RideSetNameAction.h | 2 +- src/openrct2/actions/RideSetPriceAction.h | 2 +- src/openrct2/actions/RideSetSettingAction.h | 2 +- src/openrct2/actions/RideSetStatusAction.h | 2 +- src/openrct2/actions/RideSetVehicleAction.h | 2 +- src/openrct2/actions/SignSetNameAction.cpp | 6 +-- src/openrct2/actions/TrackDesignAction.cpp | 2 +- src/openrct2/actions/TrackPlaceAction.h | 2 +- src/openrct2/actions/WallPlaceAction.cpp | 2 +- src/openrct2/entity/Guest.cpp | 44 +++++++++---------- src/openrct2/entity/Peep.cpp | 26 +++++------ src/openrct2/entity/Staff.cpp | 4 +- src/openrct2/peep/GuestPathfinding.cpp | 16 +++---- src/openrct2/rct1/S4Importer.cpp | 2 +- src/openrct2/rct12/RCT12.cpp | 2 +- src/openrct2/ride/Ride.cpp | 4 +- src/openrct2/ride/Ride.h | 4 +- src/openrct2/ride/RideTypes.h | 2 - src/openrct2/ride/TrackDesignSave.cpp | 2 +- src/openrct2/ride/Vehicle.cpp | 4 +- .../scripting/bindings/entity/ScVehicle.cpp | 2 +- .../scripting/bindings/ride/ScRide.hpp | 2 +- .../scripting/bindings/ride/ScRideStation.hpp | 2 +- .../bindings/world/ScTileElement.cpp | 6 +-- src/openrct2/world/Banner.cpp | 10 ++--- src/openrct2/world/Footpath.cpp | 20 ++++----- src/openrct2/world/Map.cpp | 2 +- src/openrct2/world/TileElement.cpp | 2 +- 41 files changed, 102 insertions(+), 104 deletions(-) diff --git a/src/openrct2-ui/windows/NewCampaign.cpp b/src/openrct2-ui/windows/NewCampaign.cpp index 65cd068d94..d5f23b79be 100644 --- a/src/openrct2-ui/windows/NewCampaign.cpp +++ b/src/openrct2-ui/windows/NewCampaign.cpp @@ -27,7 +27,7 @@ static constexpr const rct_string_id WINDOW_TITLE = STR_NONE; static constexpr const int32_t WH = 109; static constexpr const int32_t WW = 350; -constexpr auto SELECTED_RIDE_UNDEFINED = RIDE_ID_NULL; +constexpr auto SELECTED_RIDE_UNDEFINED = RideId::GetNull(); constexpr uint16_t SELECTED_ITEM_UNDEFINED = 0xFFFF; // clang-format off diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index c4e99f1870..d963285362 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -1353,7 +1353,7 @@ rct_window* WindowRideOpenTrack(TileElement* tileElement) { assert(tileElement != nullptr); auto rideIndex = tileElement->GetRideIndex(); - if (rideIndex != RIDE_ID_NULL) + if (!rideIndex.IsNull()) { auto ride = get_ride(rideIndex); if (ride != nullptr) diff --git a/src/openrct2/Game.cpp b/src/openrct2/Game.cpp index ac1dc210b9..ff479d8432 100644 --- a/src/openrct2/Game.cpp +++ b/src/openrct2/Game.cpp @@ -363,7 +363,7 @@ void game_fix_save_vars() { const auto srcStation = peep->CurrentRideStation; const auto rideIdx = peep->CurrentRide; - if (rideIdx == RIDE_ID_NULL) + if (rideIdx.IsNull()) { continue; } @@ -371,7 +371,7 @@ void game_fix_save_vars() if (ride == nullptr) { log_warning("Couldn't find ride %u, resetting ride on peep %u", rideIdx, peep->sprite_index); - peep->CurrentRide = RIDE_ID_NULL; + peep->CurrentRide = RideId::GetNull(); continue; } auto curName = peep->GetName(); diff --git a/src/openrct2/actions/FootpathPlaceAction.cpp b/src/openrct2/actions/FootpathPlaceAction.cpp index 4428e64c0d..93ee989e19 100644 --- a/src/openrct2/actions/FootpathPlaceAction.cpp +++ b/src/openrct2/actions/FootpathPlaceAction.cpp @@ -424,7 +424,7 @@ GameActions::Result FootpathPlaceAction::ElementInsertExecute(GameActions::Resul pathElement->SetSloped(_slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED); pathElement->SetIsQueue(isQueue); pathElement->SetAddition(0); - pathElement->SetRideIndex(RIDE_ID_NULL); + pathElement->SetRideIndex(RideId::GetNull()); pathElement->SetAdditionStatus(255); pathElement->SetIsBroken(false); pathElement->SetGhost(GetFlags() & GAME_COMMAND_FLAG_GHOST); diff --git a/src/openrct2/actions/FootpathPlaceFromTrackAction.cpp b/src/openrct2/actions/FootpathPlaceFromTrackAction.cpp index b532f4a36b..a63a9999f6 100644 --- a/src/openrct2/actions/FootpathPlaceFromTrackAction.cpp +++ b/src/openrct2/actions/FootpathPlaceFromTrackAction.cpp @@ -268,7 +268,7 @@ GameActions::Result FootpathPlaceFromTrackAction::ElementInsertExecute(GameActio pathElement->SetSloped(_slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED); pathElement->SetIsQueue(isQueue); pathElement->SetAddition(0); - pathElement->SetRideIndex(RIDE_ID_NULL); + pathElement->SetRideIndex(RideId::GetNull()); pathElement->SetAdditionStatus(255); pathElement->SetIsBroken(false); pathElement->SetEdges(_edges); diff --git a/src/openrct2/actions/LargeSceneryPlaceAction.cpp b/src/openrct2/actions/LargeSceneryPlaceAction.cpp index abddc9176a..23612ea6bd 100644 --- a/src/openrct2/actions/LargeSceneryPlaceAction.cpp +++ b/src/openrct2/actions/LargeSceneryPlaceAction.cpp @@ -231,7 +231,7 @@ GameActions::Result LargeSceneryPlaceAction::Execute() const banner->position = TileCoordsXY(_loc); RideId rideIndex = banner_get_closest_ride_index({ _loc, maxHeight }); - if (rideIndex != RIDE_ID_NULL) + if (!rideIndex.IsNull()) { banner->ride_index = rideIndex; banner->flags |= BANNER_FLAG_LINKED_TO_RIDE; diff --git a/src/openrct2/actions/MazePlaceTrackAction.h b/src/openrct2/actions/MazePlaceTrackAction.h index 5ef4f0e0d3..cf2e9c7497 100644 --- a/src/openrct2/actions/MazePlaceTrackAction.h +++ b/src/openrct2/actions/MazePlaceTrackAction.h @@ -14,7 +14,7 @@ class MazePlaceTrackAction final : public GameActionBase { private: - NetworkRideId_t _rideIndex{ RIDE_ID_NULL }; + NetworkRideId_t _rideIndex{ RideId::GetNull() }; uint8_t _modifyType{ RIDE_MODIFY_DEMOLISH }; public: diff --git a/src/openrct2/actions/RideEntranceExitPlaceAction.h b/src/openrct2/actions/RideEntranceExitPlaceAction.h index 2cca8c762f..15f8650e0f 100644 --- a/src/openrct2/actions/RideEntranceExitPlaceAction.h +++ b/src/openrct2/actions/RideEntranceExitPlaceAction.h @@ -17,7 +17,7 @@ class RideEntranceExitPlaceAction final : public GameActionBase { private: - NetworkRideId_t _rideIndex{ RIDE_ID_NULL }; + NetworkRideId_t _rideIndex{ RideId::GetNull() }; RideSetAppearanceType _type{}; uint16_t _value{}; uint32_t _index{}; diff --git a/src/openrct2/actions/RideSetNameAction.h b/src/openrct2/actions/RideSetNameAction.h index d32a4dfa4f..1193218df7 100644 --- a/src/openrct2/actions/RideSetNameAction.h +++ b/src/openrct2/actions/RideSetNameAction.h @@ -14,7 +14,7 @@ class RideSetNameAction final : public GameActionBase { private: - NetworkRideId_t _rideIndex{ RIDE_ID_NULL }; + NetworkRideId_t _rideIndex{ RideId::GetNull() }; std::string _name; public: diff --git a/src/openrct2/actions/RideSetPriceAction.h b/src/openrct2/actions/RideSetPriceAction.h index 176f53527b..0d0621e382 100644 --- a/src/openrct2/actions/RideSetPriceAction.h +++ b/src/openrct2/actions/RideSetPriceAction.h @@ -14,7 +14,7 @@ class RideSetPriceAction final : public GameActionBase { private: - NetworkRideId_t _rideIndex{ RIDE_ID_NULL }; + NetworkRideId_t _rideIndex{ RideId::GetNull() }; money16 _price{ MONEY16_UNDEFINED }; bool _primaryPrice{ true }; diff --git a/src/openrct2/actions/RideSetSettingAction.h b/src/openrct2/actions/RideSetSettingAction.h index 30c736e1af..18945a3823 100644 --- a/src/openrct2/actions/RideSetSettingAction.h +++ b/src/openrct2/actions/RideSetSettingAction.h @@ -29,7 +29,7 @@ enum class RideSetSetting : uint8_t class RideSetSettingAction final : public GameActionBase { private: - NetworkRideId_t _rideIndex{ RIDE_ID_NULL }; + NetworkRideId_t _rideIndex{ RideId::GetNull() }; RideSetSetting _setting{}; uint8_t _value{}; diff --git a/src/openrct2/actions/RideSetStatusAction.h b/src/openrct2/actions/RideSetStatusAction.h index 9090310115..575b1f02dd 100644 --- a/src/openrct2/actions/RideSetStatusAction.h +++ b/src/openrct2/actions/RideSetStatusAction.h @@ -14,7 +14,7 @@ class RideSetStatusAction final : public GameActionBase { private: - NetworkRideId_t _rideIndex{ RIDE_ID_NULL }; + NetworkRideId_t _rideIndex{ RideId::GetNull() }; RideStatus _status{ RideStatus::Closed }; public: diff --git a/src/openrct2/actions/RideSetVehicleAction.h b/src/openrct2/actions/RideSetVehicleAction.h index 4b88c7bea7..1b4d56a359 100644 --- a/src/openrct2/actions/RideSetVehicleAction.h +++ b/src/openrct2/actions/RideSetVehicleAction.h @@ -22,7 +22,7 @@ enum class RideSetVehicleType : uint8_t class RideSetVehicleAction final : public GameActionBase { private: - NetworkRideId_t _rideIndex{ RIDE_ID_NULL }; + NetworkRideId_t _rideIndex{ RideId::GetNull() }; RideSetVehicleType _type{}; uint8_t _value{}; uint8_t _colour{}; diff --git a/src/openrct2/actions/SignSetNameAction.cpp b/src/openrct2/actions/SignSetNameAction.cpp index 0763dc5d1e..454d5c27bf 100644 --- a/src/openrct2/actions/SignSetNameAction.cpp +++ b/src/openrct2/actions/SignSetNameAction.cpp @@ -66,17 +66,17 @@ GameActions::Result SignSetNameAction::Execute() const if (!_name.empty()) { banner->flags &= ~BANNER_FLAG_LINKED_TO_RIDE; - banner->ride_index = RIDE_ID_NULL; + banner->ride_index = RideId::GetNull(); banner->text = _name; } else { // If empty name take closest ride name. RideId rideIndex = banner_get_closest_ride_index({ banner->position.ToCoordsXY(), 16 }); - if (rideIndex == RIDE_ID_NULL) + if (rideIndex.IsNull()) { banner->flags &= ~BANNER_FLAG_LINKED_TO_RIDE; - banner->ride_index = RIDE_ID_NULL; + banner->ride_index = RideId::GetNull(); banner->text = {}; } else diff --git a/src/openrct2/actions/TrackDesignAction.cpp b/src/openrct2/actions/TrackDesignAction.cpp index 33e5b234b9..208f306335 100644 --- a/src/openrct2/actions/TrackDesignAction.cpp +++ b/src/openrct2/actions/TrackDesignAction.cpp @@ -122,7 +122,7 @@ GameActions::Result TrackDesignAction::Query() const } res.Cost = queryRes.Cost; - res.SetData(RideId{ RIDE_ID_NULL }); + res.SetData(RideId{ RideId::GetNull() }); return res; } diff --git a/src/openrct2/actions/TrackPlaceAction.h b/src/openrct2/actions/TrackPlaceAction.h index de933799d8..b803712b5f 100644 --- a/src/openrct2/actions/TrackPlaceAction.h +++ b/src/openrct2/actions/TrackPlaceAction.h @@ -19,7 +19,7 @@ struct TrackPlaceActionResult class TrackPlaceAction final : public GameActionBase { private: - NetworkRideId_t _rideIndex{ RIDE_ID_NULL }; + NetworkRideId_t _rideIndex{ RideId::GetNull() }; int32_t _trackType{}; ride_type_t _rideType{}; CoordsXYZD _origin; diff --git a/src/openrct2/actions/WallPlaceAction.cpp b/src/openrct2/actions/WallPlaceAction.cpp index d5d27bb3d5..4ca0298dbd 100644 --- a/src/openrct2/actions/WallPlaceAction.cpp +++ b/src/openrct2/actions/WallPlaceAction.cpp @@ -348,7 +348,7 @@ GameActions::Result WallPlaceAction::Execute() const banner->position = TileCoordsXY(_loc); RideId rideIndex = banner_get_closest_ride_index(targetLoc); - if (rideIndex != RIDE_ID_NULL) + if (!rideIndex.IsNull()) { banner->ride_index = rideIndex; banner->flags |= BANNER_FLAG_LINKED_TO_RIDE; diff --git a/src/openrct2/entity/Guest.cpp b/src/openrct2/entity/Guest.cpp index d08113c5f2..ff668e9dd3 100644 --- a/src/openrct2/entity/Guest.cpp +++ b/src/openrct2/entity/Guest.cpp @@ -1001,7 +1001,7 @@ void Guest::Tick128UpdateGuest(int32_t index) } if (State == PeepState::Walking && !OutsideOfPark && !(PeepFlags & PEEP_FLAGS_LEAVING_PARK) && GuestNumRides == 0 - && GuestHeadingToRideId == RIDE_ID_NULL) + && GuestHeadingToRideId.IsNull()) { uint32_t time_duration = gCurrentTicks - ParkEntryTime; time_duration /= 2048; @@ -1010,7 +1010,7 @@ void Guest::Tick128UpdateGuest(int32_t index) { PickRideToGoOn(); - if (GuestHeadingToRideId == RIDE_ID_NULL) + if (GuestHeadingToRideId.IsNull()) { HappinessTarget = std::max(HappinessTarget - 128, 0); peep_leave_park(this); @@ -1404,7 +1404,7 @@ void Guest::CheckIfLost() */ void Guest::CheckCantFindRide() { - if (GuestHeadingToRideId == RIDE_ID_NULL) + if (GuestHeadingToRideId.IsNull()) return; // Peeps will think "I can't find ride X" twice before giving up completely. @@ -1418,7 +1418,7 @@ void Guest::CheckCantFindRide() if (GuestIsLostCountdown != 0) return; - GuestHeadingToRideId = RIDE_ID_NULL; + GuestHeadingToRideId = RideId::GetNull(); rct_window* w = window_find_by_number(WC_PEEP, sprite_index); if (w != nullptr) @@ -1805,7 +1805,7 @@ void Guest::PickRideToGoOn() { if (State != PeepState::Walking) return; - if (GuestHeadingToRideId != RIDE_ID_NULL) + if (!GuestHeadingToRideId.IsNull()) return; if (PeepFlags & PEEP_FLAGS_LEAVING_PARK) return; @@ -1891,7 +1891,7 @@ BitSet Guest::FindRidesToGoOn() for (auto* trackElement : TileElementsView(location)) { auto rideIndex = trackElement->GetRideIndex(); - if (rideIndex != RIDE_ID_NULL) + if (!rideIndex.IsNull()) { rideConsideration[rideIndex.ToUnderlying()] = true; } @@ -2396,7 +2396,7 @@ static void peep_tried_to_enter_full_queue(Guest* peep, Ride* ride) static void peep_reset_ride_heading(Guest* peep) { - peep->GuestHeadingToRideId = RIDE_ID_NULL; + peep->GuestHeadingToRideId = RideId::GetNull(); peep->WindowInvalidateFlags |= PEEP_INVALIDATE_PEEP_ACTION; } @@ -3070,7 +3070,7 @@ static void peep_decide_whether_to_leave_park(Guest* peep) */ static void peep_leave_park(Guest* peep) { - peep->GuestHeadingToRideId = RIDE_ID_NULL; + peep->GuestHeadingToRideId = RideId::GetNull(); if (peep->PeepFlags & PEEP_FLAGS_LEAVING_PARK) { if (peep->GuestIsLostCountdown < 60) @@ -3103,7 +3103,7 @@ template static void peep_head_for_nearest_ride(Guest* peep, bool co return; if (peep->x == LOCATION_NULL) return; - if (peep->GuestHeadingToRideId != RIDE_ID_NULL) + if (!peep->GuestHeadingToRideId.IsNull()) { auto ride = get_ride(peep->GuestHeadingToRideId); if (ride != nullptr && predicate(*ride)) @@ -4940,7 +4940,7 @@ void Guest::UpdateRideLeaveExit() } } - InteractionRideIndex = RIDE_ID_NULL; + InteractionRideIndex = RideId::GetNull(); SetState(PeepState::Falling); CoordsXY targetLoc = { x, y }; @@ -5438,7 +5438,7 @@ void Guest::UpdateWalking() { InsertNewThought(PeepThoughtType::NewRide); } - if (CurrentRide == RIDE_ID_NULL) + if (CurrentRide.IsNull()) { InsertNewThought(PeepThoughtType::Scenery); } @@ -6359,7 +6359,7 @@ static bool peep_find_ride_to_look_at(Peep* peep, uint8_t edge, RideId* rideToVi *rideSeatToView = 0x02; } - *rideToView = RIDE_ID_NULL; + *rideToView = RideId::GetNull(); return true; } @@ -6476,7 +6476,7 @@ static bool peep_find_ride_to_look_at(Peep* peep, uint8_t edge, RideId* rideToVi *rideSeatToView = 0x02; } - *rideToView = RIDE_ID_NULL; + *rideToView = RideId::GetNull(); return true; } @@ -6592,7 +6592,7 @@ static bool peep_find_ride_to_look_at(Peep* peep, uint8_t edge, RideId* rideToVi *rideSeatToView = 0x02; } - *rideToView = RIDE_ID_NULL; + *rideToView = RideId::GetNull(); return true; } @@ -6775,7 +6775,7 @@ void Guest::UpdateSpriteType() bool Guest::HeadingForRideOrParkExit() const { - return (PeepFlags & PEEP_FLAGS_LEAVING_PARK) || (GuestHeadingToRideId != RIDE_ID_NULL); + return (PeepFlags & PEEP_FLAGS_LEAVING_PARK) || !GuestHeadingToRideId.IsNull(); } /** @@ -6970,7 +6970,7 @@ Guest* Guest::Generate(const CoordsXYZ& coords) peep->WalkingFrameNum = 0; peep->ActionSpriteType = PeepActionSpriteType::None; peep->PeepFlags = 0; - peep->FavouriteRide = RIDE_ID_NULL; + peep->FavouriteRide = RideId::GetNull(); peep->FavouriteRideRating = 0; const rct_sprite_bounds* spriteBounds = &GetSpriteBounds(peep->SpriteType, peep->ActionSpriteType); @@ -6982,8 +6982,8 @@ Guest* Guest::Generate(const CoordsXYZ& coords) peep->sprite_direction = 0; peep->Mass = (scenario_rand() & 0x1F) + 45; peep->PathCheckOptimisation = 0; - peep->InteractionRideIndex = RIDE_ID_NULL; - peep->PreviousRide = RIDE_ID_NULL; + peep->InteractionRideIndex = RideId::GetNull(); + peep->PreviousRide = RideId::GetNull(); std::get<0>(peep->Thoughts).type = PeepThoughtType::None; peep->WindowInvalidateFlags = 0; @@ -7089,7 +7089,7 @@ Guest* Guest::Generate(const CoordsXYZ& coords) peep->ParkEntryTime = -1; peep->ResetPathfindGoal(); peep->RemoveAllItems(); - peep->GuestHeadingToRideId = RIDE_ID_NULL; + peep->GuestHeadingToRideId = RideId::GetNull(); peep->LitterCount = 0; peep->DisgustingCount = 0; peep->VandalismSeen = 0; @@ -7405,7 +7405,7 @@ void Guest::RemoveRideFromMemory(RideId rideId) { if (CurrentRide == rideId) { - CurrentRide = RIDE_ID_NULL; + CurrentRide = RideId::GetNull(); if (TimeToStand >= 50) { // make peep stop watching the ride @@ -7455,11 +7455,11 @@ void Guest::RemoveRideFromMemory(RideId rideId) if (GuestHeadingToRideId == rideId) { - GuestHeadingToRideId = RIDE_ID_NULL; + GuestHeadingToRideId = RideId::GetNull(); } if (FavouriteRide == rideId) { - FavouriteRide = RIDE_ID_NULL; + FavouriteRide = RideId::GetNull(); } // Erase all thoughts that contain the ride. diff --git a/src/openrct2/entity/Peep.cpp b/src/openrct2/entity/Peep.cpp index eb1d23fe93..6c819d8728 100644 --- a/src/openrct2/entity/Peep.cpp +++ b/src/openrct2/entity/Peep.cpp @@ -929,9 +929,9 @@ void Peep::Update() auto* guest = As(); if (guest != nullptr) { - if (guest->PreviousRide != RIDE_ID_NULL) + if (!guest->PreviousRide.IsNull()) if (++guest->PreviousRideTimeOut >= 720) - guest->PreviousRide = RIDE_ID_NULL; + guest->PreviousRide = RideId::GetNull(); peep_update_thoughts(guest); } @@ -1022,7 +1022,7 @@ void peep_problem_warnings_update() break; case PeepThoughtType::Hungry: // 0x14 - if (peep->GuestHeadingToRideId == RIDE_ID_NULL) + if (peep->GuestHeadingToRideId.IsNull()) { hunger_counter++; break; @@ -1033,7 +1033,7 @@ void peep_problem_warnings_update() break; case PeepThoughtType::Thirsty: - if (peep->GuestHeadingToRideId == RIDE_ID_NULL) + if (peep->GuestHeadingToRideId.IsNull()) { thirst_counter++; break; @@ -1044,7 +1044,7 @@ void peep_problem_warnings_update() break; case PeepThoughtType::Toilet: - if (peep->GuestHeadingToRideId == RIDE_ID_NULL) + if (peep->GuestHeadingToRideId.IsNull()) { toilet_counter++; break; @@ -1340,7 +1340,7 @@ void Peep::FormatActionTo(Formatter& ft) const auto* guest = As(); if (guest != nullptr) { - if (guest->GuestHeadingToRideId != RIDE_ID_NULL) + if (!guest->GuestHeadingToRideId.IsNull()) { auto ride = get_ride(guest->GuestHeadingToRideId); if (ride != nullptr) @@ -1371,7 +1371,7 @@ void Peep::FormatActionTo(Formatter& ft) const ft.Add(STR_SITTING); break; case PeepState::Watching: - if (CurrentRide != RIDE_ID_NULL) + if (!CurrentRide.IsNull()) { auto ride = get_ride(CurrentRide); if (ride != nullptr) @@ -1644,7 +1644,7 @@ static bool peep_interact_with_entrance(Peep* peep, const CoordsXYE& coords, uin { // Default guest/staff behaviour attempting to enter a // ride exit is to turn around. - peep->InteractionRideIndex = RIDE_ID_NULL; + peep->InteractionRideIndex = RideId::GetNull(); peep_return_to_centre_of_tile(peep); return true; } @@ -1660,7 +1660,7 @@ static bool peep_interact_with_entrance(Peep* peep, const CoordsXYE& coords, uin { // Default staff behaviour attempting to enter a // ride entrance is to turn around. - peep->InteractionRideIndex = RIDE_ID_NULL; + peep->InteractionRideIndex = RideId::GetNull(); peep_return_to_centre_of_tile(peep); return true; } @@ -2101,7 +2101,7 @@ static void peep_interact_with_path(Peep* peep, const CoordsXYE& coords) else { // Queue got disconnected from the original ride. - guest->InteractionRideIndex = RIDE_ID_NULL; + guest->InteractionRideIndex = RideId::GetNull(); guest->RemoveFromQueue(); guest->SetState(PeepState::One); peep_footpath_move_forward(guest, { coords, tile_element }, vandalism_present); @@ -2172,7 +2172,7 @@ static void peep_interact_with_path(Peep* peep, const CoordsXYE& coords) } else { - peep->InteractionRideIndex = RIDE_ID_NULL; + peep->InteractionRideIndex = RideId::GetNull(); if (guest != nullptr && peep->State == PeepState::Queuing) { guest->RemoveFromQueue(); @@ -2272,7 +2272,7 @@ static bool peep_interact_with_shop(Peep* peep, const CoordsXYE& coords) else { if (guest->GuestHeadingToRideId == rideIndex) - guest->GuestHeadingToRideId = RIDE_ID_NULL; + guest->GuestHeadingToRideId = RideId::GetNull(); guest->ActionSpriteImageOffset = _unk_F1AEF0; guest->SetState(PeepState::Buying); guest->CurrentRide = rideIndex; @@ -2394,7 +2394,7 @@ void Peep::PerformNextAction(uint8_t& pathing_result, TileElement*& tile_result) int16_t height = abs(tile_element_height(newLoc) - z); if (height <= 3 || (Is() && height <= 32)) { - InteractionRideIndex = RIDE_ID_NULL; + InteractionRideIndex = RideId::GetNull(); if (guest != nullptr && State == PeepState::Queuing) { guest->RemoveFromQueue(); diff --git a/src/openrct2/entity/Staff.cpp b/src/openrct2/entity/Staff.cpp index b3e5a93e82..1e6f33409d 100644 --- a/src/openrct2/entity/Staff.cpp +++ b/src/openrct2/entity/Staff.cpp @@ -586,7 +586,7 @@ bool Staff::DoHandymanPathFinding() if (litterDirection != INVALID_DIRECTION && pathDirections & (1 << litterDirection)) { /// Check whether path is a queue path and connected to a ride - bool connectedQueue = (pathElement->IsQueue() && pathElement->GetRideIndex() != RIDE_ID_NULL); + bool connectedQueue = (pathElement->IsQueue() && !pathElement->GetRideIndex().IsNull()); /// When in a queue path make the probability of following litter much lower (10% instead of 90%) /// as handymen often get stuck when there is litter on a normal path next to a queue they are in uint32_t chooseRandomProbability = connectedQueue ? 0xE666 : 0x1999; @@ -783,7 +783,7 @@ Direction Staff::MechanicDirectionPath(uint8_t validDirections, PathElement* pat gPeepPathFindGoalPosition.z = location.z; gPeepPathFindIgnoreForeignQueues = false; - gPeepPathFindQueueRideIndex = RIDE_ID_NULL; + gPeepPathFindQueueRideIndex = RideId::GetNull(); #if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 PathfindLoggingEnable(this); diff --git a/src/openrct2/peep/GuestPathfinding.cpp b/src/openrct2/peep/GuestPathfinding.cpp index 784e0cf8fa..29c9501e72 100644 --- a/src/openrct2/peep/GuestPathfinding.cpp +++ b/src/openrct2/peep/GuestPathfinding.cpp @@ -294,7 +294,7 @@ static uint8_t footpath_element_next_in_direction(TileCoordsXYZ loc, PathElement if (nextTileElement->AsPath()->IsWide()) return PATH_SEARCH_WIDE; // Only queue tiles that are connected to a ride are returned as ride queues. - if (nextTileElement->AsPath()->IsQueue() && nextTileElement->AsPath()->GetRideIndex() != RIDE_ID_NULL) + if (nextTileElement->AsPath()->IsQueue() && !nextTileElement->AsPath()->GetRideIndex().IsNull()) return PATH_SEARCH_RIDE_QUEUE; return PATH_SEARCH_OTHER; @@ -756,7 +756,7 @@ static void peep_pathfind_heuristic_search( if (tileElement->IsGhost()) continue; - RideId rideIndex = RIDE_ID_NULL; + RideId rideIndex = RideId::GetNull(); switch (tileElement->GetType()) { case TileElementType::Track: @@ -859,7 +859,7 @@ static void peep_pathfind_heuristic_search( if (tileElement->AsPath()->IsQueue() && tileElement->AsPath()->GetRideIndex() != gPeepPathFindQueueRideIndex) { - if (gPeepPathFindIgnoreForeignQueues && (tileElement->AsPath()->GetRideIndex() != RIDE_ID_NULL)) + if (gPeepPathFindIgnoreForeignQueues && !tileElement->AsPath()->GetRideIndex().IsNull()) { // Path is a queue we aren't interested in /* The rideIndex will be useful for @@ -1673,7 +1673,7 @@ static int32_t GuestPathFindParkEntranceEntering(Peep* peep, uint8_t edges) gPeepPathFindGoalPosition = TileCoordsXYZ(chosenEntrance.value()); gPeepPathFindIgnoreForeignQueues = true; - gPeepPathFindQueueRideIndex = RIDE_ID_NULL; + gPeepPathFindQueueRideIndex = RideId::GetNull(); Direction chosenDirection = peep_pathfind_choose_direction(TileCoordsXYZ{ peep->NextLoc }, peep); @@ -1730,7 +1730,7 @@ static int32_t GuestPathFindPeepSpawn(Peep* peep, uint8_t edges) } gPeepPathFindIgnoreForeignQueues = true; - gPeepPathFindQueueRideIndex = RIDE_ID_NULL; + gPeepPathFindQueueRideIndex = RideId::GetNull(); direction = peep_pathfind_choose_direction(TileCoordsXYZ{ peep->NextLoc }, peep); if (direction == INVALID_DIRECTION) return guest_path_find_aimless(peep, edges); @@ -1769,7 +1769,7 @@ static int32_t GuestPathFindParkEntranceLeaving(Peep* peep, uint8_t edges) gPeepPathFindGoalPosition = entranceGoal; gPeepPathFindIgnoreForeignQueues = true; - gPeepPathFindQueueRideIndex = RIDE_ID_NULL; + gPeepPathFindQueueRideIndex = RideId::GetNull(); #if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 PathfindLoggingEnable(peep); @@ -2096,7 +2096,7 @@ int32_t guest_path_finding(Guest* peep) if (!(adjustedEdges & (1 << chosenDirection))) continue; - RideId rideIndex = RIDE_ID_NULL; + RideId rideIndex = RideId::GetNull(); auto pathSearchResult = footpath_element_destination_in_direction(loc, pathElement, chosenDirection, &rideIndex); switch (pathSearchResult) { @@ -2143,7 +2143,7 @@ int32_t guest_path_finding(Guest* peep) return GuestPathFindParkEntranceLeaving(peep, edges); } - if (peep->GuestHeadingToRideId == RIDE_ID_NULL) + if (peep->GuestHeadingToRideId.IsNull()) { #if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 if (_pathFindDebug) diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index f7789918a7..fa87bad008 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -2896,7 +2896,7 @@ namespace RCT1 } else { - dst->FavouriteRide = RIDE_ID_NULL; + dst->FavouriteRide = RideId::GetNull(); dst->FavouriteRideRating = 0; } diff --git a/src/openrct2/rct12/RCT12.cpp b/src/openrct2/rct12/RCT12.cpp index 76ce4ea95d..282a53fca8 100644 --- a/src/openrct2/rct12/RCT12.cpp +++ b/src/openrct2/rct12/RCT12.cpp @@ -490,7 +490,7 @@ ObjectEntryIndex RCTEntryIndexToOpenRCT2EntryIndex(const RCT12ObjectEntryIndex i RideId RCT12RideIdToOpenRCT2RideId(const RCT12RideId rideId) { if (rideId == RCT12_RIDE_ID_NULL) - return RIDE_ID_NULL; + return RideId::GetNull(); return RideId::FromUnderlying(rideId); } diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index 44e950a045..091ae19514 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -150,7 +150,7 @@ RideId GetNextFreeRideId() } if (result >= OpenRCT2::Limits::MaxRidesInPark) { - return RIDE_ID_NULL; + return RideId::GetNull(); } return RideId::FromUnderlying(result); } @@ -332,7 +332,7 @@ void ride_update_favourited_stat() for (auto peep : EntityList()) { - if (peep->FavouriteRide != RIDE_ID_NULL) + if (!peep->FavouriteRide.IsNull()) { auto ride = get_ride(peep->FavouriteRide); if (ride != nullptr) diff --git a/src/openrct2/ride/Ride.h b/src/openrct2/ride/Ride.h index 29137fca0e..b9a9a7a881 100644 --- a/src/openrct2/ride/Ride.h +++ b/src/openrct2/ride/Ride.h @@ -105,7 +105,7 @@ enum class RideStatus : uint8_t; */ struct Ride { - RideId id = RIDE_ID_NULL; + RideId id = RideId::GetNull(); uint8_t type = RIDE_TYPE_NULL; // pointer to static info. for example, wild mouse type is 0x36, subtype is // 0x4c. @@ -343,7 +343,7 @@ public: void FormatStatusTo(Formatter&) const; static void UpdateAll(); - static bool NameExists(std::string_view name, RideId excludeRideId = RIDE_ID_NULL); + static bool NameExists(std::string_view name, RideId excludeRideId = RideId::GetNull()); [[nodiscard]] std::unique_ptr SaveToTrackDesign(TrackDesignState& tds) const; diff --git a/src/openrct2/ride/RideTypes.h b/src/openrct2/ride/RideTypes.h index 582c661dfd..9b396666a7 100644 --- a/src/openrct2/ride/RideTypes.h +++ b/src/openrct2/ride/RideTypes.h @@ -18,8 +18,6 @@ struct Ride; -constexpr auto RIDE_ID_NULL = RideId::GetNull(); - using ride_type_t = uint16_t; /** diff --git a/src/openrct2/ride/TrackDesignSave.cpp b/src/openrct2/ride/TrackDesignSave.cpp index 7db6483723..d689349174 100644 --- a/src/openrct2/ride/TrackDesignSave.cpp +++ b/src/openrct2/ride/TrackDesignSave.cpp @@ -41,7 +41,7 @@ constexpr size_t TRACK_MAX_SAVED_TILE_ELEMENTS = 1500; constexpr int32_t TRACK_NEARBY_SCENERY_DISTANCE = 1; bool gTrackDesignSaveMode = false; -RideId gTrackDesignSaveRideIndex = RIDE_ID_NULL; +RideId gTrackDesignSaveRideIndex = RideId::GetNull(); std::vector _trackSavedTileElements; std::vector _trackSavedTileElementsDesc; diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index 98048d854a..922463bc07 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -2765,10 +2765,10 @@ static bool ride_station_can_depart_synchronised(const Ride& ride, StationIndex if (!(sv_ride->stations[sv->stationIndex].Depart & STATION_DEPART_FLAG)) { sv = _synchronisedVehicles; - RideId rideId = RIDE_ID_NULL; + RideId rideId = RideId::GetNull(); for (; sv < _lastSynchronisedVehicle; sv++) { - if (rideId == RIDE_ID_NULL) + if (rideId.IsNull()) { rideId = sv->ride_id; } diff --git a/src/openrct2/scripting/bindings/entity/ScVehicle.cpp b/src/openrct2/scripting/bindings/entity/ScVehicle.cpp index 6e3ecded33..d2f974335a 100644 --- a/src/openrct2/scripting/bindings/entity/ScVehicle.cpp +++ b/src/openrct2/scripting/bindings/entity/ScVehicle.cpp @@ -138,7 +138,7 @@ namespace OpenRCT2::Scripting int32_t ScVehicle::ride_get() const { auto vehicle = GetVehicle(); - return (vehicle != nullptr ? vehicle->ride : RIDE_ID_NULL).ToUnderlying(); + return (vehicle != nullptr ? vehicle->ride : RideId::GetNull()).ToUnderlying(); } void ScVehicle::ride_set(int32_t value) { diff --git a/src/openrct2/scripting/bindings/ride/ScRide.hpp b/src/openrct2/scripting/bindings/ride/ScRide.hpp index cc2c5e10b9..efba237088 100644 --- a/src/openrct2/scripting/bindings/ride/ScRide.hpp +++ b/src/openrct2/scripting/bindings/ride/ScRide.hpp @@ -60,7 +60,7 @@ namespace OpenRCT2::Scripting class ScRide { private: - RideId _rideId = RIDE_ID_NULL; + RideId _rideId = RideId::GetNull(); public: ScRide(RideId rideId); diff --git a/src/openrct2/scripting/bindings/ride/ScRideStation.hpp b/src/openrct2/scripting/bindings/ride/ScRideStation.hpp index c78ef5fe49..70b44217bf 100644 --- a/src/openrct2/scripting/bindings/ride/ScRideStation.hpp +++ b/src/openrct2/scripting/bindings/ride/ScRideStation.hpp @@ -21,7 +21,7 @@ namespace OpenRCT2::Scripting class ScRideStation { private: - RideId _rideId = RIDE_ID_NULL; + RideId _rideId = RideId::GetNull(); StationIndex _stationIndex{}; public: diff --git a/src/openrct2/scripting/bindings/world/ScTileElement.cpp b/src/openrct2/scripting/bindings/world/ScTileElement.cpp index d152c87d28..8bdeaf1701 100644 --- a/src/openrct2/scripting/bindings/world/ScTileElement.cpp +++ b/src/openrct2/scripting/bindings/world/ScTileElement.cpp @@ -451,7 +451,7 @@ namespace OpenRCT2::Scripting case TileElementType::Path: { auto el = _element->AsPath(); - if (el->IsQueue() && el->GetRideIndex() != RIDE_ID_NULL) + if (el->IsQueue() && !el->GetRideIndex().IsNull()) duk_push_int(ctx, el->GetRideIndex().ToUnderlying()); else duk_push_null(ctx); @@ -490,7 +490,7 @@ namespace OpenRCT2::Scripting if (value.type() == DukValue::Type::NUMBER) el->SetRideIndex(RideId::FromUnderlying(value.as_uint())); else - el->SetRideIndex(RIDE_ID_NULL); + el->SetRideIndex(RideId::GetNull()); Invalidate(); } break; @@ -528,7 +528,7 @@ namespace OpenRCT2::Scripting case TileElementType::Path: { auto el = _element->AsPath(); - if (el->IsQueue() && el->GetRideIndex() != RIDE_ID_NULL && el->GetStationIndex() != STATION_INDEX_NULL) + if (el->IsQueue() && !el->GetRideIndex().IsNull() && el->GetStationIndex() != STATION_INDEX_NULL) duk_push_int(ctx, el->GetStationIndex()); else duk_push_null(ctx); diff --git a/src/openrct2/world/Banner.cpp b/src/openrct2/world/Banner.cpp index a848e3efc8..d3b0d4b1ec 100644 --- a/src/openrct2/world/Banner.cpp +++ b/src/openrct2/world/Banner.cpp @@ -90,7 +90,7 @@ void Banner::FormatTextTo(Formatter& ft) const static RideId banner_get_ride_index_at(const CoordsXYZ& bannerCoords) { TileElement* tileElement = map_get_first_element_at(bannerCoords); - RideId resultRideIndex = RIDE_ID_NULL; + RideId resultRideIndex = RideId::GetNull(); if (tileElement == nullptr) return resultRideIndex; do @@ -210,13 +210,13 @@ RideId banner_get_closest_ride_index(const CoordsXYZ& mapPos) for (const auto& neighhbourCoords : NeighbourCheckOrder) { RideId rideIndex = banner_get_ride_index_at({ CoordsXY{ mapPos } + neighhbourCoords, mapPos.z }); - if (rideIndex != RIDE_ID_NULL) + if (!rideIndex.IsNull()) { return rideIndex; } } - auto rideIndex = RIDE_ID_NULL; + auto rideIndex = RideId::GetNull(); auto resultDistance = std::numeric_limits::max(); for (auto& ride : GetRideManager()) { @@ -366,7 +366,7 @@ void UnlinkAllRideBanners() if (!banner.IsNull()) { banner.flags &= ~BANNER_FLAG_LINKED_TO_RIDE; - banner.ride_index = RIDE_ID_NULL; + banner.ride_index = RideId::GetNull(); } } } @@ -378,7 +378,7 @@ void UnlinkAllBannersForRide(RideId rideId) if (!banner.IsNull() && (banner.flags & BANNER_FLAG_LINKED_TO_RIDE) && banner.ride_index == rideId) { banner.flags &= ~BANNER_FLAG_LINKED_TO_RIDE; - banner.ride_index = RIDE_ID_NULL; + banner.ride_index = RideId::GetNull(); banner.text = {}; } } diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index cb5d37b485..b1682c67ec 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -817,7 +817,7 @@ static void loc_6A6F1F( } else { - neighbour_list_push(neighbourList, 2, direction, RIDE_ID_NULL, 255); + neighbour_list_push(neighbourList, 2, direction, RideId::GetNull(), 255); } } else @@ -846,7 +846,7 @@ static void loc_6A6D7E( { if (query) { - neighbour_list_push(neighbourList, 7, direction, RIDE_ID_NULL, 255); + neighbour_list_push(neighbourList, 7, direction, RideId::GetNull(), 255); } loc_6A6FD2(initialTileElementPos, direction, initialTileElement, query); } @@ -1038,13 +1038,13 @@ void footpath_connect_edges(const CoordsXY& footpathPos, TileElement* tileElemen if (tileElement->GetType() == TileElementType::Path && tileElement->AsPath()->IsQueue()) { - RideId rideIndex = RIDE_ID_NULL; + RideId rideIndex = RideId::GetNull(); uint8_t entranceIndex = 255; for (size_t i = 0; i < neighbourList.count; i++) { - if (neighbourList.items[i].ride_index != RIDE_ID_NULL) + if (!neighbourList.items[i].ride_index.IsNull()) { - if (rideIndex == RIDE_ID_NULL) + if (rideIndex.IsNull()) { rideIndex = neighbourList.items[i].ride_index; entranceIndex = neighbourList.items[i].entrance_index; @@ -1189,7 +1189,7 @@ void footpath_chain_ride_queue( break; } - if (rideIndex != RIDE_ID_NULL && lastPathElement != nullptr) + if (!rideIndex.IsNull() && lastPathElement != nullptr) { if (lastPathElement->AsPath()->IsQueue()) { @@ -1212,7 +1212,7 @@ void footpath_queue_chain_reset() */ void footpath_queue_chain_push(RideId rideIndex) { - if (rideIndex != RIDE_ID_NULL) + if (!rideIndex.IsNull()) { auto* lastSlot = _footpathQueueChain + std::size(_footpathQueueChain) - 1; if (_footpathQueueChainNext <= lastSlot) @@ -2055,10 +2055,10 @@ void footpath_update_queue_entrance_banner(const CoordsXY& footpathPos, TileElem { if (tileElement->AsPath()->GetEdges() & (1 << direction)) { - footpath_chain_ride_queue(RIDE_ID_NULL, 0, footpathPos, tileElement, direction); + footpath_chain_ride_queue(RideId::GetNull(), 0, footpathPos, tileElement, direction); } } - tileElement->AsPath()->SetRideIndex(RIDE_ID_NULL); + tileElement->AsPath()->SetRideIndex(RideId::GetNull()); } } else if (elementType == TileElementType::Entrance) @@ -2067,7 +2067,7 @@ void footpath_update_queue_entrance_banner(const CoordsXY& footpathPos, TileElem { footpath_queue_chain_push(tileElement->AsEntrance()->GetRideIndex()); footpath_chain_ride_queue( - RIDE_ID_NULL, 0, footpathPos, tileElement, direction_reverse(tileElement->GetDirection())); + RideId::GetNull(), 0, footpathPos, tileElement, direction_reverse(tileElement->GetDirection())); } } } diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 6cecb6ad27..37e2598d71 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -1119,7 +1119,7 @@ void map_remove_all_rides() if (it.element->AsPath()->IsQueue()) { it.element->AsPath()->SetHasQueueBanner(false); - it.element->AsPath()->SetRideIndex(RIDE_ID_NULL); + it.element->AsPath()->SetRideIndex(RideId::GetNull()); } break; case TileElementType::Entrance: diff --git a/src/openrct2/world/TileElement.cpp b/src/openrct2/world/TileElement.cpp index 7a83557e76..6b1db199ff 100644 --- a/src/openrct2/world/TileElement.cpp +++ b/src/openrct2/world/TileElement.cpp @@ -97,7 +97,7 @@ RideId TileElement::GetRideIndex() const case TileElementType::Path: return AsPath()->GetRideIndex(); default: - return RIDE_ID_NULL; + return RideId::GetNull(); } } From 1fe6c0618b62d3b88c14c7c72ede1843b99896d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Wed, 19 Jan 2022 18:36:26 +0200 Subject: [PATCH 6/9] Fix clang format --- src/openrct2/interface/Window.h | 6 +++--- src/openrct2/peep/GuestPathfinding.cpp | 3 +-- src/openrct2/ride/Ride.cpp | 7 +++---- src/openrct2/ride/Vehicle.cpp | 4 ++-- src/openrct2/windows/_legacy.cpp | 7 +++---- src/openrct2/world/TileElement.h | 4 ++-- 6 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/openrct2/interface/Window.h b/src/openrct2/interface/Window.h index cb01175199..2ec963dad9 100644 --- a/src/openrct2/interface/Window.h +++ b/src/openrct2/interface/Window.h @@ -269,7 +269,7 @@ struct campaign_variables int16_t no_weeks; // 0x482 union { - RideId RideId; // 0x484 + RideId RideId; // 0x484 ObjectEntryIndex ShopItemId; // 0x484 }; uint32_t pad_486; @@ -858,8 +858,8 @@ void window_follow_sprite(rct_window* w, size_t spriteIndex); void window_unfollow_sprite(rct_window* w); bool window_ride_construction_update_state( - int32_t* trackType, int32_t* trackDirection, RideId* rideIndex, int32_t* _liftHillAndAlternativeState, - CoordsXYZ* trackPos, int32_t* properties); + int32_t* trackType, int32_t* trackDirection, RideId* rideIndex, int32_t* _liftHillAndAlternativeState, CoordsXYZ* trackPos, + int32_t* properties); money32 place_provisional_track_piece( RideId rideIndex, int32_t trackType, int32_t trackDirection, int32_t liftHillAndAlternativeState, const CoordsXYZ& trackPos); diff --git a/src/openrct2/peep/GuestPathfinding.cpp b/src/openrct2/peep/GuestPathfinding.cpp index 29c9501e72..fbb1c18fc9 100644 --- a/src/openrct2/peep/GuestPathfinding.cpp +++ b/src/openrct2/peep/GuestPathfinding.cpp @@ -321,8 +321,7 @@ static uint8_t footpath_element_next_in_direction(TileCoordsXYZ loc, PathElement * * This is the recursive portion of footpath_element_destination_in_direction(). */ -static uint8_t footpath_element_dest_in_dir( - TileCoordsXYZ loc, Direction chosenDirection, RideId* outRideIndex, int32_t level) +static uint8_t footpath_element_dest_in_dir(TileCoordsXYZ loc, Direction chosenDirection, RideId* outRideIndex, int32_t level) { TileElement* tileElement; Direction direction; diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index 091ae19514..d03c1aa8ad 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -3279,8 +3279,7 @@ static Vehicle* vehicle_create_car( * rct2: 0x006DD84C */ static train_ref vehicle_create_train( - RideId rideIndex, const CoordsXYZ& trainPos, int32_t vehicleIndex, int32_t* remainingDistance, - TrackElement* trackElement) + RideId rideIndex, const CoordsXYZ& trainPos, int32_t vehicleIndex, int32_t* remainingDistance, TrackElement* trackElement) { train_ref train = { nullptr, nullptr }; auto ride = get_ride(rideIndex); @@ -3993,8 +3992,8 @@ bool Ride::Open(bool isApplying) // to set the track to its final state and clean up ghosts. // We can't just call close as it would cause a stack overflow during shop creation // with auto open on. - if (WC_RIDE_CONSTRUCTION == gCurrentToolWidget.window_classification && id.ToUnderlying() == gCurrentToolWidget.window_number - && (input_test_flag(INPUT_FLAG_TOOL_ACTIVE))) + if (WC_RIDE_CONSTRUCTION == gCurrentToolWidget.window_classification + && id.ToUnderlying() == gCurrentToolWidget.window_number && (input_test_flag(INPUT_FLAG_TOOL_ACTIVE))) { window_close_by_number(WC_RIDE_CONSTRUCTION, id.ToUnderlying()); } diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index 922463bc07..c719c4801b 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -5127,8 +5127,8 @@ static void ride_train_crash(Ride* ride, uint16_t numFatalities) { ride->FormatNameTo(ft); News::AddItemToQueue( - News::ItemType::Ride, numFatalities == 1 ? STR_X_PERSON_DIED_ON_X : STR_X_PEOPLE_DIED_ON_X, ride->id.ToUnderlying(), - ft); + News::ItemType::Ride, numFatalities == 1 ? STR_X_PERSON_DIED_ON_X : STR_X_PEOPLE_DIED_ON_X, + ride->id.ToUnderlying(), ft); } if (gParkRatingCasualtyPenalty < 500) diff --git a/src/openrct2/windows/_legacy.cpp b/src/openrct2/windows/_legacy.cpp index b77c16c0c0..a5dcd72c36 100644 --- a/src/openrct2/windows/_legacy.cpp +++ b/src/openrct2/windows/_legacy.cpp @@ -44,8 +44,7 @@ bool _deferClose; * rct2: 0x006CA162 */ money32 place_provisional_track_piece( - RideId rideIndex, int32_t trackType, int32_t trackDirection, int32_t liftHillAndAlternativeState, - const CoordsXYZ& trackPos) + RideId rideIndex, int32_t trackType, int32_t trackDirection, int32_t liftHillAndAlternativeState, const CoordsXYZ& trackPos) { auto ride = get_ride(rideIndex); if (ride == nullptr) @@ -238,8 +237,8 @@ static std::tuple window_ride_construction_update_state_get_ * @return (CF) */ bool window_ride_construction_update_state( - int32_t* _trackType, int32_t* _trackDirection, RideId* _rideIndex, int32_t* _liftHillAndInvertedState, - CoordsXYZ* _trackPos, int32_t* _properties) + int32_t* _trackType, int32_t* _trackDirection, RideId* _rideIndex, int32_t* _liftHillAndInvertedState, CoordsXYZ* _trackPos, + int32_t* _properties) { RideId rideIndex; uint8_t trackDirection; diff --git a/src/openrct2/world/TileElement.h b/src/openrct2/world/TileElement.h index 57b72a4284..fa010a3b5c 100644 --- a/src/openrct2/world/TileElement.h +++ b/src/openrct2/world/TileElement.h @@ -245,7 +245,7 @@ private: union { uint8_t AdditionStatus; // 13, only used for litter bins - RideId rideIndex; // 13 + RideId rideIndex; // 13 }; ::StationIndex StationIndex; // 15 @@ -547,7 +547,7 @@ private: uint8_t SequenceIndex; // 6. Only uses the lower nibble. uint8_t StationIndex; // 7 ObjectEntryIndex PathType; // 8 - RideId rideIndex; // A + RideId rideIndex; // A uint8_t flags2; // C #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-private-field" From f4d105f843b8cddbab2fadb12fd39fab84063dd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Wed, 19 Jan 2022 19:42:17 +0200 Subject: [PATCH 7/9] Remove NetworkRideId --- src/openrct2/actions/MazePlaceTrackAction.cpp | 2 +- src/openrct2/actions/MazePlaceTrackAction.h | 4 ++-- src/openrct2/actions/MazeSetTrackAction.cpp | 3 +-- src/openrct2/actions/MazeSetTrackAction.h | 4 ++-- src/openrct2/actions/RideDemolishAction.h | 2 +- src/openrct2/actions/RideEntranceExitPlaceAction.h | 2 +- src/openrct2/actions/RideEntranceExitRemoveAction.h | 2 +- src/openrct2/actions/RideSetAppearanceAction.h | 2 +- src/openrct2/actions/RideSetNameAction.h | 2 +- src/openrct2/actions/RideSetPriceAction.h | 2 +- src/openrct2/actions/RideSetSettingAction.h | 2 +- src/openrct2/actions/RideSetStatusAction.h | 2 +- src/openrct2/actions/RideSetVehicleAction.h | 2 +- src/openrct2/actions/TrackPlaceAction.cpp | 4 ++-- src/openrct2/actions/TrackPlaceAction.h | 6 +++--- src/openrct2/network/NetworkTypes.h | 2 -- 16 files changed, 20 insertions(+), 23 deletions(-) diff --git a/src/openrct2/actions/MazePlaceTrackAction.cpp b/src/openrct2/actions/MazePlaceTrackAction.cpp index 0c596a1519..4d81ece794 100644 --- a/src/openrct2/actions/MazePlaceTrackAction.cpp +++ b/src/openrct2/actions/MazePlaceTrackAction.cpp @@ -15,7 +15,7 @@ using namespace OpenRCT2::TrackMetaData; -MazePlaceTrackAction::MazePlaceTrackAction(const CoordsXYZ& location, NetworkRideId_t rideIndex, uint16_t mazeEntry) +MazePlaceTrackAction::MazePlaceTrackAction(const CoordsXYZ& location, RideId rideIndex, uint16_t mazeEntry) : _loc(location) , _rideIndex(rideIndex) , _mazeEntry(mazeEntry) diff --git a/src/openrct2/actions/MazePlaceTrackAction.h b/src/openrct2/actions/MazePlaceTrackAction.h index cf2e9c7497..1c215220e0 100644 --- a/src/openrct2/actions/MazePlaceTrackAction.h +++ b/src/openrct2/actions/MazePlaceTrackAction.h @@ -14,12 +14,12 @@ class MazePlaceTrackAction final : public GameActionBase { private: - NetworkRideId_t _rideIndex{ RideId::GetNull() }; + RideId _rideIndex{ RideId::GetNull() }; uint8_t _modifyType{ RIDE_MODIFY_DEMOLISH }; public: diff --git a/src/openrct2/actions/RideEntranceExitPlaceAction.h b/src/openrct2/actions/RideEntranceExitPlaceAction.h index 15f8650e0f..a5ea850073 100644 --- a/src/openrct2/actions/RideEntranceExitPlaceAction.h +++ b/src/openrct2/actions/RideEntranceExitPlaceAction.h @@ -17,7 +17,7 @@ class RideEntranceExitPlaceAction final : public GameActionBase { private: - NetworkRideId_t _rideIndex{ RideId::GetNull() }; + RideId _rideIndex{ RideId::GetNull() }; RideSetAppearanceType _type{}; uint16_t _value{}; uint32_t _index{}; diff --git a/src/openrct2/actions/RideSetNameAction.h b/src/openrct2/actions/RideSetNameAction.h index 1193218df7..3dd0e93e2f 100644 --- a/src/openrct2/actions/RideSetNameAction.h +++ b/src/openrct2/actions/RideSetNameAction.h @@ -14,7 +14,7 @@ class RideSetNameAction final : public GameActionBase { private: - NetworkRideId_t _rideIndex{ RideId::GetNull() }; + RideId _rideIndex{ RideId::GetNull() }; std::string _name; public: diff --git a/src/openrct2/actions/RideSetPriceAction.h b/src/openrct2/actions/RideSetPriceAction.h index 0d0621e382..a0135a9633 100644 --- a/src/openrct2/actions/RideSetPriceAction.h +++ b/src/openrct2/actions/RideSetPriceAction.h @@ -14,7 +14,7 @@ class RideSetPriceAction final : public GameActionBase { private: - NetworkRideId_t _rideIndex{ RideId::GetNull() }; + RideId _rideIndex{ RideId::GetNull() }; money16 _price{ MONEY16_UNDEFINED }; bool _primaryPrice{ true }; diff --git a/src/openrct2/actions/RideSetSettingAction.h b/src/openrct2/actions/RideSetSettingAction.h index 18945a3823..fe8c9c49ad 100644 --- a/src/openrct2/actions/RideSetSettingAction.h +++ b/src/openrct2/actions/RideSetSettingAction.h @@ -29,7 +29,7 @@ enum class RideSetSetting : uint8_t class RideSetSettingAction final : public GameActionBase { private: - NetworkRideId_t _rideIndex{ RideId::GetNull() }; + RideId _rideIndex{ RideId::GetNull() }; RideSetSetting _setting{}; uint8_t _value{}; diff --git a/src/openrct2/actions/RideSetStatusAction.h b/src/openrct2/actions/RideSetStatusAction.h index 575b1f02dd..06b2950e2a 100644 --- a/src/openrct2/actions/RideSetStatusAction.h +++ b/src/openrct2/actions/RideSetStatusAction.h @@ -14,7 +14,7 @@ class RideSetStatusAction final : public GameActionBase { private: - NetworkRideId_t _rideIndex{ RideId::GetNull() }; + RideId _rideIndex{ RideId::GetNull() }; RideStatus _status{ RideStatus::Closed }; public: diff --git a/src/openrct2/actions/RideSetVehicleAction.h b/src/openrct2/actions/RideSetVehicleAction.h index 1b4d56a359..78278607f3 100644 --- a/src/openrct2/actions/RideSetVehicleAction.h +++ b/src/openrct2/actions/RideSetVehicleAction.h @@ -22,7 +22,7 @@ enum class RideSetVehicleType : uint8_t class RideSetVehicleAction final : public GameActionBase { private: - NetworkRideId_t _rideIndex{ RideId::GetNull() }; + RideId _rideIndex{ RideId::GetNull() }; RideSetVehicleType _type{}; uint8_t _value{}; uint8_t _colour{}; diff --git a/src/openrct2/actions/TrackPlaceAction.cpp b/src/openrct2/actions/TrackPlaceAction.cpp index 8bd29cbb21..cc859100f9 100644 --- a/src/openrct2/actions/TrackPlaceAction.cpp +++ b/src/openrct2/actions/TrackPlaceAction.cpp @@ -24,8 +24,8 @@ using namespace OpenRCT2::TrackMetaData; TrackPlaceAction::TrackPlaceAction( - NetworkRideId_t rideIndex, int32_t trackType, ride_type_t rideType, const CoordsXYZD& origin, int32_t brakeSpeed, - int32_t colour, int32_t seatRotation, int32_t liftHillAndAlternativeState, bool fromTrackDesign) + RideId rideIndex, int32_t trackType, ride_type_t rideType, const CoordsXYZD& origin, int32_t brakeSpeed, int32_t colour, + int32_t seatRotation, int32_t liftHillAndAlternativeState, bool fromTrackDesign) : _rideIndex(rideIndex) , _trackType(trackType) , _rideType(rideType) diff --git a/src/openrct2/actions/TrackPlaceAction.h b/src/openrct2/actions/TrackPlaceAction.h index b803712b5f..dfc9b55417 100644 --- a/src/openrct2/actions/TrackPlaceAction.h +++ b/src/openrct2/actions/TrackPlaceAction.h @@ -19,7 +19,7 @@ struct TrackPlaceActionResult class TrackPlaceAction final : public GameActionBase { private: - NetworkRideId_t _rideIndex{ RideId::GetNull() }; + RideId _rideIndex{ RideId::GetNull() }; int32_t _trackType{}; ride_type_t _rideType{}; CoordsXYZD _origin; @@ -32,8 +32,8 @@ private: public: TrackPlaceAction() = default; TrackPlaceAction( - NetworkRideId_t rideIndex, int32_t trackType, ride_type_t rideType, const CoordsXYZD& origin, int32_t brakeSpeed, - int32_t colour, int32_t seatRotation, int32_t liftHillAndAlternativeState, bool fromTrackDesign); + RideId rideIndex, int32_t trackType, ride_type_t rideType, const CoordsXYZD& origin, int32_t brakeSpeed, int32_t colour, + int32_t seatRotation, int32_t liftHillAndAlternativeState, bool fromTrackDesign); void AcceptParameters(GameActionParameterVisitor& visitor) override; diff --git a/src/openrct2/network/NetworkTypes.h b/src/openrct2/network/NetworkTypes.h index 71c81beeb6..5ddb69fccd 100644 --- a/src/openrct2/network/NetworkTypes.h +++ b/src/openrct2/network/NetworkTypes.h @@ -126,8 +126,6 @@ template struct NetworkObjectId_t }; #pragma pack(pop) -using NetworkRideId_t = RideId; - // NOTE: When adding new types make sure to have no duplicate _TypeID's otherwise // there is no way to specialize templates if they have the exact symbol. using NetworkPlayerId_t = NetworkObjectId_t; From f22142d2cfa6a089ef18d70b4dcd71c5cf03e506 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Fri, 21 Jan 2022 14:57:15 +0200 Subject: [PATCH 8/9] Use RideId::GetNull over SELECTED_RIDE_UNDEFINED --- src/openrct2-ui/windows/NewCampaign.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/openrct2-ui/windows/NewCampaign.cpp b/src/openrct2-ui/windows/NewCampaign.cpp index d5f23b79be..c04707b059 100644 --- a/src/openrct2-ui/windows/NewCampaign.cpp +++ b/src/openrct2-ui/windows/NewCampaign.cpp @@ -27,7 +27,6 @@ static constexpr const rct_string_id WINDOW_TITLE = STR_NONE; static constexpr const int32_t WH = 109; static constexpr const int32_t WW = 350; -constexpr auto SELECTED_RIDE_UNDEFINED = RideId::GetNull(); constexpr uint16_t SELECTED_ITEM_UNDEFINED = 0xFFFF; // clang-format off @@ -173,7 +172,7 @@ public: campaign.no_weeks = 2; // Currently selected ride - campaign.RideId = SELECTED_RIDE_UNDEFINED; + campaign.RideId = RideId::GetNull(); RefreshRides(); } @@ -312,7 +311,7 @@ public: widgets[WIDX_RIDE_DROPDOWN].type = WindowWidgetType::DropdownMenu; widgets[WIDX_RIDE_DROPDOWN_BUTTON].type = WindowWidgetType::Button; widgets[WIDX_RIDE_LABEL].text = STR_MARKETING_RIDE; - if (campaign.RideId != SELECTED_RIDE_UNDEFINED) + if (campaign.RideId != RideId::GetNull()) { auto curRide = get_ride(campaign.RideId); if (curRide != nullptr) @@ -341,7 +340,7 @@ public: // Enable / disable start button based on ride dropdown WidgetSetDisabled(this, WIDX_START_BUTTON, false); - if (widgets[WIDX_RIDE_DROPDOWN].type == WindowWidgetType::DropdownMenu && campaign.RideId == SELECTED_RIDE_UNDEFINED) + if (widgets[WIDX_RIDE_DROPDOWN].type == WindowWidgetType::DropdownMenu && campaign.RideId == RideId::GetNull()) WidgetSetDisabled(this, WIDX_START_BUTTON, true); } From 004cf02c26a0c2490baacd3db1ceb7e4d66c21a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Sat, 12 Feb 2022 18:15:19 +0200 Subject: [PATCH 9/9] Fix variable name type conflict --- src/openrct2/interface/Window.h | 4 ++-- src/openrct2/management/Marketing.h | 2 +- src/openrct2/ride/RideAudio.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/openrct2/interface/Window.h b/src/openrct2/interface/Window.h index 2ec963dad9..f4c0049b4a 100644 --- a/src/openrct2/interface/Window.h +++ b/src/openrct2/interface/Window.h @@ -269,8 +269,8 @@ struct campaign_variables int16_t no_weeks; // 0x482 union { - RideId RideId; // 0x484 - ObjectEntryIndex ShopItemId; // 0x484 + ::RideId RideId; + ObjectEntryIndex ShopItemId; }; uint32_t pad_486; }; diff --git a/src/openrct2/management/Marketing.h b/src/openrct2/management/Marketing.h index 0ea501010f..42962b9307 100644 --- a/src/openrct2/management/Marketing.h +++ b/src/openrct2/management/Marketing.h @@ -50,7 +50,7 @@ struct MarketingCampaign uint8_t Flags{}; union { - RideId RideId{}; + ::RideId RideId{}; ShopItemIndex ShopItemType; }; }; diff --git a/src/openrct2/ride/RideAudio.cpp b/src/openrct2/ride/RideAudio.cpp index fa2af9bb85..46e5fdf9d8 100644 --- a/src/openrct2/ride/RideAudio.cpp +++ b/src/openrct2/ride/RideAudio.cpp @@ -35,7 +35,7 @@ namespace OpenRCT2::RideAudio */ struct ViewportRideMusicInstance { - RideId RideId; + ::RideId RideId; uint8_t TrackIndex{}; size_t Offset{}; @@ -49,7 +49,7 @@ namespace OpenRCT2::RideAudio */ struct RideMusicChannel { - RideId RideId{}; + ::RideId RideId{}; uint8_t TrackIndex{}; size_t Offset{};