1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-22 14:24:33 +01:00

Close #12447: Refactor WEATHER_EFFECT to use strong enum (#12548)

This commit is contained in:
Sidney
2020-08-07 18:10:59 +02:00
committed by GitHub
parent db010cd971
commit 93ef28927f
5 changed files with 20 additions and 20 deletions

View File

@@ -2665,12 +2665,12 @@ private:
gClimateUpdateTimer = _s4.climate_timer;
gClimateCurrent.Temperature = _s4.temperature;
gClimateCurrent.Weather = _s4.weather;
gClimateCurrent.WeatherEffect = WEATHER_EFFECT_NONE;
gClimateCurrent.WeatherEffect = WeatherEffectType::None;
gClimateCurrent.WeatherGloom = _s4.weather_gloom;
gClimateCurrent.Level = static_cast<RainLevel>(_s4.rain);
gClimateNext.Temperature = _s4.target_temperature;
gClimateNext.Weather = _s4.target_weather;
gClimateNext.WeatherEffect = WEATHER_EFFECT_NONE;
gClimateNext.WeatherEffect = WeatherEffectType::None;
gClimateNext.WeatherGloom = _s4.target_weather_gloom;
gClimateNext.Level = static_cast<RainLevel>(_s4.target_rain);
}

View File

@@ -387,8 +387,8 @@ void S6Exporter::Export()
_s6.next_weather = gClimateNext.Weather;
_s6.temperature = gClimateCurrent.Temperature;
_s6.next_temperature = gClimateNext.Temperature;
_s6.current_weather_effect = gClimateCurrent.WeatherEffect;
_s6.next_weather_effect = gClimateNext.WeatherEffect;
_s6.current_weather_effect = static_cast<uint8_t>(gClimateCurrent.WeatherEffect);
_s6.next_weather_effect = static_cast<uint8_t>(gClimateNext.WeatherEffect);
_s6.current_weather_gloom = gClimateCurrent.WeatherGloom;
_s6.next_weather_gloom = gClimateNext.WeatherGloom;
_s6.current_rain_level = static_cast<uint8_t>(gClimateCurrent.Level);

View File

@@ -414,8 +414,8 @@ public:
gClimateNext.Weather = _s6.next_weather;
gClimateCurrent.Temperature = _s6.temperature;
gClimateNext.Temperature = _s6.next_temperature;
gClimateCurrent.WeatherEffect = _s6.current_weather_effect;
gClimateNext.WeatherEffect = _s6.next_weather_effect;
gClimateCurrent.WeatherEffect = WeatherEffectType{ _s6.current_weather_effect };
gClimateNext.WeatherEffect = WeatherEffectType{ _s6.next_weather_effect };
gClimateCurrent.WeatherGloom = _s6.current_weather_gloom;
gClimateNext.WeatherGloom = _s6.next_weather_gloom;
gClimateCurrent.Level = static_cast<RainLevel>(_s6.current_rain_level);

View File

@@ -169,7 +169,7 @@ void climate_update()
climate_update_lightning();
climate_update_thunder();
}
else if (gClimateCurrent.WeatherEffect == WEATHER_EFFECT_STORM)
else if (gClimateCurrent.WeatherEffect == WeatherEffectType::Storm)
{
// Create new thunder and lightning
uint32_t randomNumber = util_rand();
@@ -277,7 +277,7 @@ static void climate_determine_future_weather(int32_t randomDistribution)
static void climate_update_rain_sound()
{
if (gClimateCurrent.WeatherEffect == WEATHER_EFFECT_RAIN || gClimateCurrent.WeatherEffect == WEATHER_EFFECT_STORM)
if (gClimateCurrent.WeatherEffect == WeatherEffectType::Rain || gClimateCurrent.WeatherEffect == WeatherEffectType::Storm)
{
// Start playing the rain sound
if (gRainSoundChannel == nullptr)
@@ -412,12 +412,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, WEATHER_EFFECT_NONE, 0, RainLevel::None, SPR_WEATHER_SUN }, // Sunny
{ 5, WEATHER_EFFECT_NONE, 0, RainLevel::None, SPR_WEATHER_SUN_CLOUD }, // Partially Cloudy
{ 0, WEATHER_EFFECT_NONE, 0, RainLevel::None, SPR_WEATHER_CLOUD }, // Cloudy
{ -2, WEATHER_EFFECT_RAIN, 1, RainLevel::Light, SPR_WEATHER_LIGHT_RAIN }, // Rain
{ -4, WEATHER_EFFECT_RAIN, 2, RainLevel::Heavy, SPR_WEATHER_HEAVY_RAIN }, // Heavy Rain
{ 2, WEATHER_EFFECT_STORM, 2, RainLevel::Heavy, SPR_WEATHER_STORM }, // Thunderstorm
{ 10, WeatherEffectType::None, 0, RainLevel::None, SPR_WEATHER_SUN }, // Sunny
{ 5, WeatherEffectType::None, 0, RainLevel::None, SPR_WEATHER_SUN_CLOUD }, // Partially Cloudy
{ 0, WeatherEffectType::None, 0, RainLevel::None, SPR_WEATHER_CLOUD }, // Cloudy
{ -2, WeatherEffectType::Rain, 1, RainLevel::Light, SPR_WEATHER_LIGHT_RAIN }, // Rain
{ -4, WeatherEffectType::Rain, 2, RainLevel::Heavy, SPR_WEATHER_HEAVY_RAIN }, // Heavy Rain
{ 2, WeatherEffectType::Storm, 2, RainLevel::Heavy, SPR_WEATHER_STORM }, // Thunderstorm
};
static constexpr const WeatherTransition ClimateTransitionsCoolAndWet[] = {

View File

@@ -31,11 +31,11 @@ enum WEATHER
WEATHER_THUNDER,
};
enum WEATHER_EFFECT
enum class WeatherEffectType : uint8_t
{
WEATHER_EFFECT_NONE,
WEATHER_EFFECT_RAIN,
WEATHER_EFFECT_STORM,
None,
Rain,
Storm,
};
enum class RainLevel
@@ -48,7 +48,7 @@ enum class RainLevel
struct WeatherState
{
int8_t TemperatureDelta;
int8_t EffectLevel;
WeatherEffectType EffectLevel;
int8_t GloomLevel;
RainLevel Level;
uint32_t SpriteId;
@@ -58,7 +58,7 @@ struct ClimateState
{
uint8_t Weather;
int8_t Temperature;
uint8_t WeatherEffect;
WeatherEffectType WeatherEffect;
uint8_t WeatherGloom;
RainLevel Level;
};