1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-19 21:13:05 +01:00

Close #12448: Refactor RAIN_LEVEL to use strong enum (#12488)

* Close #12448: Refactor RAIN_LEVEL to use strong enum

* Refactor to remove enum suffix
This commit is contained in:
wdarvin
2020-07-28 11:19:45 -05:00
committed by GitHub
parent a55f1947bd
commit 95b4bca3d0
7 changed files with 31 additions and 31 deletions

View File

@@ -866,7 +866,7 @@ void lightfx_apply_palette_filter(uint8_t i, uint8_t* r, uint8_t* g, uint8_t* b)
natLightB *= 1.0f + overExpose;
overExpose *= 255.0f;
float targetFogginess = static_cast<float>(gClimateCurrent.RainLevel) / 8.0f;
float targetFogginess = static_cast<float>(gClimateCurrent.Level) / 8.0f;
targetFogginess += (night * night) * 0.15f;
if (gClimateCurrent.Temperature < 10)
@@ -909,7 +909,7 @@ void lightfx_apply_palette_filter(uint8_t i, uint8_t* r, uint8_t* g, uint8_t* b)
natLightG /= 1.0f + lightPolution;
natLightB /= 1.0f + lightPolution;
reduceColourLit += static_cast<float>(gClimateCurrent.RainLevel) / 2.0f;
reduceColourLit += static_cast<float>(gClimateCurrent.Level) / 2.0f;
reduceColourNat /= 1.0f + fogginess;
reduceColourLit /= 1.0f + fogginess;

View File

@@ -49,10 +49,10 @@ void DrawRain(rct_drawpixelinfo* dpi, IRainDrawer* rainDrawer)
viewFlags = viewport->flags;
// Get rain draw function and draw rain
uint32_t rainType = gClimateCurrent.RainLevel;
if (rainType != RAIN_LEVEL_NONE && !gTrackDesignSaveMode && !(viewFlags & VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES))
RainLevel rainType = gClimateCurrent.Level;
if (rainType != RainLevel::None && !gTrackDesignSaveMode && !(viewFlags & VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES))
{
auto drawFunc = DrawRainFunctions[rainType];
auto drawFunc = DrawRainFunctions[static_cast<int8_t>(rainType)];
auto uiContext = GetContext()->GetUiContext();
uiContext->DrawRainAnimation(rainDrawer, dpi, drawFunc);
}

View File

@@ -2651,12 +2651,12 @@ private:
gClimateCurrent.Weather = _s4.weather;
gClimateCurrent.WeatherEffect = WEATHER_EFFECT_NONE;
gClimateCurrent.WeatherGloom = _s4.weather_gloom;
gClimateCurrent.RainLevel = _s4.rain;
gClimateCurrent.Level = static_cast<RainLevel>(_s4.rain);
gClimateNext.Temperature = _s4.target_temperature;
gClimateNext.Weather = _s4.target_weather;
gClimateNext.WeatherEffect = WEATHER_EFFECT_NONE;
gClimateNext.WeatherGloom = _s4.target_weather_gloom;
gClimateNext.RainLevel = _s4.target_rain;
gClimateNext.Level = static_cast<RainLevel>(_s4.target_rain);
}
void ImportScenarioNameDetails()

View File

@@ -391,8 +391,8 @@ void S6Exporter::Export()
_s6.next_weather_effect = gClimateNext.WeatherEffect;
_s6.current_weather_gloom = gClimateCurrent.WeatherGloom;
_s6.next_weather_gloom = gClimateNext.WeatherGloom;
_s6.current_rain_level = gClimateCurrent.RainLevel;
_s6.next_rain_level = gClimateNext.RainLevel;
_s6.current_rain_level = static_cast<uint8_t>(gClimateCurrent.Level);
_s6.next_rain_level = static_cast<uint8_t>(gClimateNext.Level);
// News items
for (size_t i = 0; i < RCT12_MAX_NEWS_ITEMS; i++)

View File

@@ -418,8 +418,8 @@ public:
gClimateNext.WeatherEffect = _s6.next_weather_effect;
gClimateCurrent.WeatherGloom = _s6.current_weather_gloom;
gClimateNext.WeatherGloom = _s6.next_weather_gloom;
gClimateCurrent.RainLevel = _s6.current_rain_level;
gClimateNext.RainLevel = _s6.next_rain_level;
gClimateCurrent.Level = static_cast<RainLevel>(_s6.current_rain_level);
gClimateNext.Level = static_cast<RainLevel>(_s6.next_rain_level);
// News items
news_item_init_queue();

View File

@@ -91,7 +91,7 @@ void climate_reset(int32_t climate)
gClimateCurrent.Temperature = transition->BaseTemperature + weatherState->TemperatureDelta;
gClimateCurrent.WeatherEffect = weatherState->EffectLevel;
gClimateCurrent.WeatherGloom = weatherState->GloomLevel;
gClimateCurrent.RainLevel = weatherState->RainLevel;
gClimateCurrent.Level = weatherState->Level;
_lightningTimer = 0;
_thunderTimer = 0;
@@ -135,17 +135,17 @@ void climate_update()
_thunderTimer = 0;
_lightningTimer = 0;
if (gClimateCurrent.RainLevel == gClimateNext.RainLevel)
if (gClimateCurrent.Level == gClimateNext.Level)
{
gClimateCurrent.Weather = gClimateNext.Weather;
climate_determine_future_weather(scenario_rand());
auto intent = Intent(INTENT_ACTION_UPDATE_CLIMATE);
context_broadcast_intent(&intent);
}
else if (gClimateNext.RainLevel <= RAIN_LEVEL_HEAVY)
else if (gClimateNext.Level <= RainLevel::Heavy)
{
gClimateCurrent.RainLevel = climate_step_weather_level(
gClimateCurrent.RainLevel, gClimateNext.RainLevel);
gClimateCurrent.Level = static_cast<RainLevel>(climate_step_weather_level(
static_cast<int8_t>(gClimateCurrent.Level), static_cast<int8_t>(gClimateNext.Level)));
}
}
else
@@ -187,7 +187,7 @@ void climate_force_weather(uint8_t weather)
const auto weatherState = &ClimateWeatherData[weather];
gClimateCurrent.Weather = weather;
gClimateCurrent.WeatherGloom = weatherState->GloomLevel;
gClimateCurrent.RainLevel = weatherState->RainLevel;
gClimateCurrent.Level = weatherState->Level;
gClimateCurrent.WeatherEffect = weatherState->EffectLevel;
gClimateUpdateTimer = 1920;
@@ -214,7 +214,7 @@ void climate_update_sound()
bool climate_is_raining()
{
return gClimateCurrent.RainLevel != RAIN_LEVEL_NONE;
return gClimateCurrent.Level != RainLevel::None;
}
FILTER_PALETTE_ID climate_get_weather_gloom_palette_id(const ClimateState& state)
@@ -270,7 +270,7 @@ static void climate_determine_future_weather(int32_t randomDistribution)
gClimateNext.Temperature = transition->BaseTemperature + nextWeatherState->TemperatureDelta;
gClimateNext.WeatherEffect = nextWeatherState->EffectLevel;
gClimateNext.WeatherGloom = nextWeatherState->GloomLevel;
gClimateNext.RainLevel = nextWeatherState->RainLevel;
gClimateNext.Level = nextWeatherState->Level;
gClimateUpdateTimer = 1920;
}
@@ -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, 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
{ 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
};
static constexpr const WeatherTransition ClimateTransitionsCoolAndWet[] = {

View File

@@ -38,11 +38,11 @@ enum WEATHER_EFFECT
WEATHER_EFFECT_STORM,
};
enum RAIN_LEVEL
enum class RainLevel
{
RAIN_LEVEL_NONE,
RAIN_LEVEL_LIGHT,
RAIN_LEVEL_HEAVY,
None,
Light,
Heavy,
};
struct WeatherState
@@ -50,7 +50,7 @@ struct WeatherState
int8_t TemperatureDelta;
int8_t EffectLevel;
int8_t GloomLevel;
int8_t RainLevel;
RainLevel Level;
uint32_t SpriteId;
};
@@ -60,7 +60,7 @@ struct ClimateState
int8_t Temperature;
uint8_t WeatherEffect;
uint8_t WeatherGloom;
uint8_t RainLevel;
RainLevel Level;
};
extern uint8_t gClimate;