define next climate variables, all refs rewritten

This commit is contained in:
IntelOrca 2014-04-29 12:35:37 +01:00
parent 1dcfdbe355
commit a325bcc856
3 changed files with 20 additions and 13 deletions

View File

@ -30,11 +30,17 @@ typedef struct {
sint8 distribution[24];
} rct_weather_transition;
int gClimateNextWeather;
static int _climateNextTemperature;
static int _climateNextWeatherEffect;
static int _climateNextWeatherGloom;
static int _climateNextRainLevel;
static const rct_weather_transition* climate_transitions[4];
static void climate_determine_future_weather();
int climate_celcius_to_fahrenheit(int celcius)
{
return (celcius * 29) / 16 + 32;
@ -61,11 +67,11 @@ void climate_update()
{
uint8 screen_flags = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8);
sint8 temperature = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TEMPERATURE, sint8),
target_temperature = RCT2_GLOBAL(RCT2_ADDRESS_NEXT_TEMPERATURE, sint8),
target_temperature = _climateNextTemperature,
cur_gloom = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_WEATHER_GLOOM, sint8),
next_gloom = RCT2_GLOBAL(RCT2_ADDRESS_NEXT_WEATHER_GLOOM, sint8),
next_gloom = _climateNextWeatherGloom,
cur_rain = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_RAIN_LEVEL, sint8),
next_rain = RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RAIN_LEVEL, sint8);
next_rain = _climateNextRainLevel;
if (screen_flags & (~SCREEN_FLAGS_PLAYING)) // only normal play mode gets climate
@ -82,10 +88,10 @@ void climate_update()
if (temperature == target_temperature) {
if (cur_gloom == next_gloom) {
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_WEATHER_EFFECT, sint8) = RCT2_GLOBAL(RCT2_ADDRESS_NEXT_WEATHER_EFFECT, sint8);
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_WEATHER_EFFECT, sint8) = _climateNextWeatherEffect;
if (cur_rain == next_rain) {
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_WEATHER, sint8) = RCT2_GLOBAL(RCT2_ADDRESS_NEXT_WEATHER, sint8);
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_WEATHER, sint8) = gClimateNextWeather;
climate_determine_future_weather();
RCT2_GLOBAL(0x009A9804, uint32) |= 8; // climate dirty flag?
} else {
@ -136,12 +142,12 @@ static void climate_determine_future_weather()
// Generate a random variable with values 0 upto distribution_size-1 and chose weather from the distribution table accordingly
sint8 next_weather = transition.distribution[ ((rand() & 0xFF) * transition.distribution_size) >> 8 ];
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_WEATHER, sint8) = next_weather;
gClimateNextWeather = next_weather;
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_TEMPERATURE, sint8) = transition.base_temperature + climate_weather_data[next_weather].temp_delta;
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_WEATHER_EFFECT, sint8) = climate_weather_data[next_weather].effect_level;
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_WEATHER_GLOOM, sint8) = climate_weather_data[next_weather].gloom_level;
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RAIN_LEVEL, sint8) = climate_weather_data[next_weather].rain_level;
_climateNextTemperature = transition.base_temperature + climate_weather_data[next_weather].temp_delta;
_climateNextWeatherEffect = climate_weather_data[next_weather].effect_level;
_climateNextWeatherGloom = climate_weather_data[next_weather].gloom_level;
_climateNextRainLevel = climate_weather_data[next_weather].rain_level;
RCT2_GLOBAL(RCT2_ADDRESS_CLIMATE_UPDATE_TIMER, sint16) = 1920;
}

View File

@ -38,6 +38,7 @@ typedef struct {
uint32 sprite_id;
} rct_weather;
extern int gClimateNextWeather;
extern const rct_weather climate_weather_data[6];
int climate_celcius_to_fahrenheit(int celcius);

View File

@ -483,10 +483,10 @@ static void window_game_bottom_toolbar_draw_right_panel(rct_drawpixelinfo *dpi,
gfx_draw_sprite(dpi, climate_weather_data[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_WEATHER, sint8)].sprite_id, x, y);
// Next weather
if (climate_weather_data[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_WEATHER, sint8)].sprite_id != climate_weather_data[RCT2_GLOBAL(RCT2_ADDRESS_NEXT_WEATHER, sint8)].sprite_id) {
if (climate_weather_data[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_WEATHER, sint8)].sprite_id != climate_weather_data[gClimateNextWeather].sprite_id) {
if (RCT2_GLOBAL(RCT2_ADDRESS_CLIMATE_UPDATE_TIMER, sint16) < 960) {
gfx_draw_sprite(dpi, SPR_NEXT_WEATHER, x + 27, y + 5);
gfx_draw_sprite(dpi, climate_weather_data[RCT2_GLOBAL(RCT2_ADDRESS_NEXT_WEATHER, sint8)].sprite_id, x + 40, y);
gfx_draw_sprite(dpi, climate_weather_data[gClimateNextWeather].sprite_id, x + 40, y);
}
}
}