1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-04 13:42:55 +01:00

Make ClimateWeatherData and ClimateWeatherGloomColours internal to Climate.cpp

This commit is contained in:
Ted John
2018-01-06 01:20:28 +00:00
committed by Richard Jenkins
parent 83cdd56825
commit 68202db51c
6 changed files with 50 additions and 21 deletions

View File

@@ -585,15 +585,17 @@ static void window_game_bottom_toolbar_draw_right_panel(rct_drawpixelinfo *dpi,
x += 30;
// Current weather
gfx_draw_sprite(dpi, ClimateWeatherData[gClimateCurrent.Weather].SpriteId, x, y, 0);
auto currentWeatherSpriteId = climate_get_weather_sprite_id(gClimateCurrent);
gfx_draw_sprite(dpi, currentWeatherSpriteId, x, y, 0);
// Next weather
if (ClimateWeatherData[gClimateCurrent.Weather].SpriteId != ClimateWeatherData[gClimateNext.Weather].SpriteId)
auto nextWeatherSpriteId = climate_get_weather_sprite_id(gClimateNext);
if (currentWeatherSpriteId != nextWeatherSpriteId)
{
if (gClimateUpdateTimer < 960)
{
gfx_draw_sprite(dpi, SPR_NEXT_WEATHER, x + 27, y + 5, 0);
gfx_draw_sprite(dpi, ClimateWeatherData[gClimateNext.Weather].SpriteId, x + 40, y, 0);
gfx_draw_sprite(dpi, nextWeatherSpriteId, x + 40, y, 0);
}
}
}

View File

@@ -231,12 +231,11 @@ void update_palette_effects()
uint32 shade = 0;
if (gConfigGeneral.render_weather_gloom)
{
uint8 gloom = gClimateCurrent.WeatherGloom;
if (gloom != 0)
auto paletteId = climate_get_weather_gloom_palette_id(&gClimateCurrent);
if (paletteId != PALETTE_NULL)
{
FILTER_PALETTE_ID weatherColour = ClimateWeatherGloomColours[gloom];
shade = 1;
if (weatherColour != PALETTE_DARKEN_1)
if (paletteId != PALETTE_DARKEN_1)
{
shade = 2;
}

View File

@@ -80,6 +80,8 @@ enum {
};
typedef enum {
PALETTE_NULL = 0,
PALETTE_WATER = 32,
PALETTE_34 = 34,

View File

@@ -914,16 +914,16 @@ static void viewport_paint_column(rct_drawpixelinfo * dpi, uint32 viewFlags)
static void viewport_paint_weather_gloom(rct_drawpixelinfo * dpi)
{
uint8 gloom = gClimateCurrent.WeatherGloom;
if (gloom != 0) {
FILTER_PALETTE_ID paletteId = climate_get_weather_gloom_palette_id(&gClimateCurrent);
if (paletteId != PALETTE_NULL)
{
gfx_filter_rect(
dpi,
dpi->x,
dpi->y,
dpi->width + dpi->x - 1,
dpi->height + dpi->y - 1,
ClimateWeatherGloomColours[gloom]
);
paletteId);
}
}

View File

@@ -14,21 +14,21 @@
*****************************************************************************/
#pragma endregion
#include "../config/Config.h"
#include "../core/Math.hpp"
#include "../OpenRCT2.h"
#include "Climate.h"
#include "../audio/audio.h"
#include "../audio/AudioMixer.h"
#include "../Cheats.h"
#include "../config/Config.h"
#include "../core/Math.hpp"
#include "../core/Util.hpp"
#include "../drawing/Drawing.h"
#include "../Game.h"
#include "../interface/Window.h"
#include "../localisation/Date.h"
#include "../OpenRCT2.h"
#include "../scenario/Scenario.h"
#include "../sprites.h"
#include "../util/Util.h"
#include "Climate.h"
constexpr sint32 MAX_THUNDER_INSTANCES = 2;
@@ -45,7 +45,9 @@ struct WeatherTransition
sint8 Distribution[24];
};
extern const WeatherTransition * ClimateTransitions[4];
extern const WeatherTransition * ClimateTransitions[4];
extern const WeatherState ClimateWeatherData[6];
extern const FILTER_PALETTE_ID ClimateWeatherGloomColours[4];
// Climate data
uint8 gClimate;
@@ -206,6 +208,27 @@ extern "C"
climate_update_rain_sound();
climate_update_thunder_sound();
}
FILTER_PALETTE_ID climate_get_weather_gloom_palette_id(const ClimateState * state)
{
auto paletteId = PALETTE_NULL;
auto gloom = state->WeatherGloom;
if (gloom < Util::CountOf(ClimateWeatherGloomColours))
{
paletteId = ClimateWeatherGloomColours[gloom];
}
return paletteId;
}
}
uint32 climate_get_weather_sprite_id(const ClimateState &state)
{
uint32 spriteId = SPR_WEATHER_SUN;
if (state.Weather < Util::CountOf(ClimateWeatherData))
{
spriteId = ClimateWeatherData[state.Weather].SpriteId;
}
return spriteId;
}
static sint8 climate_step_weather_level(sint8 currentWeatherLevel, sint8 nextWeatherLevel)
@@ -371,7 +394,7 @@ static void climate_play_thunder(sint32 instanceIndex, sint32 soundId, sint32 vo
const FILTER_PALETTE_ID ClimateWeatherGloomColours[4] =
{
(FILTER_PALETTE_ID)0,
PALETTE_NULL,
PALETTE_DARKEN_1,
PALETTE_DARKEN_2,
PALETTE_DARKEN_3,

View File

@@ -66,14 +66,17 @@ extern "C"
extern uint16 gClimateUpdateTimer;
extern uint16 gClimateLightningFlash;
extern const WeatherState ClimateWeatherData[6];
extern const FILTER_PALETTE_ID ClimateWeatherGloomColours[4];
sint32 climate_celsius_to_fahrenheit(sint32 celsius);
void climate_reset(sint32 climate);
void climate_update();
void climate_update_sound();
void climate_force_weather(uint8 weather);
FILTER_PALETTE_ID climate_get_weather_gloom_palette_id(const ClimateState * state);
#ifdef __cplusplus
}
uint32 climate_get_weather_sprite_id(const ClimateState &state);
#endif