diff --git a/src/openrct2/entity/Guest.cpp b/src/openrct2/entity/Guest.cpp index 2b23849397..69f9a35252 100644 --- a/src/openrct2/entity/Guest.cpp +++ b/src/openrct2/entity/Guest.cpp @@ -443,25 +443,27 @@ static constexpr ride_rating kNauseaMinimumThresholds[] = { 400, }; -static bool PeepHasVoucherForFreeRide(Guest* peep, const Ride& ride); -static void PeepRideIsTooIntense(Guest* peep, Ride& ride, bool peepAtRide); -static void PeepResetRideHeading(Guest* peep); -static void PeepTriedToEnterFullQueue(Guest* peep, Ride& ride); -static int16_t PeepCalculateRideSatisfaction(Guest* peep, const Ride& ride); -static void GuestUpdateFavouriteRide(Guest& peep, const Ride& ride, const uint8_t satisfaction); -static int16_t PeepCalculateRideValueSatisfaction(Guest* peep, const Ride& ride); -static int16_t PeepCalculateRideIntensityNauseaSatisfaction(Guest* peep, const Ride& ride); -static void PeepUpdateRideNauseaGrowth(Guest* peep, const Ride& ride); -static bool PeepShouldGoOnRideAgain(Guest* peep, const Ride& ride); -static bool PeepShouldPreferredIntensityIncrease(Guest* peep); -static bool PeepReallyLikedRide(Guest* peep, const Ride& ride); +static bool PeepHasVoucherForFreeRide(Guest& guest, const Ride& ride); +static void PeepRideIsTooIntense(Guest& guest, Ride& ride, bool peepAtRide); +static void PeepResetRideHeading(Guest& guest); +static void PeepTriedToEnterFullQueue(Guest& guest, Ride& ride); +static int16_t PeepCalculateRideSatisfaction(Guest& guest, const Ride& ride); +static void GuestUpdateFavouriteRide(Guest& guest, const Ride& ride, const uint8_t satisfaction); +static int16_t PeepCalculateRideValueSatisfaction(Guest& guest, const Ride& ride); +static int16_t PeepCalculateRideIntensityNauseaSatisfaction(Guest& guest, const Ride& ride); +static void PeepUpdateRideNauseaGrowth(Guest& guest, const Ride& ride); +static bool PeepShouldGoOnRideAgain(Guest& guest, const Ride& ride); +static bool PeepShouldPreferredIntensityIncrease(Guest& guest); +static bool PeepReallyLikedRide(Guest& guest, const Ride& ride); static PeepThoughtType PeepAssessSurroundings(int16_t centre_x, int16_t centre_y, int16_t centre_z); -static void PeepUpdateHunger(Guest* peep); -static void PeepDecideWhetherToLeavePark(Guest* peep); -static void PeepLeavePark(Guest* peep); -static void PeepHeadForNearestRideWithFlag(Guest* peep, bool considerOnlyCloseRides, RtdFlag rtdFlag); +static void PeepUpdateHunger(Guest& guest); +static void PeepDecideWhetherToLeavePark(Guest& guest); +static void PeepLeavePark(Guest& guest); +static void PeepHeadForNearestRideWithFlag(Guest& guest, bool considerOnlyCloseRides, RtdFlag rtdFlag); static void GuestHeadForNearestRideWithSpecialType(Guest& guest, bool considerOnlyCloseRides, RtdSpecialType specialType); -bool Loc690FD0(Peep* peep, RideId* rideToView, uint8_t* rideSeatToView, TileElement* tileElement); +static bool Loc690FD0(Guest& guest, RideId* rideToView, uint8_t* rideSeatToView, TileElement* tileElement); +static void PeepUpdateWalkingBreakScenery(Guest& guest); +static bool PeepFindRideToLookAt(Guest& guest, uint8_t edge, RideId* rideToView, uint8_t* rideSeatToView); template<> bool EntityBase::Is() const @@ -1049,8 +1051,8 @@ void Guest::Tick128UpdateGuest(uint32_t index) if (GuestHeadingToRideId.IsNull()) { HappinessTarget = std::max(HappinessTarget - 128, 0); - PeepLeavePark(this); - PeepUpdateHunger(this); + PeepLeavePark(*this); + PeepUpdateHunger(*this); UpdateMotivesIdle(); UpdateConsumptionMotives(); return; @@ -1125,10 +1127,10 @@ void Guest::Tick128UpdateGuest(uint32_t index) switch (chosen_thought) { case PeepThoughtType::Hungry: - PeepHeadForNearestRideWithFlag(this, false, RtdFlag::sellsFood); + PeepHeadForNearestRideWithFlag(*this, false, RtdFlag::sellsFood); break; case PeepThoughtType::Thirsty: - PeepHeadForNearestRideWithFlag(this, false, RtdFlag::sellsDrinks); + PeepHeadForNearestRideWithFlag(*this, false, RtdFlag::sellsDrinks); break; case PeepThoughtType::Toilet: GuestHeadForNearestRideWithSpecialType(*this, false, RtdSpecialType::toilet); @@ -1165,8 +1167,8 @@ void Guest::Tick128UpdateGuest(uint32_t index) case PeepState::Walking: case PeepState::LeavingPark: case PeepState::EnteringPark: - PeepDecideWhetherToLeavePark(this); - PeepUpdateHunger(this); + PeepDecideWhetherToLeavePark(*this); + PeepUpdateHunger(*this); break; case PeepState::Sitting: @@ -1185,7 +1187,7 @@ void Guest::Tick128UpdateGuest(uint32_t index) // In the original this branched differently // but it would mean setting the peep happiness from // a thought type entry which i think is incorrect. - PeepUpdateHunger(this); + PeepUpdateHunger(*this); break; case PeepState::Queuing: @@ -1230,14 +1232,14 @@ void Guest::Tick128UpdateGuest(uint32_t index) HappinessTarget = std::max(HappinessTarget - 4, 0); } } - PeepUpdateHunger(this); + PeepUpdateHunger(*this); break; case PeepState::EnteringRide: if (SubState == 17 || SubState == 15) { - PeepDecideWhetherToLeavePark(this); + PeepDecideWhetherToLeavePark(*this); } - PeepUpdateHunger(this); + PeepUpdateHunger(*this); break; default: break; @@ -1754,7 +1756,7 @@ bool Guest::DecideAndBuyItem(Ride& ride, const ShopItem shopItem, money64 price) void Guest::OnEnterRide(Ride& ride) { // Calculate how satisfying the ride is for the peep. Can range from -140 to +105. - int16_t satisfaction = PeepCalculateRideSatisfaction(this, ride); + int16_t satisfaction = PeepCalculateRideSatisfaction(*this, ride); // Update the satisfaction stat of the ride. uint8_t rideSatisfaction = 0; @@ -1774,7 +1776,7 @@ void Guest::OnEnterRide(Ride& ride) SetHasRidden(ride); GuestUpdateFavouriteRide(*this, ride, satisfaction); HappinessTarget = std::clamp(HappinessTarget + satisfaction, 0, kPeepMaxHappiness); - PeepUpdateRideNauseaGrowth(this, ride); + PeepUpdateRideNauseaGrowth(*this, ride); } /** @@ -1797,7 +1799,7 @@ void Guest::OnExitRide(Ride& ride) if (PeepFlags & PEEP_FLAGS_LEAVING_PARK) PeepFlags &= ~(PEEP_FLAGS_PARK_ENTRANCE_CHOSEN); - if (PeepShouldGoOnRideAgain(this, ride)) + if (PeepShouldGoOnRideAgain(*this, ride)) { GuestHeadingToRideId = ride.id; GuestIsLostCountdown = 200; @@ -1805,7 +1807,7 @@ void Guest::OnExitRide(Ride& ride) WindowInvalidateFlags |= PEEP_INVALIDATE_PEEP_ACTION; } - if (PeepShouldPreferredIntensityIncrease(this)) + if (PeepShouldPreferredIntensityIncrease(*this)) { if (Intensity.GetMaximum() < 15) { @@ -1813,7 +1815,7 @@ void Guest::OnExitRide(Ride& ride) } } - if (PeepReallyLikedRide(this, ride)) + if (PeepReallyLikedRide(*this, ride)) { InsertNewThought(PeepThoughtType::WasGreat, ride.id); @@ -1989,7 +1991,7 @@ bool Guest::ShouldGoOnRide(Ride& ride, StationIndex entranceNum, bool atQueue, b { if (!station.LastPeepInQueue.IsNull()) { - PeepTriedToEnterFullQueue(this, ride); + PeepTriedToEnterFullQueue(*this, ride); return false; } } @@ -2007,14 +2009,14 @@ bool Guest::ShouldGoOnRide(Ride& ride, StationIndex entranceNum, bool atQueue, b // This check enforces a minimum distance between peeps entering the queue. if (maxD < 8) { - PeepTriedToEnterFullQueue(this, ride); + PeepTriedToEnterFullQueue(*this, ride); return false; } // This checks if there's a peep standing still at the very end of the queue. if (maxD <= 13 && lastPeepInQueue->TimeInQueue > 10) { - PeepTriedToEnterFullQueue(this, ride); + PeepTriedToEnterFullQueue(*this, ride); return false; } } @@ -2035,7 +2037,7 @@ bool Guest::ShouldGoOnRide(Ride& ride, StationIndex entranceNum, bool atQueue, b auto& gameState = getGameState(); // Basic price checks - if (ridePrice != 0 && !PeepHasVoucherForFreeRide(this, ride) && !(gameState.park.Flags & PARK_FLAGS_NO_MONEY)) + if (ridePrice != 0 && !PeepHasVoucherForFreeRide(*this, ride) && !(gameState.park.Flags & PARK_FLAGS_NO_MONEY)) { if (ridePrice > CashInPocket) { @@ -2079,7 +2081,7 @@ bool Guest::ShouldGoOnRide(Ride& ride, StationIndex entranceNum, bool atQueue, b { if (ride.ratings.intensity > MakeRideRating(10, 00) && !getGameState().cheats.ignoreRideIntensity) { - PeepRideIsTooIntense(this, ride, peepAtRide); + PeepRideIsTooIntense(*this, ride, peepAtRide); return false; } } @@ -2127,7 +2129,7 @@ bool Guest::ShouldGoOnRide(Ride& ride, StationIndex entranceNum, bool atQueue, b } if (ride.ratings.intensity > maxIntensity) { - PeepRideIsTooIntense(this, ride, peepAtRide); + PeepRideIsTooIntense(*this, ride, peepAtRide); return false; } @@ -2184,7 +2186,7 @@ bool Guest::ShouldGoOnRide(Ride& ride, StationIndex entranceNum, bool atQueue, b money64 value = ride.value; // If the value of the ride hasn't yet been calculated, peeps will be willing to pay any amount for the ride. - if (value != kRideValueUndefined && !PeepHasVoucherForFreeRide(this, ride) + if (value != kRideValueUndefined && !PeepHasVoucherForFreeRide(*this, ride) && !(gameState.park.Flags & PARK_FLAGS_NO_MONEY)) { // The amount peeps are willing to pay is decreased by 75% if they had to pay to enter the park. @@ -2230,7 +2232,7 @@ bool Guest::ShouldGoOnRide(Ride& ride, StationIndex entranceNum, bool atQueue, b if (ride.id == GuestHeadingToRideId) { - PeepResetRideHeading(this); + PeepResetRideHeading(*this); } ride.lifecycleFlags &= ~RIDE_LIFECYCLE_QUEUE_FULL; @@ -2310,7 +2312,7 @@ bool Guest::ShouldGoToShop(Ride& ride, bool peepAtShop) ride.updatePopularity(1); if (ride.id == GuestHeadingToRideId) { - PeepResetRideHeading(this); + PeepResetRideHeading(*this); } } return true; @@ -2408,7 +2410,7 @@ void Guest::ChoseNotToGoOnRide(const Ride& ride, bool peepAtRide, bool updateLas if (ride.id == GuestHeadingToRideId) { - PeepResetRideHeading(this); + PeepResetRideHeading(*this); } } @@ -2423,9 +2425,9 @@ void Guest::ReadMap() } } -static bool PeepHasVoucherForFreeRide(Guest* peep, const Ride& ride) +static bool PeepHasVoucherForFreeRide(Guest& guest, const Ride& ride) { - return peep->HasItem(ShopItem::Voucher) && peep->VoucherType == VOUCHER_TYPE_RIDE_FREE && peep->VoucherRideId == ride.id; + return guest.HasItem(ShopItem::Voucher) && guest.VoucherType == VOUCHER_TYPE_RIDE_FREE && guest.VoucherRideId == ride.id; } /** @@ -2433,43 +2435,43 @@ static bool PeepHasVoucherForFreeRide(Guest* peep, const Ride& ride) * Does not effect peeps that walk up to the queue entrance. * This flag is reset the next time a peep successfully joins the queue. */ -static void PeepTriedToEnterFullQueue(Guest* peep, Ride& ride) +static void PeepTriedToEnterFullQueue(Guest& guest, Ride& ride) { ride.lifecycleFlags |= RIDE_LIFECYCLE_QUEUE_FULL; - peep->PreviousRide = ride.id; - peep->PreviousRideTimeOut = 0; + guest.PreviousRide = ride.id; + guest.PreviousRideTimeOut = 0; // Change status "Heading to" to "Walking" if queue is full - if (ride.id == peep->GuestHeadingToRideId) + if (ride.id == guest.GuestHeadingToRideId) { - PeepResetRideHeading(peep); + PeepResetRideHeading(guest); } } -static void PeepResetRideHeading(Guest* peep) +static void PeepResetRideHeading(Guest& guest) { - peep->GuestHeadingToRideId = RideId::GetNull(); - peep->WindowInvalidateFlags |= PEEP_INVALIDATE_PEEP_ACTION; + guest.GuestHeadingToRideId = RideId::GetNull(); + guest.WindowInvalidateFlags |= PEEP_INVALIDATE_PEEP_ACTION; } -static void PeepRideIsTooIntense(Guest* peep, Ride& ride, bool peepAtRide) +static void PeepRideIsTooIntense(Guest& guest, Ride& ride, bool peepAtRide) { if (peepAtRide) { - peep->InsertNewThought(PeepThoughtType::Intense, ride.id); - if (peep->HappinessTarget >= 64) + guest.InsertNewThought(PeepThoughtType::Intense, ride.id); + if (guest.HappinessTarget >= 64) { - peep->HappinessTarget -= 8; + guest.HappinessTarget -= 8; } ride.updatePopularity(0); } - peep->ChoseNotToGoOnRide(ride, peepAtRide, true); + guest.ChoseNotToGoOnRide(ride, peepAtRide, true); } /** * * rct2: 0x00691C6E */ -static Vehicle* PeepChooseCarFromRide(Peep* peep, const Ride& ride, std::span carArray) +static Vehicle* PeepChooseCarFromRide(Guest& guest, const Ride& ride, std::span carArray) { uint8_t chosen_car = ScenarioRand(); if (ride.getRideTypeDescriptor().HasFlag(RtdFlag::hasGForces) && ((chosen_car & 0xC) != 0xC)) @@ -2481,21 +2483,21 @@ static Vehicle* PeepChooseCarFromRide(Peep* peep, const Ride& ride, std::span(carArray.size())) >> 8; } - peep->CurrentCar = carArray[chosen_car]; + guest.CurrentCar = carArray[chosen_car]; - Vehicle* vehicle = GetEntity(ride.vehicles[peep->CurrentTrain]); + Vehicle* vehicle = GetEntity(ride.vehicles[guest.CurrentTrain]); if (vehicle == nullptr) { return nullptr; } - return vehicle->GetCar(peep->CurrentCar); + return vehicle->GetCar(guest.CurrentCar); } /** * * rct2: 0x00691CD1 */ -static void PeepChooseSeatFromCar(Peep* peep, const Ride& ride, Vehicle* vehicle) +static void PeepChooseSeatFromCar(Guest* guest, const Ride& ride, Vehicle* vehicle) { if (vehicle == nullptr) { @@ -2511,11 +2513,11 @@ static void PeepChooseSeatFromCar(Peep* peep, const Ride& ride, Vehicle* vehicle chosen_seat++; } } - peep->CurrentSeat = chosen_seat; + guest->CurrentSeat = chosen_seat; vehicle->next_free_seat++; - vehicle->peep[peep->CurrentSeat] = peep->Id; - vehicle->peep_tshirt_colours[peep->CurrentSeat] = peep->TshirtColour; + vehicle->peep[guest->CurrentSeat] = guest->Id; + vehicle->peep_tshirt_colours[guest->CurrentSeat] = guest->TshirtColour; } /** @@ -2630,40 +2632,40 @@ static bool FindVehicleToEnter( return !car_array.empty(); } -static void PeepUpdateRideAtEntranceTryLeave(Guest* peep) +static void PeepUpdateRideAtEntranceTryLeave(Guest& guest) { // Destination Tolerance is zero when peep has completely // entered entrance - if (peep->DestinationTolerance == 0) + if (guest.DestinationTolerance == 0) { - peep->RemoveFromQueue(); - peep->SetState(PeepState::Falling); + guest.RemoveFromQueue(); + guest.SetState(PeepState::Falling); } } -static bool PeepCheckRidePriceAtEntrance(Guest* peep, const Ride& ride, money64 ridePrice) +static bool PeepCheckRidePriceAtEntrance(Guest& guest, const Ride& ride, money64 ridePrice) { - if ((peep->HasItem(ShopItem::Voucher)) && peep->VoucherType == VOUCHER_TYPE_RIDE_FREE - && peep->VoucherRideId == peep->CurrentRide) + if ((guest.HasItem(ShopItem::Voucher)) && guest.VoucherType == VOUCHER_TYPE_RIDE_FREE + && guest.VoucherRideId == guest.CurrentRide) return true; - if (peep->CashInPocket <= 0 && !(getGameState().park.Flags & PARK_FLAGS_NO_MONEY)) + if (guest.CashInPocket <= 0 && !(getGameState().park.Flags & PARK_FLAGS_NO_MONEY)) { - peep->InsertNewThought(PeepThoughtType::SpentMoney); - PeepUpdateRideAtEntranceTryLeave(peep); + guest.InsertNewThought(PeepThoughtType::SpentMoney); + PeepUpdateRideAtEntranceTryLeave(guest); return false; } - if (ridePrice > peep->CashInPocket) + if (ridePrice > guest.CashInPocket) { // Prevent looping of same thought / animation since Destination Tolerance // is only 0 exactly at entrance and will immediately change as guest // tries to leave hereafter - if (peep->DestinationTolerance == 0) + if (guest.DestinationTolerance == 0) { - peep->InsertNewThought(PeepThoughtType::CantAffordRide, peep->CurrentRide); + guest.InsertNewThought(PeepThoughtType::CantAffordRide, guest.CurrentRide); } - PeepUpdateRideAtEntranceTryLeave(peep); + PeepUpdateRideAtEntranceTryLeave(guest); return false; } @@ -2672,8 +2674,8 @@ static bool PeepCheckRidePriceAtEntrance(Guest* peep, const Ride& ride, money64 { if (((value * 2) < ridePrice) && !(getGameState().cheats.ignorePrice)) { - peep->InsertNewThought(PeepThoughtType::BadValue, peep->CurrentRide); - PeepUpdateRideAtEntranceTryLeave(peep); + guest.InsertNewThought(PeepThoughtType::BadValue, guest.CurrentRide); + PeepUpdateRideAtEntranceTryLeave(guest); return false; } } @@ -2688,27 +2690,27 @@ static bool PeepCheckRidePriceAtEntrance(Guest* peep, const Ride& ride, money64 * - How long the peep was waiting in the queue * - If the peep has been on the ride before, or on another ride of the same type */ -static int16_t PeepCalculateRideSatisfaction(Guest* peep, const Ride& ride) +static int16_t PeepCalculateRideSatisfaction(Guest& guest, const Ride& ride) { - int16_t satisfaction = PeepCalculateRideValueSatisfaction(peep, ride); - satisfaction += PeepCalculateRideIntensityNauseaSatisfaction(peep, ride); + int16_t satisfaction = PeepCalculateRideValueSatisfaction(guest, ride); + satisfaction += PeepCalculateRideIntensityNauseaSatisfaction(guest, ride); // Calculate satisfaction based on how long the peep has been in the queue for. // (For comparison: peeps start thinking "I've been queueing for a long time" at 3500 and // start leaving the queue at 4300.) - if (peep->TimeInQueue >= 4500) + if (guest.TimeInQueue >= 4500) satisfaction -= 35; - else if (peep->TimeInQueue >= 2250) + else if (guest.TimeInQueue >= 2250) satisfaction -= 10; - else if (peep->TimeInQueue <= 750) + else if (guest.TimeInQueue <= 750) satisfaction += 10; // Peeps get a small boost in satisfaction if they've been on a ride of the same type before, // and this boost is doubled if they've already been on this particular ride. - if (peep->HasRiddenRideType(ride.type)) + if (guest.HasRiddenRideType(ride.type)) satisfaction += 10; - if (peep->HasRidden(*GetRide(peep->CurrentRide))) + if (guest.HasRidden(*GetRide(guest.CurrentRide))) satisfaction += 10; return satisfaction; @@ -2724,22 +2726,22 @@ static int16_t PeepCalculateRideSatisfaction(Guest* peep, const Ride& ride) * the ride becomes the peep's favourite. (This doesn't happen right away, but will be updated once the peep * exits the ride.) */ -static void GuestUpdateFavouriteRide(Guest& peep, const Ride& ride, uint8_t satisfaction) +static void GuestUpdateFavouriteRide(Guest& guest, const Ride& ride, uint8_t satisfaction) { - peep.PeepFlags &= ~PEEP_FLAGS_RIDE_SHOULD_BE_MARKED_AS_FAVOURITE; + guest.PeepFlags &= ~PEEP_FLAGS_RIDE_SHOULD_BE_MARKED_AS_FAVOURITE; uint8_t peepRideRating = std::clamp((ride.ratings.excitement / 4) + satisfaction, 0, kPeepMaxHappiness); - if (peepRideRating >= peep.FavouriteRideRating) + if (peepRideRating >= guest.FavouriteRideRating) { - if (peep.Happiness >= 160 && peep.HappinessTarget >= 160) + if (guest.Happiness >= 160 && guest.HappinessTarget >= 160) { - peep.FavouriteRideRating = peepRideRating; - peep.PeepFlags |= PEEP_FLAGS_RIDE_SHOULD_BE_MARKED_AS_FAVOURITE; + guest.FavouriteRideRating = peepRideRating; + guest.PeepFlags |= PEEP_FLAGS_RIDE_SHOULD_BE_MARKED_AS_FAVOURITE; } } } /* rct2: 0x00695555 */ -static int16_t PeepCalculateRideValueSatisfaction(Guest* peep, const Ride& ride) +static int16_t PeepCalculateRideValueSatisfaction(Guest& guest, const Ride& ride) { if (getGameState().park.Flags & PARK_FLAGS_NO_MONEY) { @@ -2757,7 +2759,7 @@ static int16_t PeepCalculateRideValueSatisfaction(Guest* peep, const Ride& ride) return -5; } - if ((ride.value + ((ride.value * peep->Happiness) / 256)) >= ridePrice) + if ((ride.value + ((ride.value * guest.Happiness) / 256)) >= ridePrice) { return -30; } @@ -2771,7 +2773,7 @@ static int16_t PeepCalculateRideValueSatisfaction(Guest* peep, const Ride& ride) * of the ride fall exactly within the peep's preferences, but lower scores can still be achieved * if the peep's happiness is enough to offset it. */ -static int16_t PeepCalculateRideIntensityNauseaSatisfaction(Guest* peep, const Ride& ride) +static int16_t PeepCalculateRideIntensityNauseaSatisfaction(Guest& guest, const Ride& ride) { if (!RideHasRatings(ride)) { @@ -2780,20 +2782,20 @@ static int16_t PeepCalculateRideIntensityNauseaSatisfaction(Guest* peep, const R uint8_t intensitySatisfaction = 3; uint8_t nauseaSatisfaction = 3; - ride_rating maxIntensity = peep->Intensity.GetMaximum() * 100; - ride_rating minIntensity = peep->Intensity.GetMinimum() * 100; + ride_rating maxIntensity = guest.Intensity.GetMaximum() * 100; + ride_rating minIntensity = guest.Intensity.GetMinimum() * 100; if (minIntensity <= ride.ratings.intensity && maxIntensity >= ride.ratings.intensity) { intensitySatisfaction--; } - minIntensity -= peep->Happiness * 2; - maxIntensity += peep->Happiness; + minIntensity -= guest.Happiness * 2; + maxIntensity += guest.Happiness; if (minIntensity <= ride.ratings.intensity && maxIntensity >= ride.ratings.intensity) { intensitySatisfaction--; } - minIntensity -= peep->Happiness * 2; - maxIntensity += peep->Happiness; + minIntensity -= guest.Happiness * 2; + maxIntensity += guest.Happiness; if (minIntensity <= ride.ratings.intensity && maxIntensity >= ride.ratings.intensity) { intensitySatisfaction--; @@ -2801,20 +2803,20 @@ static int16_t PeepCalculateRideIntensityNauseaSatisfaction(Guest* peep, const R // Although it's not shown in the interface, a peep with Average or High nausea tolerance // has a minimum preferred nausea value. (For peeps with None or Low, this is set to zero.) - ride_rating minNausea = kNauseaMinimumThresholds[(EnumValue(peep->NauseaTolerance) & 3)]; - ride_rating maxNausea = NauseaMaximumThresholds[(EnumValue(peep->NauseaTolerance) & 3)]; + ride_rating minNausea = kNauseaMinimumThresholds[(EnumValue(guest.NauseaTolerance) & 3)]; + ride_rating maxNausea = NauseaMaximumThresholds[(EnumValue(guest.NauseaTolerance) & 3)]; if (minNausea <= ride.ratings.nausea && maxNausea >= ride.ratings.nausea) { nauseaSatisfaction--; } - minNausea -= peep->Happiness * 2; - maxNausea += peep->Happiness; + minNausea -= guest.Happiness * 2; + maxNausea += guest.Happiness; if (minNausea <= ride.ratings.nausea && maxNausea >= ride.ratings.nausea) { nauseaSatisfaction--; } - minNausea -= peep->Happiness * 2; - maxNausea += peep->Happiness; + minNausea -= guest.Happiness * 2; + maxNausea += guest.Happiness; if (minNausea <= ride.ratings.nausea && maxNausea >= ride.ratings.nausea) { nauseaSatisfaction--; @@ -2871,16 +2873,16 @@ static int16_t PeepCalculateRideIntensityNauseaSatisfaction(Guest* peep, const R * - How hungry the peep is (+0% nausea at 50% hunger up to +100% nausea at 100% hunger) * - The peep's nausea tolerance (Final modifier: none: 100%, low: 50%, average: 25%, high: 12.5%) */ -static void PeepUpdateRideNauseaGrowth(Guest* peep, const Ride& ride) +static void PeepUpdateRideNauseaGrowth(Guest& guest, const Ride& ride) { - uint32_t nauseaMultiplier = std::clamp(256 - peep->HappinessTarget, 64, 200); + uint32_t nauseaMultiplier = std::clamp(256 - guest.HappinessTarget, 64, 200); uint32_t nauseaGrowthRateChange = (ride.ratings.nausea * nauseaMultiplier) / 512; - nauseaGrowthRateChange *= std::max(static_cast(128), peep->Hunger) / 64; - nauseaGrowthRateChange >>= (EnumValue(peep->NauseaTolerance) & 3); - peep->NauseaTarget = static_cast(std::min(peep->NauseaTarget + nauseaGrowthRateChange, 255u)); + nauseaGrowthRateChange *= std::max(static_cast(128), guest.Hunger) / 64; + nauseaGrowthRateChange >>= (EnumValue(guest.NauseaTolerance) & 3); + guest.NauseaTarget = static_cast(std::min(guest.NauseaTarget + nauseaGrowthRateChange, 255u)); } -static bool PeepShouldGoOnRideAgain(Guest* peep, const Ride& ride) +static bool PeepShouldGoOnRideAgain(Guest& guest, const Ride& ride) { if (!ride.getRideTypeDescriptor().HasFlag(RtdFlag::guestsWillRideAgain)) return false; @@ -2888,23 +2890,23 @@ static bool PeepShouldGoOnRideAgain(Guest* peep, const Ride& ride) return false; if (ride.ratings.intensity > MakeRideRating(10, 00) && !getGameState().cheats.ignoreRideIntensity) return false; - if (peep->Happiness < 180) + if (guest.Happiness < 180) return false; - if (peep->Energy < 100) + if (guest.Energy < 100) return false; - if (peep->Nausea > 160) + if (guest.Nausea > 160) return false; - if (peep->Hunger < 30) + if (guest.Hunger < 30) return false; - if (peep->Thirst < 20) + if (guest.Thirst < 20) return false; - if (peep->Toilet > 170) + if (guest.Toilet > 170) return false; uint8_t r = (ScenarioRand() & 0xFF); if (r <= 128) { - if (peep->GuestNumRides > 7) + if (guest.GuestNumRides > 7) return false; if (r > 64) return false; @@ -2913,21 +2915,21 @@ static bool PeepShouldGoOnRideAgain(Guest* peep, const Ride& ride) return true; } -static bool PeepShouldPreferredIntensityIncrease(Guest* peep) +static bool PeepShouldPreferredIntensityIncrease(Guest& guest) { if (getGameState().park.Flags & PARK_FLAGS_PREF_LESS_INTENSE_RIDES) return false; - if (peep->Happiness < 200) + if (guest.Happiness < 200) return false; - return (ScenarioRand() & 0xFF) >= static_cast(peep->Intensity); + return (ScenarioRand() & 0xFF) >= static_cast(guest.Intensity); } -static bool PeepReallyLikedRide(Guest* peep, const Ride& ride) +static bool PeepReallyLikedRide(Guest& guest, const Ride& ride) { - if (peep->Happiness < 215) + if (guest.Happiness < 215) return false; - if (peep->Nausea > 120) + if (guest.Nausea > 120) return false; if (!RideHasRatings(ride)) return false; @@ -3061,14 +3063,14 @@ static PeepThoughtType PeepAssessSurroundings(int16_t centre_x, int16_t centre_y * * rct2: 0x0068F9A9 */ -static void PeepUpdateHunger(Guest* peep) +static void PeepUpdateHunger(Guest& guest) { - if (peep->Hunger >= 3) + if (guest.Hunger >= 3) { - peep->Hunger -= 2; + guest.Hunger -= 2; - peep->EnergyTarget = std::min(peep->EnergyTarget + 2, kPeepMaxEnergyTarget); - peep->Toilet = std::min(peep->Toilet + 1, 255); + guest.EnergyTarget = std::min(guest.EnergyTarget + 2, kPeepMaxEnergyTarget); + guest.Toilet = std::min(guest.Toilet + 1, 255); } } @@ -3078,19 +3080,19 @@ static void PeepUpdateHunger(Guest* peep) * * rct2: 0x0068F8CD */ -static void PeepDecideWhetherToLeavePark(Guest* peep) +static void PeepDecideWhetherToLeavePark(Guest& guest) { - if (peep->EnergyTarget >= 33) + if (guest.EnergyTarget >= 33) { - peep->EnergyTarget -= 2; + guest.EnergyTarget -= 2; } - if (getGameState().weatherCurrent.temperature >= 21 && peep->Thirst >= 5) + if (getGameState().weatherCurrent.temperature >= 21 && guest.Thirst >= 5) { - peep->Thirst--; + guest.Thirst--; } - if (peep->OutsideOfPark) + if (guest.OutsideOfPark) { return; } @@ -3098,18 +3100,18 @@ static void PeepDecideWhetherToLeavePark(Guest* peep) /* Peeps that are happy enough, have enough energy and * (if appropriate) have enough money will always stay * in the park. */ - if (!(peep->PeepFlags & PEEP_FLAGS_LEAVING_PARK)) + if (!(guest.PeepFlags & PEEP_FLAGS_LEAVING_PARK)) { if (getGameState().park.Flags & PARK_FLAGS_NO_MONEY) { - if (peep->Energy >= 70 && peep->Happiness >= 60) + if (guest.Energy >= 70 && guest.Happiness >= 60) { return; } } else { - if (peep->Energy >= 55 && peep->Happiness >= 45 && peep->CashInPocket >= 5.00_GBP) + if (guest.Energy >= 55 && guest.Happiness >= 45 && guest.CashInPocket >= 5.00_GBP) { return; } @@ -3123,53 +3125,53 @@ static void PeepDecideWhetherToLeavePark(Guest* peep) } // In the remaining 5% chance the peep leaves the park. - PeepLeavePark(peep); + PeepLeavePark(guest); } /** * * rct2: 0x0068F93E */ -static void PeepLeavePark(Guest* peep) +static void PeepLeavePark(Guest& guest) { - peep->GuestHeadingToRideId = RideId::GetNull(); - if (peep->PeepFlags & PEEP_FLAGS_LEAVING_PARK) + guest.GuestHeadingToRideId = RideId::GetNull(); + if (guest.PeepFlags & PEEP_FLAGS_LEAVING_PARK) { - if (peep->GuestIsLostCountdown < 60) + if (guest.GuestIsLostCountdown < 60) { return; } } else { - peep->GuestIsLostCountdown = 254; - peep->PeepFlags |= PEEP_FLAGS_LEAVING_PARK; - peep->PeepFlags &= ~PEEP_FLAGS_PARK_ENTRANCE_CHOSEN; + guest.GuestIsLostCountdown = 254; + guest.PeepFlags |= PEEP_FLAGS_LEAVING_PARK; + guest.PeepFlags &= ~PEEP_FLAGS_PARK_ENTRANCE_CHOSEN; } - peep->InsertNewThought(PeepThoughtType::GoHome); + guest.InsertNewThought(PeepThoughtType::GoHome); auto* windowMgr = Ui::GetWindowManager(); - WindowBase* w = windowMgr->FindByNumber(WindowClass::Peep, peep->Id); + WindowBase* w = windowMgr->FindByNumber(WindowClass::Peep, guest.Id); if (w != nullptr) w->OnPrepareDraw(); - windowMgr->InvalidateByNumber(WindowClass::Peep, peep->Id); + windowMgr->InvalidateByNumber(WindowClass::Peep, guest.Id); } template -static void PeepHeadForNearestRide(Guest* peep, bool considerOnlyCloseRides, T predicate) +static void PeepHeadForNearestRide(Guest& guest, bool considerOnlyCloseRides, T predicate) { - if (peep->State != PeepState::Sitting && peep->State != PeepState::Watching && peep->State != PeepState::Walking) + if (guest.State != PeepState::Sitting && guest.State != PeepState::Watching && guest.State != PeepState::Walking) { return; } - if (peep->PeepFlags & PEEP_FLAGS_LEAVING_PARK) + if (guest.PeepFlags & PEEP_FLAGS_LEAVING_PARK) return; - if (peep->x == kLocationNull) + if (guest.x == kLocationNull) return; - if (!peep->GuestHeadingToRideId.IsNull()) + if (!guest.GuestHeadingToRideId.IsNull()) { - auto ride = GetRide(peep->GuestHeadingToRideId); + auto ride = GetRide(guest.GuestHeadingToRideId); if (ride != nullptr && predicate(*ride)) { return; @@ -3177,7 +3179,7 @@ static void PeepHeadForNearestRide(Guest* peep, bool considerOnlyCloseRides, T p } OpenRCT2::BitSet rideConsideration; - if (!considerOnlyCloseRides && (peep->HasItem(ShopItem::Map))) + if (!considerOnlyCloseRides && (guest.HasItem(ShopItem::Map))) { // Consider all rides in the park for (const auto& ride : GetRideManager()) @@ -3192,8 +3194,8 @@ static void PeepHeadForNearestRide(Guest* peep, bool considerOnlyCloseRides, T p { // Take nearby rides into consideration constexpr auto kSearchRadius = 10 * 32; - int32_t cx = floor2(peep->x, 32); - int32_t cy = floor2(peep->y, 32); + int32_t cx = floor2(guest.x, 32); + int32_t cy = floor2(guest.y, 32); for (auto x = cx - kSearchRadius; x <= cx + kSearchRadius; x += kCoordsXYStep) { for (auto y = cy - kSearchRadius; y <= cy + kSearchRadius; y += kCoordsXYStep) @@ -3227,7 +3229,7 @@ static void PeepHeadForNearestRide(Guest* peep, bool considerOnlyCloseRides, T p { if (!(ride.lifecycleFlags & RIDE_LIFECYCLE_QUEUE_FULL)) { - if (peep->ShouldGoOnRide(ride, StationIndex::FromUnderlying(0), false, true)) + if (guest.ShouldGoOnRide(ride, StationIndex::FromUnderlying(0), false, true)) { potentialRides[numPotentialRides++] = ride.id; } @@ -3244,7 +3246,7 @@ static void PeepHeadForNearestRide(Guest* peep, bool considerOnlyCloseRides, T p if (ride != nullptr) { auto rideLocation = ride->getStation().Start; - int32_t distance = abs(rideLocation.x - peep->x) + abs(rideLocation.y - peep->y); + int32_t distance = abs(rideLocation.x - guest.x) + abs(rideLocation.y - guest.y); if (distance < closestRideDistance) { closestRide = ride; @@ -3255,18 +3257,18 @@ static void PeepHeadForNearestRide(Guest* peep, bool considerOnlyCloseRides, T p if (closestRide != nullptr) { // Head to that ride - peep->GuestHeadingToRideId = closestRide->id; - peep->GuestIsLostCountdown = 200; - peep->ResetPathfindGoal(); - peep->WindowInvalidateFlags |= PEEP_INVALIDATE_PEEP_ACTION; - peep->TimeLost = 0; + guest.GuestHeadingToRideId = closestRide->id; + guest.GuestIsLostCountdown = 200; + guest.ResetPathfindGoal(); + guest.WindowInvalidateFlags |= PEEP_INVALIDATE_PEEP_ACTION; + guest.TimeLost = 0; } } -static void PeepHeadForNearestRideWithFlag(Guest* peep, bool considerOnlyCloseRides, RtdFlag rtdFlag) +static void PeepHeadForNearestRideWithFlag(Guest& guest, bool considerOnlyCloseRides, RtdFlag rtdFlag) { PeepHeadForNearestRide( - peep, considerOnlyCloseRides, [rtdFlag](const Ride& ride) { return ride.getRideTypeDescriptor().HasFlag(rtdFlag); }); + guest, considerOnlyCloseRides, [rtdFlag](const Ride& ride) { return ride.getRideTypeDescriptor().HasFlag(rtdFlag); }); } static void GuestHeadForNearestRideWithSpecialType(Guest& guest, bool considerOnlyCloseRides, RtdSpecialType specialType) @@ -3275,7 +3277,7 @@ static void GuestHeadForNearestRideWithSpecialType(Guest& guest, bool considerOn { return; } - PeepHeadForNearestRide(&guest, considerOnlyCloseRides, [specialType](const Ride& ride) { + PeepHeadForNearestRide(guest, considerOnlyCloseRides, [specialType](const Ride& ride) { return ride.getRideTypeDescriptor().specialType == specialType; }); } @@ -3336,23 +3338,23 @@ void Guest::StopPurchaseThought(ride_type_t rideType) * * rct2: 0x0069AEB7 */ -static bool PeepShouldUseCashMachine(Guest* peep, RideId rideIndex) +static bool PeepShouldUseCashMachine(Guest& guest, RideId rideIndex) { if (getGameState().park.Flags & PARK_FLAGS_NO_MONEY) return false; - if (peep->PeepFlags & PEEP_FLAGS_LEAVING_PARK) + if (guest.PeepFlags & PEEP_FLAGS_LEAVING_PARK) return false; - if (peep->CashInPocket > 20.00_GBP) + if (guest.CashInPocket > 20.00_GBP) return false; - if (115 + (ScenarioRand() % 128) > peep->Happiness) + if (115 + (ScenarioRand() % 128) > guest.Happiness) return false; - if (peep->Energy < 80) + if (guest.Energy < 80) return false; auto ride = GetRide(rideIndex); if (ride != nullptr) { - ride->updateSatisfaction(peep->Happiness >> 6); + ride->updateSatisfaction(guest.Happiness >> 6); ride->curNumCustomers++; ride->totalCustomers++; ride->windowInvalidateFlags |= RIDE_INVALIDATE_RIDE_CUSTOMER; @@ -3412,7 +3414,7 @@ void Guest::UpdateBuying() const auto& rtd = GetRideTypeDescriptor(ride->type); if (rtd.specialType == RtdSpecialType::cashMachine) { - item_bought = PeepShouldUseCashMachine(this, CurrentRide); + item_bought = PeepShouldUseCashMachine(*this, CurrentRide); if (!item_bought) { PreviousRide = CurrentRide; @@ -3526,7 +3528,7 @@ void Guest::UpdateRideAtEntrance() if (ride->status != RideStatus::open || ride->vehicleChangeTimeout != 0) { - PeepUpdateRideAtEntranceTryLeave(this); + PeepUpdateRideAtEntranceTryLeave(*this); return; } @@ -3536,13 +3538,13 @@ void Guest::UpdateRideAtEntrance() auto ridePrice = RideGetPrice(*ride); if (ridePrice != 0) { - if (!PeepCheckRidePriceAtEntrance(this, *ride, ridePrice)) + if (!PeepCheckRidePriceAtEntrance(*this, *ride, ridePrice)) return; } if (!ride->getRideTypeDescriptor().HasFlag(RtdFlag::noVehicles)) { - Vehicle* vehicle = PeepChooseCarFromRide(this, *ride, carArray); + Vehicle* vehicle = PeepChooseCarFromRide(*this, *ride, carArray); PeepChooseSeatFromCar(this, *ride, vehicle); } GoToRideEntrance(*ride); @@ -3556,9 +3558,9 @@ static constexpr CoordsXY kMazeEntranceStart[] = { { 24, 8 }, }; -void PeepUpdateRideLeaveEntranceMaze(Guest* peep, Ride& ride, CoordsXYZD& entrance_loc) +void PeepUpdateRideLeaveEntranceMaze(Guest& guest, Ride& ride, CoordsXYZD& entrance_loc) { - peep->MazeLastEdge = entrance_loc.direction + 1; + guest.MazeLastEdge = entrance_loc.direction + 1; entrance_loc.x += CoordsDirectionDelta[entrance_loc.direction].x; entrance_loc.y += CoordsDirectionDelta[entrance_loc.direction].y; @@ -3567,45 +3569,45 @@ void PeepUpdateRideLeaveEntranceMaze(Guest* peep, Ride& ride, CoordsXYZD& entran if (ScenarioRand() & 0x40) { direction += 4; - peep->MazeLastEdge += 2; + guest.MazeLastEdge += 2; } direction &= 0xF; // Direction is 11, 15, 3, or 7 - peep->Var37 = direction; - peep->MazeLastEdge &= 3; + guest.Var37 = direction; + guest.MazeLastEdge &= 3; entrance_loc.x += kMazeEntranceStart[direction / 4].x; entrance_loc.y += kMazeEntranceStart[direction / 4].y; - peep->SetDestination(entrance_loc, 3); + guest.SetDestination(entrance_loc, 3); ride.curNumCustomers++; - peep->OnEnterRide(ride); - peep->RideSubState = PeepRideSubState::MazePathfinding; + guest.OnEnterRide(ride); + guest.RideSubState = PeepRideSubState::MazePathfinding; } -void PeepUpdateRideLeaveEntranceSpiralSlide(Guest* peep, Ride& ride, CoordsXYZD& entrance_loc) +void PeepUpdateRideLeaveEntranceSpiralSlide(Guest& guest, Ride& ride, CoordsXYZD& entrance_loc) { - entrance_loc = { ride.getStation(peep->CurrentRideStation).GetStart(), entrance_loc.direction }; + entrance_loc = { ride.getStation(guest.CurrentRideStation).GetStart(), entrance_loc.direction }; - TileElement* tile_element = RideGetStationStartTrackElement(ride, peep->CurrentRideStation); + TileElement* tile_element = RideGetStationStartTrackElement(ride, guest.CurrentRideStation); uint8_t direction_track = (tile_element == nullptr ? 0 : tile_element->GetDirection()); - peep->Var37 = (entrance_loc.direction << 2) | (direction_track << 4); + guest.Var37 = (entrance_loc.direction << 2) | (direction_track << 4); - entrance_loc += kSpiralSlideWalkingPath[peep->Var37]; + entrance_loc += kSpiralSlideWalkingPath[guest.Var37]; - peep->SetDestination(entrance_loc); - peep->CurrentCar = 0; + guest.SetDestination(entrance_loc); + guest.CurrentCar = 0; ride.curNumCustomers++; - peep->OnEnterRide(ride); - peep->RideSubState = PeepRideSubState::ApproachSpiralSlide; + guest.OnEnterRide(ride); + guest.RideSubState = PeepRideSubState::ApproachSpiralSlide; } -void PeepUpdateRideLeaveEntranceDefault(Guest* peep, Ride& ride, CoordsXYZD& entrance_loc) +void PeepUpdateRideLeaveEntranceDefault(Guest& guest, Ride& ride, CoordsXYZD& entrance_loc) { const auto currentTicks = getGameState().currentTicks; @@ -3620,7 +3622,7 @@ void PeepUpdateRideLeaveEntranceDefault(Guest* peep, Ride& ride, CoordsXYZD& ent ride.formatNameTo(ft); if (Config::Get().notifications.RideWarnings) { - News::AddItemToQueue(News::ItemType::Ride, STR_GUESTS_GETTING_STUCK_ON_RIDE, peep->CurrentRide.ToUnderlying(), ft); + News::AddItemToQueue(News::ItemType::Ride, STR_GUESTS_GETTING_STUCK_ON_RIDE, guest.CurrentRide.ToUnderlying(), ft); } } } @@ -3749,7 +3751,7 @@ void Guest::UpdateRideAdvanceThroughEntrance() } const auto& rtd = GetRideTypeDescriptor(ride->type); - rtd.UpdateLeaveEntrance(this, *ride, entranceLocation); + rtd.UpdateLeaveEntrance(*this, *ride, entranceLocation); return; } @@ -3825,14 +3827,14 @@ void Guest::UpdateRideAdvanceThroughEntrance() * * rct2: 0x0069321D */ -static void PeepGoToRideExit(Peep* peep, const Ride& ride, int16_t x, int16_t y, int16_t z, uint8_t exit_direction) +static void PeepGoToRideExit(Guest& guest, const Ride& ride, int16_t x, int16_t y, int16_t z, uint8_t exit_direction) { z += ride.getRideTypeDescriptor().Heights.PlatformHeight; - peep->MoveTo({ x, y, z }); + guest.MoveTo({ x, y, z }); - Guard::Assert(peep->CurrentRideStation.ToUnderlying() < OpenRCT2::Limits::kMaxStationsPerRide); - auto exit = ride.getStation(peep->CurrentRideStation).Exit; + Guard::Assert(guest.CurrentRideStation.ToUnderlying() < OpenRCT2::Limits::kMaxStationsPerRide); + auto exit = ride.getStation(guest.CurrentRideStation).Exit; x = exit.x; y = exit.y; x *= 32; @@ -3869,10 +3871,10 @@ static void PeepGoToRideExit(Peep* peep, const Ride& ride, int16_t x, int16_t y, x -= x_shift; y -= y_shift; - peep->SetDestination({ x, y }, 2); + guest.SetDestination({ x, y }, 2); - peep->Orientation = exit_direction * 8; - peep->RideSubState = PeepRideSubState::ApproachExit; + guest.Orientation = exit_direction * 8; + guest.RideSubState = PeepRideSubState::ApproachExit; } /** @@ -3942,9 +3944,9 @@ void Guest::UpdateRideFreeVehicleEnterRide(Ride& ride) * * rct2: 0x00691FD4 */ -static void PeepUpdateRideNoFreeVehicleRejoinQueue(Guest* peep, Ride& ride) +static void PeepUpdateRideNoFreeVehicleRejoinQueue(Guest& guest, Ride& ride) { - TileCoordsXYZD entranceLocation = ride.getStation(peep->CurrentRideStation).Entrance; + TileCoordsXYZD entranceLocation = ride.getStation(guest.CurrentRideStation).Entrance; int32_t x = entranceLocation.x * 32; int32_t y = entranceLocation.y * 32; @@ -3954,11 +3956,11 @@ static void PeepUpdateRideNoFreeVehicleRejoinQueue(Guest* peep, Ride& ride) y += 16 - DirectionOffsets[entranceLocation.direction].y * 20; } - peep->SetDestination({ x, y }, 2); - peep->SetState(PeepState::QueuingFront); - peep->RideSubState = PeepRideSubState::AtEntrance; + guest.SetDestination({ x, y }, 2); + guest.SetState(PeepState::QueuingFront); + guest.RideSubState = PeepRideSubState::AtEntrance; - ride.queueInsertGuestAtFront(peep->CurrentRideStation, peep); + ride.queueInsertGuestAtFront(guest.CurrentRideStation, &guest); } /** @@ -3980,7 +3982,7 @@ void Guest::UpdateRideFreeVehicleCheck() { if (ride->status != RideStatus::open || ride->vehicleChangeTimeout != 0 || (++RejoinQueueTimeout) == 0) { - PeepUpdateRideNoFreeVehicleRejoinQueue(this, *ride); + PeepUpdateRideNoFreeVehicleRejoinQueue(*this, *ride); return; } @@ -4071,7 +4073,7 @@ void Guest::UpdateRideFreeVehicleCheck() vehicle->next_free_seat--; vehicle->peep[CurrentSeat] = EntityId::GetNull(); - PeepUpdateRideNoFreeVehicleRejoinQueue(this, *ride); + PeepUpdateRideNoFreeVehicleRejoinQueue(*this, *ride); } void Guest::UpdateRideApproachVehicle() @@ -4277,7 +4279,7 @@ void Guest::UpdateRideLeaveVehicle() platformLocation.y = vehicle->y + yShift * shiftMultiplier; PeepGoToRideExit( - this, *ride, platformLocation.x, platformLocation.y, platformLocation.z, platformLocation.direction); + *this, *ride, platformLocation.x, platformLocation.y, platformLocation.z, platformLocation.direction); return; } @@ -4314,7 +4316,7 @@ void Guest::UpdateRideLeaveVehicle() platformLocation.z = station.GetBaseZ(); - PeepGoToRideExit(this, *ride, platformLocation.x, platformLocation.y, platformLocation.z, platformLocation.direction); + PeepGoToRideExit(*this, *ride, platformLocation.x, platformLocation.y, platformLocation.z, platformLocation.direction); return; } @@ -5203,7 +5205,7 @@ void Guest::UpdateRideShopLeave() } /* From peep_update */ -static void GuestUpdateThoughts(Guest* peep) +static void GuestUpdateThoughts(Guest& guest) { // Thoughts must always have a gap of at least // 220 ticks in age between them. In order to @@ -5213,37 +5215,37 @@ static void GuestUpdateThoughts(Guest* peep) int32_t fresh_thought = -1; for (int32_t i = 0; i < kPeepMaxThoughts; i++) { - if (peep->Thoughts[i].type == PeepThoughtType::None) + if (guest.Thoughts[i].type == PeepThoughtType::None) break; - if (peep->Thoughts[i].freshness == 1) + if (guest.Thoughts[i].freshness == 1) { add_fresh = 0; // If thought is fresh we wait 220 ticks // before allowing a new thought to become fresh. - if (++peep->Thoughts[i].fresh_timeout >= 220) + if (++guest.Thoughts[i].fresh_timeout >= 220) { - peep->Thoughts[i].fresh_timeout = 0; + guest.Thoughts[i].fresh_timeout = 0; // Thought is no longer fresh - peep->Thoughts[i].freshness++; + guest.Thoughts[i].freshness++; add_fresh = 1; } } - else if (peep->Thoughts[i].freshness > 1) + else if (guest.Thoughts[i].freshness > 1) { - if (++peep->Thoughts[i].fresh_timeout == 0) + if (++guest.Thoughts[i].fresh_timeout == 0) { // When thought is older than ~6900 ticks remove it - if (++peep->Thoughts[i].freshness >= 28) + if (++guest.Thoughts[i].freshness >= 28) { - peep->WindowInvalidateFlags |= PEEP_INVALIDATE_PEEP_THOUGHTS; + guest.WindowInvalidateFlags |= PEEP_INVALIDATE_PEEP_THOUGHTS; // Clear top thought, push others up if (i < kPeepMaxThoughts - 2) { - memmove(&peep->Thoughts[i], &peep->Thoughts[i + 1], sizeof(PeepThought) * (kPeepMaxThoughts - i - 1)); + memmove(&guest.Thoughts[i], &guest.Thoughts[i + 1], sizeof(PeepThought) * (kPeepMaxThoughts - i - 1)); } - peep->Thoughts[kPeepMaxThoughts - 1].type = PeepThoughtType::None; + guest.Thoughts[kPeepMaxThoughts - 1].type = PeepThoughtType::None; } } } @@ -5257,8 +5259,8 @@ static void GuestUpdateThoughts(Guest* peep) // fresh. if (add_fresh && fresh_thought != -1) { - peep->Thoughts[fresh_thought].freshness = 1; - peep->WindowInvalidateFlags |= PEEP_INVALIDATE_PEEP_THOUGHTS; + guest.Thoughts[fresh_thought].freshness = 1; + guest.WindowInvalidateFlags |= PEEP_INVALIDATE_PEEP_THOUGHTS; } } @@ -5296,7 +5298,7 @@ void Guest::Update() } } - GuestUpdateThoughts(this); + GuestUpdateThoughts(*this); // Walking speed logic const auto stepsToTake = GetStepsToTake(); @@ -5442,9 +5444,6 @@ void Guest::UpdateRide() } } -static void PeepUpdateWalkingBreakScenery(Guest* peep); -static bool PeepFindRideToLookAt(Peep* peep, uint8_t edge, RideId* rideToView, uint8_t* rideSeatToView); - /** * * rct2: 0x0069030A @@ -5573,7 +5572,7 @@ void Guest::UpdateWalking() if (UpdateWalkingFindBin()) return; - PeepUpdateWalkingBreakScenery(this); + PeepUpdateWalkingBreakScenery(*this); if (State != PeepState::Walking) return; @@ -5643,7 +5642,7 @@ void Guest::UpdateWalking() RideId ride_to_view; uint8_t ride_seat_to_view; - if (IsOnLevelCrossing() || !PeepFindRideToLookAt(this, chosen_edge, &ride_to_view, &ride_seat_to_view)) + if (IsOnLevelCrossing() || !PeepFindRideToLookAt(*this, chosen_edge, &ride_to_view, &ride_seat_to_view)) return; // Check if there is a peep watching (and if there is place for us) @@ -6346,31 +6345,31 @@ static PathElement* FindBreakableElement(const CoordsXYZ& loc) * * rct2: 0x00690848 */ -static void PeepUpdateWalkingBreakScenery(Guest* peep) +static void PeepUpdateWalkingBreakScenery(Guest& guest) { if (getGameState().cheats.disableVandalism) return; - if (!(peep->PeepFlags & PEEP_FLAGS_ANGRY)) + if (!(guest.PeepFlags & PEEP_FLAGS_ANGRY)) { - if (peep->Happiness >= 48) + if (guest.Happiness >= 48) return; - if (peep->Energy < 85) + if (guest.Energy < 85) return; - if (peep->State != PeepState::Walking) + if (guest.State != PeepState::Walking) return; - if ((peep->LitterCount & 0xC0) != 0xC0 && (peep->DisgustingCount & 0xC0) != 0xC0) + if ((guest.LitterCount & 0xC0) != 0xC0 && (guest.DisgustingCount & 0xC0) != 0xC0) return; if ((ScenarioRand() & 0xFFFF) > 3276) return; } - if (peep->GetNextIsSurface()) + if (guest.GetNextIsSurface()) return; - auto* tileElement = FindBreakableElement(peep->NextLoc); + auto* tileElement = FindBreakableElement(guest.NextLoc); if (tileElement == nullptr) return; @@ -6379,9 +6378,9 @@ static void PeepUpdateWalkingBreakScenery(Guest* peep) return; // Check if a peep is already sitting on the bench. If so, do not vandalise it. - for (auto peep2 : EntityTileList({ peep->x, peep->y })) + for (auto* otherGuest : EntityTileList({ guest.x, guest.y })) { - if ((peep2->State != PeepState::Sitting) || (peep->z != peep2->z)) + if ((otherGuest->State != PeepState::Sitting) || (guest.z != otherGuest->z)) { continue; } @@ -6394,8 +6393,8 @@ static void PeepUpdateWalkingBreakScenery(Guest* peep) if (innerPeep->AssignedStaffType != StaffType::Security || innerPeep->x == kLocationNull) continue; - int32_t xDist = abs(innerPeep->x - peep->x); - int32_t yDist = abs(innerPeep->y - peep->y); + int32_t xDist = abs(innerPeep->x - guest.x); + int32_t yDist = abs(innerPeep->y - guest.y); if (std::max(xDist, yDist) < 224) { @@ -6406,9 +6405,9 @@ static void PeepUpdateWalkingBreakScenery(Guest* peep) tileElement->SetIsBroken(true); - MapInvalidateTileZoom1({ peep->NextLoc, tileElement->GetBaseZ(), tileElement->GetBaseZ() + 32 }); + MapInvalidateTileZoom1({ guest.NextLoc, tileElement->GetBaseZ(), tileElement->GetBaseZ() + 32 }); - peep->Angriness = 16; + guest.Angriness = 16; } /** @@ -6470,7 +6469,7 @@ static bool PeepShouldWatchRide(TileElement* tileElement) return true; } -bool Loc690FD0(Peep* peep, RideId* rideToView, uint8_t* rideSeatToView, TileElement* tileElement) +bool Loc690FD0(Guest& guest, RideId* rideToView, uint8_t* rideSeatToView, TileElement* tileElement) { auto ride = GetRide(tileElement->AsTrack()->GetRideIndex()); if (ride == nullptr) @@ -6482,7 +6481,7 @@ bool Loc690FD0(Peep* peep, RideId* rideToView, uint8_t* rideSeatToView, TileElem *rideSeatToView = 1; if (ride->status != RideStatus::open) { - if (tileElement->GetClearanceZ() > peep->NextLoc.z + (8 * kCoordsZStep)) + if (tileElement->GetClearanceZ() > guest.NextLoc.z + (8 * kCoordsZStep)) { *rideSeatToView |= (1 << 1); } @@ -6495,7 +6494,7 @@ bool Loc690FD0(Peep* peep, RideId* rideToView, uint8_t* rideSeatToView, TileElem *rideSeatToView = 0; if (ride->status == RideStatus::open && !(ride->lifecycleFlags & RIDE_LIFECYCLE_BROKEN_DOWN)) { - if (tileElement->GetClearanceZ() > peep->NextLoc.z + (8 * kCoordsZStep)) + if (tileElement->GetClearanceZ() > guest.NextLoc.z + (8 * kCoordsZStep)) { *rideSeatToView = 0x02; } @@ -6517,11 +6516,11 @@ bool Loc690FD0(Peep* peep, RideId* rideToView, uint8_t* rideSeatToView, TileElem * @param[out] rideSeatToView (ch) * @return !CF */ -static bool PeepFindRideToLookAt(Peep* peep, uint8_t edge, RideId* rideToView, uint8_t* rideSeatToView) +static bool PeepFindRideToLookAt(Guest& guest, uint8_t edge, RideId* rideToView, uint8_t* rideSeatToView) { TileElement* tileElement; - auto surfaceElement = MapGetSurfaceElementAt(peep->NextLoc); + auto surfaceElement = MapGetSurfaceElementAt(guest.NextLoc); tileElement = reinterpret_cast(surfaceElement); if (tileElement == nullptr) @@ -6545,16 +6544,16 @@ static bool PeepFindRideToLookAt(Peep* peep, uint8_t edge, RideId* rideToView, u auto wallEntry = tileElement->AsWall()->GetEntry(); if (wallEntry == nullptr || (wallEntry->flags2 & WALL_SCENERY_2_IS_OPAQUE)) continue; - if (peep->NextLoc.z + (4 * kCoordsZStep) <= tileElement->GetBaseZ()) + if (guest.NextLoc.z + (4 * kCoordsZStep) <= tileElement->GetBaseZ()) continue; - if (peep->NextLoc.z + (1 * kCoordsZStep) >= tileElement->GetClearanceZ()) + if (guest.NextLoc.z + (1 * kCoordsZStep) >= tileElement->GetClearanceZ()) continue; return false; } while (!(tileElement++)->IsLastForTile()); - uint16_t x = peep->NextLoc.x + CoordsDirectionDelta[edge].x; - uint16_t y = peep->NextLoc.y + CoordsDirectionDelta[edge].y; + uint16_t x = guest.NextLoc.x + CoordsDirectionDelta[edge].x; + uint16_t y = guest.NextLoc.y + CoordsDirectionDelta[edge].y; if (!MapIsLocationValid(CoordsXY{ x, y })) { return false; @@ -6585,9 +6584,9 @@ static bool PeepFindRideToLookAt(Peep* peep, uint8_t edge, RideId* rideToView, u if (wallEntry == nullptr || (wallEntry->flags2 & WALL_SCENERY_2_IS_OPAQUE)) continue; // TODO: Check whether this shouldn't be <=, as the other loops use. If so, also extract as loop A. - if (peep->NextLoc.z + (4 * kCoordsZStep) >= tileElement->GetBaseZ()) + if (guest.NextLoc.z + (4 * kCoordsZStep) >= tileElement->GetBaseZ()) continue; - if (peep->NextLoc.z + (1 * kCoordsZStep) >= tileElement->GetClearanceZ()) + if (guest.NextLoc.z + (1 * kCoordsZStep) >= tileElement->GetClearanceZ()) continue; return false; @@ -6605,16 +6604,16 @@ static bool PeepFindRideToLookAt(Peep* peep, uint8_t edge, RideId* rideToView, u continue; } - if (tileElement->GetClearanceZ() + (1 * kCoordsZStep) < peep->NextLoc.z) + if (tileElement->GetClearanceZ() + (1 * kCoordsZStep) < guest.NextLoc.z) continue; - if (peep->NextLoc.z + (6 * kCoordsZStep) < tileElement->GetBaseZ()) + if (guest.NextLoc.z + (6 * kCoordsZStep) < tileElement->GetBaseZ()) continue; if (tileElement->GetType() == TileElementType::Track) { if (PeepShouldWatchRide(tileElement)) { - return Loc690FD0(peep, rideToView, rideSeatToView, tileElement); + return Loc690FD0(guest, rideToView, rideSeatToView, tileElement); } } @@ -6627,7 +6626,7 @@ static bool PeepFindRideToLookAt(Peep* peep, uint8_t edge, RideId* rideToView, u } *rideSeatToView = 0; - if (tileElement->GetClearanceZ() >= peep->NextLoc.z + (8 * kCoordsZStep)) + if (tileElement->GetClearanceZ() >= guest.NextLoc.z + (8 * kCoordsZStep)) { *rideSeatToView = 0x02; } @@ -6649,9 +6648,9 @@ static bool PeepFindRideToLookAt(Peep* peep, uint8_t edge, RideId* rideToView, u if (tileElement->IsGhost()) continue; } - if (tileElement->GetClearanceZ() + (1 * kCoordsZStep) < peep->NextLoc.z) + if (tileElement->GetClearanceZ() + (1 * kCoordsZStep) < guest.NextLoc.z) continue; - if (peep->NextLoc.z + (6 * kCoordsZStep) < tileElement->GetBaseZ()) + if (guest.NextLoc.z + (6 * kCoordsZStep) < tileElement->GetBaseZ()) continue; if (tileElement->GetType() == TileElementType::Surface) continue; @@ -6703,9 +6702,9 @@ static bool PeepFindRideToLookAt(Peep* peep, uint8_t edge, RideId* rideToView, u auto wallEntry = tileElement->AsWall()->GetEntry(); if (wallEntry == nullptr || (wallEntry->flags2 & WALL_SCENERY_2_IS_OPAQUE)) continue; - if (peep->NextLoc.z + (6 * kCoordsZStep) <= tileElement->GetBaseZ()) + if (guest.NextLoc.z + (6 * kCoordsZStep) <= tileElement->GetBaseZ()) continue; - if (peep->NextLoc.z >= tileElement->GetClearanceZ()) + if (guest.NextLoc.z >= tileElement->GetClearanceZ()) continue; return false; @@ -6722,16 +6721,16 @@ static bool PeepFindRideToLookAt(Peep* peep, uint8_t edge, RideId* rideToView, u if (tileElement->IsGhost()) continue; } - if (tileElement->GetClearanceZ() + (1 * kCoordsZStep) < peep->NextLoc.z) + if (tileElement->GetClearanceZ() + (1 * kCoordsZStep) < guest.NextLoc.z) continue; - if (peep->NextLoc.z + (8 * kCoordsZStep) < tileElement->GetBaseZ()) + if (guest.NextLoc.z + (8 * kCoordsZStep) < tileElement->GetBaseZ()) continue; if (tileElement->GetType() == TileElementType::Track) { if (PeepShouldWatchRide(tileElement)) { - return Loc690FD0(peep, rideToView, rideSeatToView, tileElement); + return Loc690FD0(guest, rideToView, rideSeatToView, tileElement); } } @@ -6744,7 +6743,7 @@ static bool PeepFindRideToLookAt(Peep* peep, uint8_t edge, RideId* rideToView, u } *rideSeatToView = 0; - if (tileElement->GetClearanceZ() >= peep->NextLoc.z + (8 * kCoordsZStep)) + if (tileElement->GetClearanceZ() >= guest.NextLoc.z + (8 * kCoordsZStep)) { *rideSeatToView = 0x02; } @@ -6766,9 +6765,9 @@ static bool PeepFindRideToLookAt(Peep* peep, uint8_t edge, RideId* rideToView, u if (tileElement->IsGhost()) continue; } - if (tileElement->GetClearanceZ() + (1 * kCoordsZStep) < peep->NextLoc.z) + if (tileElement->GetClearanceZ() + (1 * kCoordsZStep) < guest.NextLoc.z) continue; - if (peep->NextLoc.z + (8 * kCoordsZStep) < tileElement->GetBaseZ()) + if (guest.NextLoc.z + (8 * kCoordsZStep) < tileElement->GetBaseZ()) continue; if (tileElement->GetType() == TileElementType::Surface) continue; @@ -6819,9 +6818,9 @@ static bool PeepFindRideToLookAt(Peep* peep, uint8_t edge, RideId* rideToView, u auto wallEntry = tileElement->AsWall()->GetEntry(); if (wallEntry == nullptr || (wallEntry->flags2 & WALL_SCENERY_2_IS_OPAQUE)) continue; - if (peep->NextLoc.z + (8 * kCoordsZStep) <= tileElement->GetBaseZ()) + if (guest.NextLoc.z + (8 * kCoordsZStep) <= tileElement->GetBaseZ()) continue; - if (peep->NextLoc.z >= tileElement->GetClearanceZ()) + if (guest.NextLoc.z >= tileElement->GetClearanceZ()) continue; return false; @@ -6838,16 +6837,16 @@ static bool PeepFindRideToLookAt(Peep* peep, uint8_t edge, RideId* rideToView, u if (tileElement->IsGhost()) continue; } - if (tileElement->GetClearanceZ() + (1 * kCoordsZStep) < peep->NextLoc.z) + if (tileElement->GetClearanceZ() + (1 * kCoordsZStep) < guest.NextLoc.z) continue; - if (peep->NextLoc.z + (10 * kCoordsZStep) < tileElement->GetBaseZ()) + if (guest.NextLoc.z + (10 * kCoordsZStep) < tileElement->GetBaseZ()) continue; if (tileElement->GetType() == TileElementType::Track) { if (PeepShouldWatchRide(tileElement)) { - return Loc690FD0(peep, rideToView, rideSeatToView, tileElement); + return Loc690FD0(guest, rideToView, rideSeatToView, tileElement); } } @@ -6860,7 +6859,7 @@ static bool PeepFindRideToLookAt(Peep* peep, uint8_t edge, RideId* rideToView, u } *rideSeatToView = 0; - if (tileElement->GetClearanceZ() >= peep->NextLoc.z + (8 * kCoordsZStep)) + if (tileElement->GetClearanceZ() >= guest.NextLoc.z + (8 * kCoordsZStep)) { *rideSeatToView = 0x02; } diff --git a/src/openrct2/entity/Guest.h b/src/openrct2/entity/Guest.h index 5f6d0c8072..ccad7d1455 100644 --- a/src/openrct2/entity/Guest.h +++ b/src/openrct2/entity/Guest.h @@ -466,9 +466,9 @@ void IncrementGuestsHeadingForPark(); void DecrementGuestsInPark(); void DecrementGuestsHeadingForPark(); -void PeepUpdateRideLeaveEntranceMaze(Guest* peep, Ride& ride, CoordsXYZD& entrance_loc); -void PeepUpdateRideLeaveEntranceSpiralSlide(Guest* peep, Ride& ride, CoordsXYZD& entrance_loc); -void PeepUpdateRideLeaveEntranceDefault(Guest* peep, Ride& ride, CoordsXYZD& entrance_loc); +void PeepUpdateRideLeaveEntranceMaze(Guest& peep, Ride& ride, CoordsXYZD& entrance_loc); +void PeepUpdateRideLeaveEntranceSpiralSlide(Guest& peep, Ride& ride, CoordsXYZD& entrance_loc); +void PeepUpdateRideLeaveEntranceDefault(Guest& peep, Ride& ride, CoordsXYZD& entrance_loc); CoordsXY GetGuestWaypointLocationDefault(const Vehicle& vehicle, const Ride& ride, const StationIndex& CurrentRideStation); CoordsXY GetGuestWaypointLocationEnterprise(const Vehicle& vehicle, const Ride& ride, const StationIndex& CurrentRideStation); diff --git a/src/openrct2/ride/RideData.h b/src/openrct2/ride/RideData.h index 18261f6e7a..ef310540f4 100644 --- a/src/openrct2/ride/RideData.h +++ b/src/openrct2/ride/RideData.h @@ -270,7 +270,7 @@ struct UpkeepCostsDescriptor using RideTrackGroups = OpenRCT2::BitSet; using UpdateRideApproachVehicleWaypointsFunction = void (*)(Guest&, const CoordsXY&, int16_t&); using RideMusicUpdateFunction = void (*)(Ride&); -using PeepUpdateRideLeaveEntranceFunc = void (*)(Guest*, Ride&, CoordsXYZD&); +using PeepUpdateRideLeaveEntranceFunc = void (*)(Guest&, Ride&, CoordsXYZD&); using StartRideMusicFunction = void (*)(const OpenRCT2::RideAudio::ViewportRideMusicInstance&); using LightFXAddLightsMagicVehicleFunction = void (*)(const Vehicle* vehicle); using RideLocationFunction = CoordsXY (*)(const Vehicle& vehicle, const Ride& ride, const StationIndex& CurrentRideStation);