Move ride_update_satisfaction() to method

This commit is contained in:
Gymnasiast 2021-12-12 12:12:03 +01:00
parent 2f20dc029e
commit 6df7c1e3b0
No known key found for this signature in database
GPG Key ID: DBFFF47AB2CA3EDD
3 changed files with 15 additions and 13 deletions

View File

@ -1605,7 +1605,7 @@ bool Guest::DecideAndBuyItem(Ride* ride, ShopItem shopItem, money32 price)
satisfaction++; satisfaction++;
} }
} }
ride_update_satisfaction(ride, satisfaction); ride->UpdateSatisfaction(satisfaction);
} }
// The peep has now decided to buy the item (or, specifically, has not been // The peep has now decided to buy the item (or, specifically, has not been
@ -1724,7 +1724,7 @@ void Guest::OnEnterRide(Ride* ride)
else if (satisfaction >= 0) else if (satisfaction >= 0)
rideSatisfaction = 1; rideSatisfaction = 1;
ride_update_satisfaction(ride, rideSatisfaction); ride->UpdateSatisfaction(rideSatisfaction);
// Update various peep stats. // Update various peep stats.
if (GuestNumRides < 255) if (GuestNumRides < 255)
@ -3286,7 +3286,7 @@ static bool peep_should_use_cash_machine(Guest* peep, ride_id_t rideIndex)
auto ride = get_ride(rideIndex); auto ride = get_ride(rideIndex);
if (ride != nullptr) if (ride != nullptr)
{ {
ride_update_satisfaction(ride, peep->Happiness >> 6); ride->UpdateSatisfaction(peep->Happiness >> 6);
ride->cur_num_customers++; ride->cur_num_customers++;
ride->total_customers++; ride->total_customers++;
ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_CUSTOMER; ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_CUSTOMER;
@ -5051,7 +5051,7 @@ void Guest::UpdateRideShopLeave()
{ {
ride->total_customers++; ride->total_customers++;
ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_CUSTOMER; ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_CUSTOMER;
ride_update_satisfaction(ride, Happiness / 64); ride->UpdateSatisfaction(Happiness / 64);
} }
} }

View File

@ -1087,16 +1087,16 @@ void Ride::UpdateChairlift()
* edi: ride (in code as bytes offset from start of rides list) * edi: ride (in code as bytes offset from start of rides list)
* bl: happiness * bl: happiness
*/ */
void ride_update_satisfaction(Ride* ride, uint8_t happiness) void Ride::UpdateSatisfaction(const uint8_t happiness)
{ {
ride->satisfaction_next += happiness; satisfaction_next += happiness;
ride->satisfaction_time_out++; satisfaction_time_out++;
if (ride->satisfaction_time_out >= 20) if (satisfaction_time_out >= 20)
{ {
ride->satisfaction = ride->satisfaction_next >> 2; satisfaction = satisfaction_next >> 2;
ride->satisfaction_next = 0; satisfaction_next = 0;
ride->satisfaction_time_out = 0; satisfaction_time_out = 0;
ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_CUSTOMER; window_invalidate_flags |= RIDE_INVALIDATE_RIDE_CUSTOMER;
} }
} }

View File

@ -374,6 +374,8 @@ public:
* they belong to, to enable merging.) * they belong to, to enable merging.)
*/ */
void UpdateRideTypeForAllPieces(); void UpdateRideTypeForAllPieces();
void UpdateSatisfaction(const uint8_t happiness);
}; };
#pragma pack(push, 1) #pragma pack(push, 1)
@ -1023,7 +1025,7 @@ void ride_init_all();
void reset_all_ride_build_dates(); void reset_all_ride_build_dates();
void ride_update_favourited_stat(); void ride_update_favourited_stat();
void ride_check_all_reachable(); void ride_check_all_reachable();
void ride_update_satisfaction(Ride* ride, uint8_t happiness);
void ride_update_popularity(Ride* ride, uint8_t pop_amount); void ride_update_popularity(Ride* ride, uint8_t pop_amount);
bool ride_try_get_origin_element(const Ride* ride, CoordsXYE* output); bool ride_try_get_origin_element(const Ride* ride, CoordsXYE* output);
int32_t ride_find_track_gap(const Ride* ride, CoordsXYE* input, CoordsXYE* output); int32_t ride_find_track_gap(const Ride* ride, CoordsXYE* input, CoordsXYE* output);