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(); } }