From 9afbfe02ab31e996b48667ce4f83d6c49b6fa2dd Mon Sep 17 00:00:00 2001 From: Ted John Date: Sat, 6 Jan 2018 13:39:08 +0000 Subject: [PATCH] Add new helper to check if raining --- src/openrct2/peep/Peep.cpp | 10 +++++----- src/openrct2/ride/Ride.cpp | 2 +- src/openrct2/world/Climate.cpp | 5 +++++ src/openrct2/world/Climate.h | 1 + 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/openrct2/peep/Peep.cpp b/src/openrct2/peep/Peep.cpp index 9e08c25da4..1376b8099e 100644 --- a/src/openrct2/peep/Peep.cpp +++ b/src/openrct2/peep/Peep.cpp @@ -1899,7 +1899,7 @@ void peep_update_sprite_type(rct_peep * peep) peep->window_invalidate_flags |= PEEP_INVALIDATE_PEEP_INVENTORY; } - if (gClimateCurrent.RainLevel != RAIN_LEVEL_NONE && (peep->item_standard_flags & PEEP_ITEM_UMBRELLA) && peep->x != LOCATION_NULL) + if (climate_is_raining() && (peep->item_standard_flags & PEEP_ITEM_UMBRELLA) && peep->x != LOCATION_NULL) { sint32 x = peep->x & 0xFFE0; sint32 y = peep->y & 0xFFE0; @@ -12152,7 +12152,7 @@ static bool peep_decide_and_buy_item(rct_peep * peep, sint32 rideIndex, sint32 s if ((shopItem == SHOP_ITEM_BALLOON) || (shopItem == SHOP_ITEM_ICE_CREAM) || (shopItem == SHOP_ITEM_CANDYFLOSS) || (shopItem == SHOP_ITEM_SUNGLASSES)) { - if (gClimateCurrent.RainLevel != RAIN_LEVEL_NONE) + if (climate_is_raining()) return false; } @@ -12174,7 +12174,7 @@ static bool peep_decide_and_buy_item(rct_peep * peep, sint32 rideIndex, sint32 s return false; } - if ((shopItem == SHOP_ITEM_UMBRELLA) && (gClimateCurrent.RainLevel != RAIN_LEVEL_NONE)) + if (shopItem == SHOP_ITEM_UMBRELLA && climate_is_raining()) goto loc_69B119; if ((shopItem != SHOP_ITEM_MAP) && shop_item_is_souvenir(shopItem) && !has_voucher) @@ -12214,7 +12214,7 @@ loc_69B119: value -= price; if (shopItem == SHOP_ITEM_UMBRELLA) { - if (gClimateCurrent.RainLevel != RAIN_LEVEL_NONE) + if (climate_is_raining()) goto loc_69B221; } @@ -13199,7 +13199,7 @@ static bool peep_should_go_on_ride(rct_peep * peep, sint32 rideIndex, sint32 ent // Peeps won't go on rides that aren't sufficiently undercover while it's raining. // The threshold is fairly low and only requires about 10-15% of the ride to be undercover. - if (gClimateCurrent.RainLevel != RAIN_LEVEL_NONE && (ride->sheltered_eighths >> 5) < 3) + if (climate_is_raining() && (ride->sheltered_eighths >> 5) < 3) { if (peepAtRide) { diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index a96500cdfc..bd4621613d 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -2353,7 +2353,7 @@ static sint32 ride_get_new_breakdown_problem(Ride *ride) rct_ride_entry *entry; // Brake failure is more likely when it's raining - _breakdownProblemProbabilities[BREAKDOWN_BRAKES_FAILURE] = gClimateCurrent.RainLevel == RAIN_LEVEL_NONE ? 3 : 20; + _breakdownProblemProbabilities[BREAKDOWN_BRAKES_FAILURE] = climate_is_raining() ? 20 : 3; entry = get_ride_entry_by_ride(ride); if (entry == nullptr || entry->flags & RIDE_ENTRY_FLAG_CANNOT_BREAK_DOWN) diff --git a/src/openrct2/world/Climate.cpp b/src/openrct2/world/Climate.cpp index f00b77bd50..59ea981708 100644 --- a/src/openrct2/world/Climate.cpp +++ b/src/openrct2/world/Climate.cpp @@ -221,6 +221,11 @@ extern "C" } } +bool climate_is_raining() +{ + return gClimateCurrent.RainLevel != RAIN_LEVEL_NONE; +} + uint32 climate_get_weather_sprite_id(const ClimateState &state) { uint32 spriteId = SPR_WEATHER_SUN; diff --git a/src/openrct2/world/Climate.h b/src/openrct2/world/Climate.h index 15abcd7ea7..a98537dee1 100644 --- a/src/openrct2/world/Climate.h +++ b/src/openrct2/world/Climate.h @@ -91,6 +91,7 @@ extern "C" #ifdef __cplusplus } +bool climate_is_raining(); uint32 climate_get_weather_sprite_id(const ClimateState &state); #endif