From ac06d9940811e802ab428d753ae0d8cbfe6824f3 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Sat, 1 Mar 2025 16:10:06 +0100 Subject: [PATCH] Fix snow transitions using rain animations --- src/openrct2/drawing/Weather.cpp | 39 ++++++++++++++++---------------- src/openrct2/world/Climate.cpp | 6 +++++ src/openrct2/world/Climate.h | 1 + 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/openrct2/drawing/Weather.cpp b/src/openrct2/drawing/Weather.cpp index 340b7d76dd..4e1dedbd74 100644 --- a/src/openrct2/drawing/Weather.cpp +++ b/src/openrct2/drawing/Weather.cpp @@ -53,27 +53,28 @@ const DrawWeatherFunc DrawSnowFunctions[] = { */ void DrawWeather(DrawPixelInfo& dpi, IWeatherDrawer* weatherDrawer) { - if (Config::Get().general.RenderWeatherEffects) + if (!Config::Get().general.RenderWeatherEffects) + return; + + uint32_t viewFlags = 0; + + const auto* viewport = WindowGetViewport(WindowGetMain()); + if (viewport != nullptr) + viewFlags = viewport->flags; + + auto weatherLevel = GetGameState().WeatherCurrent.level; + if (weatherLevel == WeatherLevel::None || gTrackDesignSaveMode || (viewFlags & VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES)) + return; + + // Get weather draw function and draw weather + auto drawFunc = DrawRainFunctions[EnumValue(weatherLevel)]; + if (ClimateIsSnowing() || ClimateTransitioningToSnow()) { - uint32_t viewFlags = 0; - - const auto* viewport = WindowGetViewport(WindowGetMain()); - if (viewport != nullptr) - viewFlags = viewport->flags; - - // Get weather draw function and draw weather - auto weatherLevel = GetGameState().WeatherCurrent.level; - if (weatherLevel != WeatherLevel::None && !gTrackDesignSaveMode && !(viewFlags & VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES)) - { - auto drawFunc = DrawRainFunctions[EnumValue(weatherLevel)]; - if (ClimateIsSnowing()) - { - drawFunc = DrawSnowFunctions[EnumValue(weatherLevel)]; - } - auto uiContext = GetContext()->GetUiContext(); - uiContext->DrawWeatherAnimation(weatherDrawer, dpi, drawFunc); - } + drawFunc = DrawSnowFunctions[EnumValue(weatherLevel)]; } + + auto uiContext = GetContext()->GetUiContext(); + uiContext->DrawWeatherAnimation(weatherDrawer, dpi, drawFunc); } /** diff --git a/src/openrct2/world/Climate.cpp b/src/openrct2/world/Climate.cpp index 00c19e2d7e..f580bf291a 100644 --- a/src/openrct2/world/Climate.cpp +++ b/src/openrct2/world/Climate.cpp @@ -256,6 +256,12 @@ bool ClimateIsSnowing() return weather == WeatherType::Snow || weather == WeatherType::HeavySnow || weather == WeatherType::Blizzard; } +bool ClimateTransitioningToSnow() +{ + auto& weather = GetGameState().WeatherNext.weatherType; + return weather == WeatherType::Snow || weather == WeatherType::HeavySnow || weather == WeatherType::Blizzard; +} + bool ClimateIsSnowingHeavily() { auto& weather = GetGameState().WeatherCurrent.weatherType; diff --git a/src/openrct2/world/Climate.h b/src/openrct2/world/Climate.h index ec1cbb5116..1bf2794e13 100644 --- a/src/openrct2/world/Climate.h +++ b/src/openrct2/world/Climate.h @@ -88,6 +88,7 @@ void ClimateForceWeather(WeatherType weather); enum class FilterPaletteID : int32_t; bool ClimateIsRaining(); +bool ClimateTransitioningToSnow(); bool ClimateIsSnowing(); bool ClimateIsSnowingHeavily(); bool WeatherIsDry(WeatherType);