Use RideId::GetNull and RideId::IsNull over constant

This commit is contained in:
ζeh Matt committed 2022-02-12 18:11:18 +02:00
1 parent 4554d6d883
commit 06e430157f
41 files changed
+102 -104

No files matched your search

+1 -1
View File
@@ -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
+1 -1
View File
@@ -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)
+2 -2
View File
@@ -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();
+1 -1
View File
@@ -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);
@@ -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);
@@ -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;
+1 -1
View File
@@ -14,7 +14,7 @@ class MazePlaceTrackAction final : public GameActionBase<GameCommand::PlaceMazeD
{
private:
CoordsXYZ _loc;
NetworkRideId_t _rideIndex{ RIDE_ID_NULL };
NetworkRideId_t _rideIndex{ RideId::GetNull() };
uint16_t _mazeEntry{};
public:
+1 -1
View File
@@ -42,7 +42,7 @@ class MazeSetTrackAction final : public GameActionBase<GameCommand::SetMazeTrack
private:
CoordsXYZD _loc;
bool _initialPlacement{};
NetworkRideId_t _rideIndex{ RIDE_ID_NULL };
NetworkRideId_t _rideIndex{ RideId::GetNull() };
uint8_t _mode{};
public:
+1 -1
View File
@@ -71,7 +71,7 @@ void RideCreateAction::Serialise(DataSerialiser& stream)
GameActions::Result RideCreateAction::Query() const
{
auto rideIndex = GetNextFreeRideId();
if (rideIndex == RIDE_ID_NULL)
if (rideIndex.IsNull())
{
// No more free slots available.
return GameActions::Result(
+1 -1
View File
@@ -14,7 +14,7 @@
class RideDemolishAction final : public GameActionBase<GameCommand::DemolishRide>
{
private:
NetworkRideId_t _rideIndex{ RIDE_ID_NULL };
NetworkRideId_t _rideIndex{ RideId::GetNull() };
uint8_t _modifyType{ RIDE_MODIFY_DEMOLISH };
public:
@@ -17,7 +17,7 @@ class RideEntranceExitPlaceAction final : public GameActionBase<GameCommand::Pla
private:
CoordsXY _loc;
Direction _direction{ INVALID_DIRECTION };
NetworkRideId_t _rideIndex{ RIDE_ID_NULL };
NetworkRideId_t _rideIndex{ RideId::GetNull() };
StationIndex _stationNum{ STATION_INDEX_NULL };
bool _isExit{};
@@ -15,7 +15,7 @@ class RideEntranceExitRemoveAction final : public GameActionBase<GameCommand::Re
{
private:
CoordsXY _loc;
NetworkRideId_t _rideIndex{ RIDE_ID_NULL };
NetworkRideId_t _rideIndex{ RideId::GetNull() };
StationIndex _stationNum{ STATION_INDEX_NULL };
bool _isExit{};
@@ -27,7 +27,7 @@ enum class RideSetAppearanceType : uint8_t
class RideSetAppearanceAction final : public GameActionBase<GameCommand::SetRideAppearance>
{
private:
NetworkRideId_t _rideIndex{ RIDE_ID_NULL };
NetworkRideId_t _rideIndex{ RideId::GetNull() };
RideSetAppearanceType _type{};
uint16_t _value{};
uint32_t _index{};
+1 -1
View File
@@ -14,7 +14,7 @@
class RideSetNameAction final : public GameActionBase<GameCommand::SetRideName>
{
private:
NetworkRideId_t _rideIndex{ RIDE_ID_NULL };
NetworkRideId_t _rideIndex{ RideId::GetNull() };
std::string _name;
public:
+1 -1
View File
@@ -14,7 +14,7 @@
class RideSetPriceAction final : public GameActionBase<GameCommand::SetRidePrice>
{
private:
NetworkRideId_t _rideIndex{ RIDE_ID_NULL };
NetworkRideId_t _rideIndex{ RideId::GetNull() };
money16 _price{ MONEY16_UNDEFINED };
bool _primaryPrice{ true };
+1 -1
View File
@@ -29,7 +29,7 @@ enum class RideSetSetting : uint8_t
class RideSetSettingAction final : public GameActionBase<GameCommand::SetRideSetting>
{
private:
NetworkRideId_t _rideIndex{ RIDE_ID_NULL };
NetworkRideId_t _rideIndex{ RideId::GetNull() };
RideSetSetting _setting{};
uint8_t _value{};
+1 -1
View File
@@ -14,7 +14,7 @@
class RideSetStatusAction final : public GameActionBase<GameCommand::SetRideStatus>
{
private:
NetworkRideId_t _rideIndex{ RIDE_ID_NULL };
NetworkRideId_t _rideIndex{ RideId::GetNull() };
RideStatus _status{ RideStatus::Closed };
public:
+1 -1
View File
@@ -22,7 +22,7 @@ enum class RideSetVehicleType : uint8_t
class RideSetVehicleAction final : public GameActionBase<GameCommand::SetRideVehicles>
{
private:
NetworkRideId_t _rideIndex{ RIDE_ID_NULL };
NetworkRideId_t _rideIndex{ RideId::GetNull() };
RideSetVehicleType _type{};
uint8_t _value{};
uint8_t _colour{};
+3 -3
View File
@@ -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
+1 -1
View File
@@ -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;
}
+1 -1
View File
@@ -19,7 +19,7 @@ struct TrackPlaceActionResult
class TrackPlaceAction final : public GameActionBase<GameCommand::PlaceTrack>
{
private:
NetworkRideId_t _rideIndex{ RIDE_ID_NULL };
NetworkRideId_t _rideIndex{ RideId::GetNull() };
int32_t _trackType{};
ride_type_t _rideType{};
CoordsXYZD _origin;
+1 -1
View File
@@ -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;
+22 -22
View File
@@ -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<OpenRCT2::Limits::MaxRidesInPark> Guest::FindRidesToGoOn()
for (auto* trackElement : TileElementsView<TrackElement>(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<typename T> 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.
+13 -13
View File
@@ -929,9 +929,9 @@ void Peep::Update()
auto* guest = As<Guest>();
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<Guest>();
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<rct_string_id>(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<Staff>() && height <= 32))
{
InteractionRideIndex = RIDE_ID_NULL;
InteractionRideIndex = RideId::GetNull();
if (guest != nullptr && State == PeepState::Queuing)
{
guest->RemoveFromQueue();
+2 -2
View File
@@ -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);
+8 -8
View File
@@ -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)
+1 -1
View File
@@ -2896,7 +2896,7 @@ namespace RCT1
}
else
{
dst->FavouriteRide = RIDE_ID_NULL;
dst->FavouriteRide = RideId::GetNull();
dst->FavouriteRideRating = 0;
}
+1 -1
View File
@@ -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);
}
+2 -2
View File
@@ -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<Guest>())
{
if (peep->FavouriteRide != RIDE_ID_NULL)
if (!peep->FavouriteRide.IsNull())
{
auto ride = get_ride(peep->FavouriteRide);
if (ride != nullptr)
+2 -2
View File
@@ -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<TrackDesign> SaveToTrackDesign(TrackDesignState& tds) const;
-2
View File
@@ -18,8 +18,6 @@
struct Ride;
constexpr auto RIDE_ID_NULL = RideId::GetNull();
using ride_type_t = uint16_t;
/**
+1 -1
View File
@@ -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<const TileElement*> _trackSavedTileElements;
std::vector<TrackDesignSceneryElement> _trackSavedTileElementsDesc;
+2 -2
View File
@@ -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;
}
@@ -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)
{
@@ -60,7 +60,7 @@ namespace OpenRCT2::Scripting
class ScRide
{
private:
RideId _rideId = RIDE_ID_NULL;
RideId _rideId = RideId::GetNull();
public:
ScRide(RideId rideId);
@@ -21,7 +21,7 @@ namespace OpenRCT2::Scripting
class ScRideStation
{
private:
RideId _rideId = RIDE_ID_NULL;
RideId _rideId = RideId::GetNull();
StationIndex _stationIndex{};
public:
@@ -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);
+5 -5
View File
@@ -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<int32_t>::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 = {};
}
}
+10 -10
View File
@@ -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()));
}
}
}
+1 -1
View File
@@ -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:
+1 -1
View File
@@ -97,7 +97,7 @@ RideId TileElement::GetRideIndex() const
case TileElementType::Path:
return AsPath()->GetRideIndex();
default:
return RIDE_ID_NULL;
return RideId::GetNull();
}
}