From 742690b4f48fcff8888f4456cbd23f0bb43b44eb Mon Sep 17 00:00:00 2001 From: Ted John Date: Sat, 6 Jan 2018 13:35:00 +0000 Subject: [PATCH] Add enums for weather effect and rain level --- src/openrct2/drawing/Rain.cpp | 2 +- src/openrct2/peep/Peep.cpp | 10 +++++----- src/openrct2/rct1/S4Importer.cpp | 4 ++-- src/openrct2/ride/Ride.cpp | 2 +- src/openrct2/world/Climate.cpp | 19 ++++++++++--------- src/openrct2/world/Climate.h | 14 ++++++++++++++ 6 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/openrct2/drawing/Rain.cpp b/src/openrct2/drawing/Rain.cpp index 34aed85c5a..8efc47e471 100644 --- a/src/openrct2/drawing/Rain.cpp +++ b/src/openrct2/drawing/Rain.cpp @@ -176,7 +176,7 @@ void DrawRain(rct_drawpixelinfo * dpi, IRainDrawer * rainDrawer) { // Get rain draw function and draw rain uint32 rainType = gClimateCurrent.RainLevel; - if (rainType > 0 && !gTrackDesignSaveMode) + if (rainType != RAIN_LEVEL_NONE && !gTrackDesignSaveMode) { DrawRainAnimation(dpi, rainDrawer, rainType); } diff --git a/src/openrct2/peep/Peep.cpp b/src/openrct2/peep/Peep.cpp index 87b23ec84a..9e08c25da4 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 != 0 && (peep->item_standard_flags & PEEP_ITEM_UMBRELLA) && peep->x != LOCATION_NULL) + if (gClimateCurrent.RainLevel != RAIN_LEVEL_NONE && (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 != 0) + if (gClimateCurrent.RainLevel != RAIN_LEVEL_NONE) 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 != 0)) + if ((shopItem == SHOP_ITEM_UMBRELLA) && (gClimateCurrent.RainLevel != RAIN_LEVEL_NONE)) 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 != 0) + if (gClimateCurrent.RainLevel != RAIN_LEVEL_NONE) 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 != 0 && (ride->sheltered_eighths >> 5) < 3) + if (gClimateCurrent.RainLevel != RAIN_LEVEL_NONE && (ride->sheltered_eighths >> 5) < 3) { if (peepAtRide) { diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 33c12ea4db..e2d69bce1e 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -2171,12 +2171,12 @@ private: gClimateUpdateTimer = _s4.climate_timer; gClimateCurrent.Temperature = _s4.temperature; gClimateCurrent.Weather = _s4.weather; - gClimateCurrent.WeatherEffect = 0; + gClimateCurrent.WeatherEffect = WEATHER_EFFECT_NONE; gClimateCurrent.WeatherGloom = _s4.weather_gloom; gClimateCurrent.RainLevel = _s4.rain; gClimateNext.Temperature = _s4.target_temperature; gClimateNext.Weather = _s4.target_weather; - gClimateNext.WeatherEffect = 0; + gClimateNext.WeatherEffect = WEATHER_EFFECT_NONE; gClimateNext.WeatherGloom = _s4.target_weather_gloom; gClimateNext.RainLevel = _s4.target_rain; } diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index e4ec273262..a96500cdfc 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 == 0 ? 3 : 20; + _breakdownProblemProbabilities[BREAKDOWN_BRAKES_FAILURE] = gClimateCurrent.RainLevel == RAIN_LEVEL_NONE ? 3 : 20; 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 215c45f3de..f00b77bd50 100644 --- a/src/openrct2/world/Climate.cpp +++ b/src/openrct2/world/Climate.cpp @@ -144,7 +144,7 @@ extern "C" climate_determine_future_weather(scenario_rand()); gToolbarDirtyFlags |= BTM_TB_DIRTY_FLAG_CLIMATE; } - else if (gClimateNext.RainLevel <= 2) + else if (gClimateNext.RainLevel <= RAIN_LEVEL_HEAVY) { gClimateCurrent.RainLevel = climate_step_weather_level(gClimateCurrent.RainLevel, gClimateNext.RainLevel); } @@ -169,7 +169,7 @@ extern "C" climate_update_lightning(); climate_update_thunder(); } - else if (gClimateCurrent.WeatherEffect == 2) + else if (gClimateCurrent.WeatherEffect == WEATHER_EFFECT_STORM) { // Create new thunder and lightning uint32 randomNumber = util_rand(); @@ -269,7 +269,8 @@ static void climate_determine_future_weather(sint32 randomDistribution) static void climate_update_rain_sound() { - if (gClimateCurrent.WeatherEffect == 1 || gClimateCurrent.WeatherEffect == 2) + if (gClimateCurrent.WeatherEffect == WEATHER_EFFECT_RAIN || + gClimateCurrent.WeatherEffect == WEATHER_EFFECT_STORM) { // Start playing the rain sound if (gRainSoundChannel == nullptr) @@ -403,12 +404,12 @@ const FILTER_PALETTE_ID ClimateWeatherGloomColours[4] = // There is actually a sprite at 0x5A9C for snow but only these weather types seem to be fully implemented const WeatherState ClimateWeatherData[6] = { - { 10, 0, 0, 0, SPR_WEATHER_SUN }, // Sunny - { 5, 0, 0, 0, SPR_WEATHER_SUN_CLOUD }, // Partially Cloudy - { 0, 0, 0, 0, SPR_WEATHER_CLOUD }, // Cloudy - { -2, 1, 1, 1, SPR_WEATHER_LIGHT_RAIN }, // Rain - { -4, 1, 2, 2, SPR_WEATHER_HEAVY_RAIN }, // Heavy Rain - { 2, 2, 2, 2, SPR_WEATHER_STORM }, // Thunderstorm + { 10, WEATHER_EFFECT_NONE, 0, RAIN_LEVEL_NONE, SPR_WEATHER_SUN }, // Sunny + { 5, WEATHER_EFFECT_NONE, 0, RAIN_LEVEL_NONE, SPR_WEATHER_SUN_CLOUD }, // Partially Cloudy + { 0, WEATHER_EFFECT_NONE, 0, RAIN_LEVEL_NONE, SPR_WEATHER_CLOUD }, // Cloudy + { -2, WEATHER_EFFECT_RAIN, 1, RAIN_LEVEL_LIGHT, SPR_WEATHER_LIGHT_RAIN }, // Rain + { -4, WEATHER_EFFECT_RAIN, 2, RAIN_LEVEL_HEAVY, SPR_WEATHER_HEAVY_RAIN }, // Heavy Rain + { 2, WEATHER_EFFECT_STORM, 2, RAIN_LEVEL_HEAVY, SPR_WEATHER_STORM }, // Thunderstorm }; static constexpr const WeatherTransition ClimateTransitionsCoolAndWet[] = diff --git a/src/openrct2/world/Climate.h b/src/openrct2/world/Climate.h index ef7fc05a84..15abcd7ea7 100644 --- a/src/openrct2/world/Climate.h +++ b/src/openrct2/world/Climate.h @@ -38,6 +38,20 @@ enum WEATHER WEATHER_THUNDER, }; +enum WEATHER_EFFECT +{ + WEATHER_EFFECT_NONE, + WEATHER_EFFECT_RAIN, + WEATHER_EFFECT_STORM, +}; + +enum RAIN_LEVEL +{ + RAIN_LEVEL_NONE, + RAIN_LEVEL_LIGHT, + RAIN_LEVEL_HEAVY, +}; + typedef struct WeatherState { sint8 TemperatureDelta;