diff --git a/src/openrct2-ui/drawing/engines/opengl/OpenGLDrawingEngine.cpp b/src/openrct2-ui/drawing/engines/opengl/OpenGLDrawingEngine.cpp index e0a50f06ea17..a1c12400ccd4 100644 --- a/src/openrct2-ui/drawing/engines/opengl/OpenGLDrawingEngine.cpp +++ b/src/openrct2-ui/drawing/engines/opengl/OpenGLDrawingEngine.cpp @@ -35,6 +35,7 @@ # include # include # include +# include # include # include @@ -137,8 +138,8 @@ class OpenGLWeatherDrawer final : public IWeatherDrawer const uint8_t* weatherpattern) override { const uint8_t* pattern = weatherpattern; - uint8_t patternXSpace = *pattern++; - uint8_t patternYSpace = *pattern++; + auto patternXSpace = *pattern++; + auto patternYSpace = *pattern++; uint8_t patternStartXOffset = xStart % patternXSpace; uint8_t patternStartYOffset = yStart % patternYSpace; @@ -150,7 +151,7 @@ class OpenGLWeatherDrawer final : public IWeatherDrawer for (; height != 0; height--) { - uint8_t patternX = pattern[patternYPos * 2]; + auto patternX = pattern[patternYPos * 2]; if (patternX != 0xFF) { uint32_t finalPixelOffset = width + pixelOffset; @@ -158,7 +159,7 @@ class OpenGLWeatherDrawer final : public IWeatherDrawer uint32_t xPixelOffset = pixelOffset; xPixelOffset += (static_cast(patternX - patternStartXOffset)) % patternXSpace; - uint8_t patternPixel = pattern[patternYPos * 2 + 1]; + auto patternPixel = pattern[patternYPos * 2 + 1]; for (; xPixelOffset < finalPixelOffset; xPixelOffset += patternXSpace) { int32_t pixelX = xPixelOffset % dpi->width; diff --git a/src/openrct2-ui/windows/Cheats.cpp b/src/openrct2-ui/windows/Cheats.cpp index 6a63a506fdca..89ca57c2f281 100644 --- a/src/openrct2-ui/windows/Cheats.cpp +++ b/src/openrct2-ui/windows/Cheats.cpp @@ -637,7 +637,7 @@ static void window_cheats_misc_mousedown(rct_window* w, rct_widgetindex widgetIn w->colours[1], 0, Dropdown::Flag::StayOpen, std::size(WeatherTypes), dropdownWidget->width() - 3); auto currentWeather = gClimateCurrent.Weather; - Dropdown::SetChecked(currentWeather, true); + Dropdown::SetChecked(EnumValue(currentWeather), true); } break; case WIDX_STAFF_SPEED_DROPDOWN_BUTTON: @@ -1087,7 +1087,7 @@ static void window_cheats_invalidate(rct_window* w) } // Current weather - window_cheats_misc_widgets[WIDX_WEATHER].text = WeatherTypes[gClimateCurrent.Weather]; + window_cheats_misc_widgets[WIDX_WEATHER].text = WeatherTypes[EnumValue(gClimateCurrent.Weather)]; // Staff speed window_cheats_misc_widgets[WIDX_STAFF_SPEED].text = _staffSpeedNames[_selectedStaffSpeed]; diff --git a/src/openrct2/actions/SetCheatAction.hpp b/src/openrct2/actions/SetCheatAction.hpp index 826a1d415e3d..bdc5c7941eb2 100644 --- a/src/openrct2/actions/SetCheatAction.hpp +++ b/src/openrct2/actions/SetCheatAction.hpp @@ -204,7 +204,8 @@ DEFINE_GAME_ACTION(SetCheatAction, GAME_COMMAND_CHEAT, GameActions::Result) scenario_success(); break; case CheatType::ForceWeather: - climate_force_weather(_param1); + // Todo - make sure this is safe + climate_force_weather(WeatherType{ static_cast(_param1) }); break; case CheatType::FreezeWeather: gCheatsFreezeWeather = _param1 != 0; @@ -356,7 +357,7 @@ DEFINE_GAME_ACTION(SetCheatAction, GAME_COMMAND_CHEAT, GameActions::Result) case CheatType::SetStaffSpeed: return { { 0, 255 }, { 0, 0 } }; case CheatType::ForceWeather: - return { { 0, WEATHER_COUNT - 1 }, { 0, 0 } }; + return { { 0, EnumValue(WeatherType::Count) - 1 }, { 0, 0 } }; case CheatType::SetForcedParkRating: return { { 0, 999 }, { 0, 0 } }; case CheatType::CreateDucks: diff --git a/src/openrct2/drawing/IDrawingEngine.h b/src/openrct2/drawing/IDrawingEngine.h index 00481138cc19..30fce3193706 100644 --- a/src/openrct2/drawing/IDrawingEngine.h +++ b/src/openrct2/drawing/IDrawingEngine.h @@ -10,6 +10,7 @@ #pragma once #include "../common.h" +#include "./Weather.h" #include #include diff --git a/src/openrct2/drawing/X8DrawingEngine.cpp b/src/openrct2/drawing/X8DrawingEngine.cpp index 6e879316d992..1fdc10603bbc 100644 --- a/src/openrct2/drawing/X8DrawingEngine.cpp +++ b/src/openrct2/drawing/X8DrawingEngine.cpp @@ -17,6 +17,7 @@ #include "../interface/Viewport.h" #include "../interface/Window.h" #include "../ui/UiContext.h" +#include "../util/Util.h" #include "../world/Climate.h" #include "Drawing.h" #include "IDrawingContext.h" @@ -50,8 +51,8 @@ void X8WeatherDrawer::Draw( int32_t x, int32_t y, int32_t width, int32_t height, int32_t xStart, int32_t yStart, const uint8_t* weatherpattern) { const uint8_t* pattern = weatherpattern; - uint8_t patternXSpace = *pattern++; - uint8_t patternYSpace = *pattern++; + auto patternXSpace = *pattern++; + auto patternYSpace = *pattern++; uint8_t patternStartXOffset = xStart % patternXSpace; uint8_t patternStartYOffset = yStart % patternYSpace; @@ -65,7 +66,7 @@ void X8WeatherDrawer::Draw( WeatherPixel* newPixels = &_weatherPixels[_weatherPixelsCount]; for (; height != 0; height--) { - uint8_t patternX = pattern[patternYPos * 2]; + auto patternX = pattern[patternYPos * 2]; if (patternX != 0xFF) { if (_weatherPixelsCount < (_weatherPixelsCapacity - static_cast(width))) @@ -75,7 +76,7 @@ void X8WeatherDrawer::Draw( uint32_t xPixelOffset = pixelOffset; xPixelOffset += (static_cast(patternX - patternStartXOffset)) % patternXSpace; - uint8_t patternPixel = pattern[patternYPos * 2 + 1]; + auto patternPixel = pattern[patternYPos * 2 + 1]; for (; xPixelOffset < finalPixelOffset; xPixelOffset += patternXSpace) { uint8_t current_pixel = screenBits[xPixelOffset]; diff --git a/src/openrct2/interface/Screenshot.cpp b/src/openrct2/interface/Screenshot.cpp index 6b73e3e3a3ae..9370a1e94a83 100644 --- a/src/openrct2/interface/Screenshot.cpp +++ b/src/openrct2/interface/Screenshot.cpp @@ -550,15 +550,9 @@ int32_t cmdline_for_gfxbench(const char** argv, int32_t argc) static void ApplyOptions(const ScreenshotOptions* options, rct_viewport& viewport) { - if (options->weather != 0) + if (options->weather != WeatherType::Sunny && options->weather != WeatherType::Count) { - if (options->weather < 1 || options->weather > 6) - { - throw std::runtime_error("Weather can only be set to an integer value from 1 till 6."); - } - - uint8_t customWeather = options->weather - 1; - climate_force_weather(customWeather); + climate_force_weather(WeatherType{ static_cast(EnumValue(options->weather) - 1) }); } if (options->hide_guests) diff --git a/src/openrct2/interface/Screenshot.h b/src/openrct2/interface/Screenshot.h index 9e73903ec61f..4d74d16d70ed 100644 --- a/src/openrct2/interface/Screenshot.h +++ b/src/openrct2/interface/Screenshot.h @@ -11,6 +11,7 @@ #include "../common.h" #include "../core/FileSystem.hpp" +#include "../world/Climate.h" #include "../world/Location.hpp" #include "ZoomLevel.h" @@ -23,7 +24,7 @@ extern uint8_t gScreenshotCountdown; struct ScreenshotOptions { - int32_t weather = 0; + WeatherType weather = WeatherType::Sunny; bool hide_guests = false; bool hide_sprites = false; bool clear_grass = false; diff --git a/src/openrct2/rct1/RCT1.h b/src/openrct2/rct1/RCT1.h index 222c27bcfcc6..5b614d30816a 100644 --- a/src/openrct2/rct1/RCT1.h +++ b/src/openrct2/rct1/RCT1.h @@ -16,6 +16,7 @@ #include "../rct12/RCT12.h" #include "../ride/Ride.h" #include "../world/Banner.h" +#include "../world/Climate.h" #include "../world/MapAnimation.h" #include "../world/Sprite.h" diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 452ec910c58e..70ff51cfcbdf 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -2680,12 +2680,12 @@ class S4Importer final : public IParkImporter gClimate = ClimateType{ _s4.climate }; gClimateUpdateTimer = _s4.climate_timer; gClimateCurrent.Temperature = _s4.temperature; - gClimateCurrent.Weather = _s4.weather; + gClimateCurrent.Weather = WeatherType{ _s4.weather }; gClimateCurrent.WeatherEffect = WeatherEffectType::None; gClimateCurrent.WeatherGloom = _s4.weather_gloom; gClimateCurrent.Level = static_cast(_s4.rain); gClimateNext.Temperature = _s4.target_temperature; - gClimateNext.Weather = _s4.target_weather; + gClimateNext.Weather = WeatherType{ _s4.target_weather }; gClimateNext.WeatherEffect = WeatherEffectType::None; gClimateNext.WeatherGloom = _s4.target_weather_gloom; gClimateNext.Level = static_cast(_s4.target_rain); diff --git a/src/openrct2/rct2/S6Exporter.cpp b/src/openrct2/rct2/S6Exporter.cpp index ae923391c2d0..8834cdf59f2a 100644 --- a/src/openrct2/rct2/S6Exporter.cpp +++ b/src/openrct2/rct2/S6Exporter.cpp @@ -389,8 +389,8 @@ void S6Exporter::Export() // byte_13CA742 // pad_013CA747 _s6.climate_update_timer = gClimateUpdateTimer; - _s6.current_weather = gClimateCurrent.Weather; - _s6.next_weather = gClimateNext.Weather; + _s6.current_weather = EnumValue(gClimateCurrent.Weather); + _s6.next_weather = EnumValue(gClimateNext.Weather); _s6.temperature = gClimateCurrent.Temperature; _s6.next_temperature = gClimateNext.Temperature; _s6.current_weather_effect = static_cast(gClimateCurrent.WeatherEffect); diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index 7dadfdecd7d1..ed0bfcbf8616 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -415,8 +415,8 @@ class S6Importer final : public IParkImporter // byte_13CA742 // pad_013CA747 gClimateUpdateTimer = _s6.climate_update_timer; - gClimateCurrent.Weather = _s6.current_weather; - gClimateNext.Weather = _s6.next_weather; + gClimateCurrent.Weather = WeatherType{ _s6.current_weather }; + gClimateNext.Weather = WeatherType{ _s6.next_weather }; gClimateCurrent.Temperature = _s6.temperature; gClimateNext.Temperature = _s6.next_temperature; gClimateCurrent.WeatherEffect = WeatherEffectType{ _s6.current_weather_effect }; diff --git a/src/openrct2/scenario/Scenario.h b/src/openrct2/scenario/Scenario.h index 23ed8d54f47c..054e45dff33b 100644 --- a/src/openrct2/scenario/Scenario.h +++ b/src/openrct2/scenario/Scenario.h @@ -20,6 +20,7 @@ #include "../ride/Ride.h" #include "../ride/RideRatings.h" #include "../world/Banner.h" +#include "../world/Climate.h" #include "../world/Map.h" #include "../world/MapAnimation.h" #include "../world/Sprite.h" diff --git a/src/openrct2/world/Climate.cpp b/src/openrct2/world/Climate.cpp index b9e2a0549ef5..3e5317c2206b 100644 --- a/src/openrct2/world/Climate.cpp +++ b/src/openrct2/world/Climate.cpp @@ -39,11 +39,11 @@ struct WeatherTransition { int8_t BaseTemperature; int8_t DistributionSize; - int8_t Distribution[24]; + WeatherType Distribution[24]; }; extern const WeatherTransition* ClimateTransitions[4]; -extern const WeatherState ClimateWeatherData[WEATHER_COUNT]; +extern const WeatherState ClimateWeatherData[EnumValue(WeatherType::Count)]; extern const FILTER_PALETTE_ID ClimateWeatherGloomColours[4]; // Climate data @@ -81,10 +81,10 @@ int32_t climate_celsius_to_fahrenheit(int32_t celsius) */ void climate_reset(ClimateType climate) { - uint8_t weather = WEATHER_PARTIALLY_CLOUDY; + auto weather = WeatherType::PartiallyCloudy; int32_t month = date_get_month(gDateMonthsElapsed); const WeatherTransition* transition = &ClimateTransitions[static_cast(climate)][month]; - const WeatherState* weatherState = &ClimateWeatherData[weather]; + const WeatherState* weatherState = &ClimateWeatherData[EnumValue(weather)]; gClimate = climate; gClimateCurrent.Weather = weather; @@ -184,11 +184,11 @@ void climate_update() } } -void climate_force_weather(uint8_t weather) +void climate_force_weather(WeatherType weather) { int32_t month = date_get_month(gDateMonthsElapsed); const WeatherTransition* transition = &ClimateTransitions[static_cast(gClimate)][month]; - const auto weatherState = &ClimateWeatherData[weather]; + const auto weatherState = &ClimateWeatherData[EnumValue(weather)]; gClimateCurrent.Weather = weather; gClimateCurrent.WeatherGloom = weatherState->GloomLevel; @@ -217,8 +217,8 @@ void climate_update_sound() bool climate_is_raining() { - if (gClimateCurrent.Weather == WEATHER_RAIN || gClimateCurrent.Weather == WEATHER_HEAVY_RAIN - || gClimateCurrent.Weather == WEATHER_THUNDER) + if (gClimateCurrent.Weather == WeatherType::Rain || gClimateCurrent.Weather == WeatherType::HeavyRain + || gClimateCurrent.Weather == WeatherType::Thunder) { return true; } @@ -230,8 +230,8 @@ bool climate_is_raining() bool climate_is_snowing() { - if (gClimateCurrent.Weather == WEATHER_SNOW || gClimateCurrent.Weather == WEATHER_HEAVY_SNOW - || gClimateCurrent.Weather == WEATHER_BLIZZARD) + if (gClimateCurrent.Weather == WeatherType::Snow || gClimateCurrent.Weather == WeatherType::HeavySnow + || gClimateCurrent.Weather == WeatherType::Blizzard) { return true; } @@ -241,6 +241,12 @@ bool climate_is_snowing() } } +bool WeatherIsDry(WeatherType weatherType) +{ + return weatherType == WeatherType::Sunny || weatherType == WeatherType::PartiallyCloudy + || weatherType == WeatherType::Cloudy; +} + FILTER_PALETTE_ID climate_get_weather_gloom_palette_id(const ClimateState& state) { auto paletteId = PALETTE_NULL; @@ -255,9 +261,9 @@ FILTER_PALETTE_ID climate_get_weather_gloom_palette_id(const ClimateState& state uint32_t climate_get_weather_sprite_id(const ClimateState& state) { uint32_t spriteId = SPR_WEATHER_SUN; - if (state.Weather < std::size(ClimateWeatherData)) + if (EnumValue(state.Weather) < std::size(ClimateWeatherData)) { - spriteId = ClimateWeatherData[state.Weather].SpriteId; + spriteId = ClimateWeatherData[EnumValue(state.Weather)].SpriteId; } return spriteId; } @@ -287,10 +293,10 @@ static void climate_determine_future_weather(int32_t randomDistribution) // Generate a random variable with values 0 up to DistributionSize-1 and chose weather from the distribution table // accordingly const WeatherTransition* transition = &ClimateTransitions[static_cast(gClimate)][month]; - int8_t nextWeather = (transition->Distribution[((randomDistribution & 0xFF) * transition->DistributionSize) >> 8]); + WeatherType nextWeather = (transition->Distribution[((randomDistribution & 0xFF) * transition->DistributionSize) >> 8]); gClimateNext.Weather = nextWeather; - const auto nextWeatherState = &ClimateWeatherData[nextWeather]; + const auto nextWeatherState = &ClimateWeatherData[EnumValue(nextWeather)]; gClimateNext.Temperature = transition->BaseTemperature + nextWeatherState->TemperatureDelta; gClimateNext.WeatherEffect = nextWeatherState->EffectLevel; gClimateNext.WeatherGloom = nextWeatherState->GloomLevel; @@ -438,7 +444,7 @@ 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[WEATHER_COUNT] = { +const WeatherState ClimateWeatherData[EnumValue(WeatherType::Count)] = { { 10, WeatherEffectType::None, 0, WeatherLevel::None, SPR_WEATHER_SUN }, // Sunny { 5, WeatherEffectType::None, 0, WeatherLevel::None, SPR_WEATHER_SUN_CLOUD }, // Partially Cloudy { 0, WeatherEffectType::None, 0, WeatherLevel::None, SPR_WEATHER_CLOUD }, // Cloudy @@ -450,45 +456,52 @@ const WeatherState ClimateWeatherData[WEATHER_COUNT] = { { -20, WeatherEffectType::Blizzard, 2, WeatherLevel::Heavy, SPR_WEATHER_SNOW }, // Blizzard }; +constexpr auto S = WeatherType::Sunny; +constexpr auto P = WeatherType::PartiallyCloudy; +constexpr auto C = WeatherType::Cloudy; +constexpr auto R = WeatherType::Rain; +constexpr auto H = WeatherType::HeavyRain; +constexpr auto T = WeatherType::Thunder; + static constexpr const WeatherTransition ClimateTransitionsCoolAndWet[] = { - { 8, 18, { 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 0, 0, 0, 0, 0 } }, - { 10, 21, { 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 0, 0 } }, - { 14, 17, { 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 0, 0, 0, 0, 0, 0 } }, - { 17, 17, { 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 0, 0, 0, 0, 0, 0 } }, - { 19, 23, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 4 } }, - { 20, 23, { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 4, 4, 4, 5 } }, - { 16, 19, { 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 4, 4, 5, 0, 0, 0, 0 } }, - { 13, 16, { 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0 } }, + { 8, 18, { S, P, P, P, P, P, C, C, C, C, C, C, C, R, R, R, H, H, S, S, S, S, S } }, + { 10, 21, { P, P, P, P, P, C, C, C, C, C, C, C, C, C, R, R, R, H, H, H, T, S, S } }, + { 14, 17, { S, S, S, P, P, P, P, P, P, C, C, C, C, R, R, R, H, S, S, S, S, S, S } }, + { 17, 17, { S, S, S, S, P, P, P, P, P, P, P, C, C, C, C, R, R, S, S, S, S, S, S } }, + { 19, 23, { S, S, S, S, S, S, S, S, S, S, P, P, P, P, P, P, C, C, C, C, C, R, H } }, + { 20, 23, { S, S, S, S, S, S, P, P, P, P, P, P, P, P, C, C, C, C, R, H, H, H, T } }, + { 16, 19, { S, S, S, P, P, P, P, P, C, C, C, C, C, C, R, R, H, H, T, S, S, S, S } }, + { 13, 16, { S, S, P, P, P, P, C, C, C, C, C, C, R, R, H, T, S, S, S, S, S, S, S } }, }; static constexpr const WeatherTransition ClimateTransitionsWarm[] = { - { 12, 21, { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 4, 0, 0 } }, - { 13, 22, { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 5, 0 } }, - { 16, 17, { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 0, 0, 0, 0, 0, 0 } }, - { 19, 18, { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 0, 0, 0, 0, 0 } }, - { 21, 22, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 0 } }, - { 22, 17, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 5, 0, 0, 0, 0, 0, 0 } }, - { 19, 17, { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 0, 0, 0, 0, 0, 0 } }, - { 16, 17, { 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 0, 0, 0, 0, 0, 0 } }, + { 12, 21, { S, S, S, S, S, P, P, P, P, P, P, P, P, C, C, C, C, C, C, C, H, S, S } }, + { 13, 22, { S, S, S, S, S, P, P, P, P, P, P, C, C, C, C, C, C, C, C, C, R, T, S } }, + { 16, 17, { S, S, S, S, S, S, P, P, P, P, P, P, C, C, C, C, R, S, S, S, S, S, S } }, + { 19, 18, { S, S, S, S, S, S, P, P, P, P, P, P, P, C, C, C, C, R, S, S, S, S, S } }, + { 21, 22, { S, S, S, S, S, S, S, S, S, S, P, P, P, P, P, P, P, P, P, C, C, C, S } }, + { 22, 17, { S, S, S, S, S, S, S, S, S, P, P, P, P, P, C, C, T, S, S, S, S, S, S } }, + { 19, 17, { S, S, S, S, S, P, P, P, P, P, C, C, C, C, C, C, R, S, S, S, S, S, S } }, + { 16, 17, { S, S, P, P, P, P, P, C, C, C, C, C, C, C, C, C, H, S, S, S, S, S, S } }, }; static constexpr const WeatherTransition ClimateTransitionsHotAndDry[] = { - { 12, 15, { 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0 } }, - { 14, 12, { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, - { 16, 11, { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, - { 19, 9, { 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, - { 21, 13, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, - { 22, 11, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, - { 21, 12, { 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, - { 16, 13, { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, + { 12, 15, { S, S, S, S, P, P, P, P, P, P, P, P, C, C, R, S, S, S, S, S, S, S, S } }, + { 14, 12, { S, S, S, S, S, P, P, P, P, P, C, C, S, S, S, S, S, S, S, S, S, S, S } }, + { 16, 11, { S, S, S, S, S, S, P, P, P, P, C, S, S, S, S, S, S, S, S, S, S, S, S } }, + { 19, 9, { S, S, S, S, S, S, P, P, P, S, S, S, S, S, S, S, S, S, S, S, S, S, S } }, + { 21, 13, { S, S, S, S, S, S, S, S, S, S, P, P, P, S, S, S, S, S, S, S, S, S, S } }, + { 22, 11, { S, S, S, S, S, S, S, S, S, P, P, S, S, S, S, S, S, S, S, S, S, S, S } }, + { 21, 12, { S, S, S, S, S, S, S, P, P, P, C, T, S, S, S, S, S, S, S, S, S, S, S } }, + { 16, 13, { S, S, S, S, S, S, S, S, P, P, P, C, R, S, S, S, S, S, S, S, S, S, S } }, }; static constexpr const WeatherTransition ClimateTransitionsCold[] = { - { 4, 18, { 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 4, 0, 0, 0, 0, 0 } }, - { 5, 21, { 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 4, 5, 0, 0 } }, - { 7, 17, { 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 4, 0, 0, 0, 0, 0, 0 } }, - { 9, 17, { 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 0, 0, 0, 0, 0, 0 } }, - { 10, 23, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 4 } }, - { 11, 23, { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 4, 5 } }, - { 9, 19, { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 4, 5, 0, 0, 0, 0 } }, - { 6, 16, { 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0 } }, + { 4, 18, { S, S, S, S, P, P, P, P, P, C, C, C, C, C, C, C, R, H, S, S, S, S, S } }, + { 5, 21, { S, S, S, S, P, P, P, P, P, C, C, C, C, C, C, C, C, C, R, H, T, S, S } }, + { 7, 17, { S, S, S, S, P, P, P, P, P, P, P, C, C, C, C, R, H, S, S, S, S, S, S } }, + { 9, 17, { S, S, S, S, P, P, P, P, P, P, P, C, C, C, C, R, R, S, S, S, S, S, S } }, + { 10, 23, { S, S, S, S, S, S, S, S, S, S, P, P, P, P, P, P, C, C, C, C, C, R, H } }, + { 11, 23, { S, S, S, S, S, S, P, P, P, P, P, P, P, P, P, P, C, C, C, C, R, H, T } }, + { 9, 19, { S, S, S, S, S, P, P, P, P, P, C, C, C, C, C, C, R, H, T, S, S, S, S } }, + { 6, 16, { S, S, P, P, P, P, C, C, C, C, C, C, R, R, H, T, S, S, S, S, S, S, S } }, }; const WeatherTransition* ClimateTransitions[] = { diff --git a/src/openrct2/world/Climate.h b/src/openrct2/world/Climate.h index f598fa003b1d..bb5ffd44c278 100644 --- a/src/openrct2/world/Climate.h +++ b/src/openrct2/world/Climate.h @@ -11,6 +11,7 @@ #include "../common.h" #include "../drawing/Drawing.h" +#include "../util/Util.h" enum class ClimateType : uint8_t { @@ -21,18 +22,18 @@ enum class ClimateType : uint8_t Count }; -enum WEATHER +enum class WeatherType : uint8_t { - WEATHER_SUNNY, - WEATHER_PARTIALLY_CLOUDY, - WEATHER_CLOUDY, - WEATHER_RAIN, - WEATHER_HEAVY_RAIN, - WEATHER_THUNDER, - WEATHER_SNOW, - WEATHER_HEAVY_SNOW, - WEATHER_BLIZZARD, - WEATHER_COUNT, + Sunny, + PartiallyCloudy, + Cloudy, + Rain, + HeavyRain, + Thunder, + Snow, + HeavySnow, + Blizzard, + Count }; enum class WeatherEffectType : uint8_t @@ -62,7 +63,7 @@ struct WeatherState struct ClimateState { - uint8_t Weather; + WeatherType Weather; int8_t Temperature; WeatherEffectType WeatherEffect; uint8_t WeatherGloom; @@ -79,9 +80,10 @@ int32_t climate_celsius_to_fahrenheit(int32_t celsius); void climate_reset(ClimateType climate); void climate_update(); void climate_update_sound(); -void climate_force_weather(uint8_t weather); +void climate_force_weather(WeatherType weather); bool climate_is_raining(); bool climate_is_snowing(); +bool WeatherIsDry(WeatherType); FILTER_PALETTE_ID climate_get_weather_gloom_palette_id(const ClimateState& state); uint32_t climate_get_weather_sprite_id(const ClimateState& state); diff --git a/src/openrct2/world/Scenery.cpp b/src/openrct2/world/Scenery.cpp index aae9b07afac4..6503b0ffed2b 100644 --- a/src/openrct2/world/Scenery.cpp +++ b/src/openrct2/world/Scenery.cpp @@ -114,8 +114,8 @@ void SmallSceneryElement::UpdateAge(const CoordsXY& sceneryPos) return; } - if (!scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_CAN_BE_WATERED) - || (gClimateCurrent.Weather < WEATHER_RAIN) || GetAge() < 5) + if (!scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_CAN_BE_WATERED) || WeatherIsDry(gClimateCurrent.Weather) + || GetAge() < 5) { IncreaseAge(sceneryPos); return;