From 6bd34c1e55d8db5bde13be6e6e40adcf53fd9623 Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Tue, 16 May 2017 22:36:48 +0200 Subject: [PATCH] Clean up sub_69101A, use constants for undefined excitement ratings, fixes #5481 --- src/openrct2/management/award.c | 2 +- src/openrct2/peep/peep.c | 33 +++++++++++++++++---------------- src/openrct2/ride/ride.c | 2 +- src/openrct2/windows/ride.c | 8 ++++---- src/openrct2/world/park.c | 2 +- 5 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/openrct2/management/award.c b/src/openrct2/management/award.c index f434d6e6d7..0cc0c6f159 100644 --- a/src/openrct2/management/award.c +++ b/src/openrct2/management/award.c @@ -441,7 +441,7 @@ static sint32 award_is_deserved_most_disappointing(sint32 awardType, sint32 acti disappointingRides = 0; FOR_ALL_RIDES(i, ride) { - if (ride->excitement == (ride_rating)(uint16)0xFFFF || ride->popularity == 0xFF) + if (ride->excitement == RIDE_RATING_UNDEFINED || ride->popularity == 0xFF) continue; countedRides++; diff --git a/src/openrct2/peep/peep.c b/src/openrct2/peep/peep.c index a1f5eebf24..1110a81a55 100644 --- a/src/openrct2/peep/peep.c +++ b/src/openrct2/peep/peep.c @@ -11310,37 +11310,38 @@ static void peep_easter_egg_peep_interactions(rct_peep *peep) * * @return (CF) */ -static bool sub_69101A(rct_map_element *esi) { - rct_ride *ride = get_ride(esi->properties.track.ride_index); +static bool peep_should_watch_ride(rct_map_element *mapElement) { + rct_ride *ride = get_ride(mapElement->properties.track.ride_index); if (gRideClassifications[ride->type] != RIDE_CLASS_RIDE) { + return false; + } + + // This is most likely to have peeps watch new rides + if (ride->excitement == RIDE_RATING_UNDEFINED) { return true; } - if ((uint16) ride->excitement == 0xFFFF) { - return false; - } - if (ride->excitement >= RIDE_RATING(4, 70)) { - return false; + return true; } if (ride->intensity >= RIDE_RATING(4, 50)) { - return false; + return true; } if (RideData4[ride->type].flags & RIDE_TYPE_FLAG4_INTERESTING_TO_LOOK_AT) { if ((scenario_rand() & 0xFFFF) > 0x3333) { - return true; + return false; } } else if (RideData4[ride->type].flags & RIDE_TYPE_FLAG4_SLIGHTLY_INTERESTING_TO_LOOK_AT) { if ((scenario_rand() & 0xFFFF) > 0x1000) { - return true; + return false; } } else { - return true; + return false; } - return false; + return true; } /** @@ -11400,7 +11401,7 @@ static bool peep_find_ride_to_look_at(rct_peep *peep, uint8 edge, uint8 *rideToV if (peep->next_z + 6 < mapElement->base_height) continue; if (map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_TRACK) { - if (!sub_69101A(mapElement)) { + if (peep_should_watch_ride(mapElement)) { return loc_690FD0(peep, rideToView, rideSeatToView, mapElement); } } @@ -11469,7 +11470,7 @@ static bool peep_find_ride_to_look_at(rct_peep *peep, uint8 edge, uint8 *rideToV if (peep->next_z + 8 < mapElement->base_height) continue; if (map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_TRACK) { - if (!sub_69101A(mapElement)) { + if (peep_should_watch_ride(mapElement)) { return loc_690FD0(peep, rideToView, rideSeatToView, mapElement); } } @@ -11537,7 +11538,7 @@ static bool peep_find_ride_to_look_at(rct_peep *peep, uint8 edge, uint8 *rideToV if (peep->next_z + 10 < mapElement->base_height) continue; if (map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_TRACK) { - if (!sub_69101A(mapElement)) { + if (peep_should_watch_ride(mapElement)) { return loc_690FD0(peep, rideToView, rideSeatToView, mapElement); } } @@ -11565,7 +11566,7 @@ bool loc_690FD0(rct_peep *peep, uint8 *rideToView, uint8 *rideSeatToView, rct_ma rct_ride *ride = get_ride(esi->properties.track.ride_index); *rideToView = esi->properties.track.ride_index; - if ((uint16) ride->excitement == 0xFFFF) { + if (ride->excitement == RIDE_RATING_UNDEFINED) { *rideSeatToView = 1; if (ride->status != RIDE_STATUS_OPEN) { if (esi->clearance_height > peep->next_z + 8) { diff --git a/src/openrct2/ride/ride.c b/src/openrct2/ride/ride.c index ee591ad052..8d5b12707b 100644 --- a/src/openrct2/ride/ride.c +++ b/src/openrct2/ride/ride.c @@ -7280,7 +7280,7 @@ void invalidate_test_results(sint32 rideIndex) rct_ride *ride = get_ride(rideIndex); ride_measurement_clear(ride); - ride->excitement = 0xFFFF; + ride->excitement = RIDE_RATING_UNDEFINED; ride->lifecycle_flags &= ~RIDE_LIFECYCLE_TESTED; ride->lifecycle_flags &= ~RIDE_LIFECYCLE_TEST_IN_PROGRESS; if (ride->lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK) { diff --git a/src/openrct2/windows/ride.c b/src/openrct2/windows/ride.c index 7444f39670..e56cc425d5 100644 --- a/src/openrct2/windows/ride.c +++ b/src/openrct2/windows/ride.c @@ -5202,7 +5202,7 @@ static void window_ride_measurements_invalidate(rct_window *w) window_ride_measurements_widgets[WIDX_SAVE_TRACK_DESIGN].type = WWT_FLATBTN; w->disabled_widgets |= (1 << WIDX_SAVE_TRACK_DESIGN); if (ride->lifecycle_flags & RIDE_LIFECYCLE_TESTED) { - if (ride->excitement != -1) { + if (ride->excitement != RIDE_RATING_UNDEFINED) { w->disabled_widgets &= ~(1 << WIDX_SAVE_TRACK_DESIGN); window_ride_measurements_widgets[WIDX_SAVE_TRACK_DESIGN].tooltip = STR_SAVE_TRACK_DESIGN; } @@ -5245,7 +5245,7 @@ static void window_ride_measurements_paint(rct_window *w, rct_drawpixelinfo *dpi // Excitement set_format_arg(0, uint32, ride->excitement); set_format_arg(4, rct_string_id, RatingNames[min(ride->excitement >> 8, 5)]); - rct_string_id stringId = ride->excitement == -1 ? STR_EXCITEMENT_RATING_NOT_YET_AVAILABLE : STR_EXCITEMENT_RATING; + rct_string_id stringId = ride->excitement == RIDE_RATING_UNDEFINED ? STR_EXCITEMENT_RATING_NOT_YET_AVAILABLE : STR_EXCITEMENT_RATING; gfx_draw_string_left(dpi, stringId, gCommonFormatArgs, COLOUR_BLACK, x, y); y += 10; @@ -5254,7 +5254,7 @@ static void window_ride_measurements_paint(rct_window *w, rct_drawpixelinfo *dpi set_format_arg(4, rct_string_id, RatingNames[min(ride->intensity >> 8, 5)]); stringId = STR_INTENSITY_RATING; - if (ride->excitement == -1) + if (ride->excitement == RIDE_RATING_UNDEFINED) stringId = STR_INTENSITY_RATING_NOT_YET_AVAILABLE; else if (ride->intensity >= RIDE_RATING(10,00)) stringId = STR_INTENSITY_RATING_RED; @@ -5265,7 +5265,7 @@ static void window_ride_measurements_paint(rct_window *w, rct_drawpixelinfo *dpi // Nausea set_format_arg(0, uint32, ride->nausea); set_format_arg(4, rct_string_id, RatingNames[min(ride->nausea >> 8, 5)]); - stringId = ride->excitement == -1 ? STR_NAUSEA_RATING_NOT_YET_AVAILABLE : STR_NAUSEA_RATING; + stringId = ride->excitement == RIDE_RATING_UNDEFINED ? STR_NAUSEA_RATING_NOT_YET_AVAILABLE : STR_NAUSEA_RATING; gfx_draw_string_left(dpi, stringId, gCommonFormatArgs, COLOUR_BLACK, x, y); y += 20; diff --git a/src/openrct2/world/park.c b/src/openrct2/world/park.c index 39a9bfdbb1..c0f1933ea8 100644 --- a/src/openrct2/world/park.c +++ b/src/openrct2/world/park.c @@ -240,7 +240,7 @@ sint32 calculate_park_rating() FOR_ALL_RIDES(i, ride) { total_ride_uptime += 100 - ride->downtime; - if (ride->excitement != -1){ + if (ride->excitement != RIDE_RATING_UNDEFINED){ total_ride_excitement += ride->excitement / 8; total_ride_intensity += ride->intensity / 8; num_exciting_rides++;