From bac55381783ab3ff1d795b445a973a7b0ff081e2 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 24 Apr 2016 10:36:56 +0100 Subject: [PATCH] add global macro: gTotalRideValue --- src/management/award.c | 6 +++--- src/ride/ride.h | 2 ++ src/scenario.c | 6 +++--- src/world/park.c | 12 +++++++----- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/management/award.c b/src/management/award.c index 2dbc0bd5e1..91bf9fc707 100644 --- a/src/management/award.c +++ b/src/management/award.c @@ -164,9 +164,9 @@ static int award_is_deserved_best_value(int awardType, int activeAwardTypes) return 0; if (gParkFlags & (PARK_FLAGS_NO_MONEY | PARK_FLAGS_PARK_FREE_ENTRY)) return 0; - if (RCT2_GLOBAL(RCT2_TOTAL_RIDE_VALUE, money16) < MONEY(10, 00)) + if (gTotalRideValue < MONEY(10, 00)) return 0; - if (gParkEntranceFee + MONEY(0, 10) >= RCT2_GLOBAL(RCT2_TOTAL_RIDE_VALUE, money16) / 2) + if (gParkEntranceFee + MONEY(0, 10) >= gTotalRideValue / 2) return 0; return 1; } @@ -216,7 +216,7 @@ static int award_is_deserved_worse_value(int awardType, int activeAwardTypes) return 0; if (gParkEntranceFee == MONEY(0, 00)) return 0; - if (RCT2_GLOBAL(RCT2_TOTAL_RIDE_VALUE, money16) >= gParkEntranceFee) + if (gTotalRideValue >= gParkEntranceFee) return 0; return 1; } diff --git a/src/ride/ride.h b/src/ride/ride.h index eefe3a6046..65895e13c0 100644 --- a/src/ride/ride.h +++ b/src/ride/ride.h @@ -884,6 +884,8 @@ rct_ride_measurement *get_ride_measurement(int index); for (i = 0; i < MAX_RIDES; i++) \ if ((ride = get_ride(i))->type != RIDE_TYPE_NULL) +#define gTotalRideValue RCT2_GLOBAL(RCT2_TOTAL_RIDE_VALUE, money16) + extern const uint8 gRideClassifications[255]; extern money32 _currentTrackPrice; diff --git a/src/scenario.c b/src/scenario.c index 4c21de66e0..03be9ef10c 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -464,9 +464,9 @@ void scenario_success_submit_name(const char *name) void scenario_entrance_fee_too_high_check() { uint16 x = 0, y = 0; - uint16 totalRideValue = RCT2_GLOBAL(RCT2_TOTAL_RIDE_VALUE, uint16); - uint16 park_entrance_fee = gParkEntranceFee; - int max_fee = totalRideValue + (totalRideValue / 2); + money16 totalRideValue = gTotalRideValue; + money16 park_entrance_fee = gParkEntranceFee; + money16 max_fee = totalRideValue + (totalRideValue / 2); uint32 game_flags = gParkFlags, packed_xy; if ((game_flags & PARK_FLAGS_PARK_OPEN) && !(game_flags & PARK_FLAGS_NO_MONEY) && park_entrance_fee > max_fee) { diff --git a/src/world/park.c b/src/world/park.c index 0124629156..ed2de70ca7 100644 --- a/src/world/park.c +++ b/src/world/park.c @@ -86,7 +86,7 @@ void park_init() gGuestChangeModifier = 0; gParkRating = 0; _guestGenerationProbability = 0; - RCT2_GLOBAL(RCT2_TOTAL_RIDE_VALUE, uint16) = 0; + gTotalRideValue = 0; RCT2_GLOBAL(RCT2_ADDRESS_LAST_RESEARCHED_ITEM_SUBJECT, sint32) = -1; for (i = 0; i < 20; i++) @@ -358,7 +358,8 @@ void reset_park_entrances() static int park_calculate_guest_generation_probability() { unsigned int probability; - int i, suggestedMaxGuests, totalRideValue; + int i, suggestedMaxGuests; + money16 totalRideValue; rct_ride *ride; // Calculate suggested guest maximum (based on ride type) and total ride value @@ -377,9 +378,10 @@ static int park_calculate_guest_generation_probability() // Add ride value if (ride->value != RIDE_VALUE_UNDEFINED) { - int rideValue = ride->value - ride->price; - if (rideValue > 0) + money16 rideValue = (money16)(ride->value - ride->price); + if (rideValue > 0) { totalRideValue += rideValue * 2; + } } } @@ -409,7 +411,7 @@ static int park_calculate_guest_generation_probability() } suggestedMaxGuests = min(suggestedMaxGuests, 65535); - RCT2_GLOBAL(RCT2_TOTAL_RIDE_VALUE, uint16) = totalRideValue; + gTotalRideValue = totalRideValue; _suggestedGuestMaximum = suggestedMaxGuests; // Begin with 50 + park rating