From 83a7dd50952fe854c937bfd557b76d38b6210fee Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Sun, 14 Dec 2014 15:00:22 +0000 Subject: [PATCH 1/2] Fix lightning error caused by buffer overflow in scenery --- src/windows/scenery.c | 2 +- src/world/climate.c | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/windows/scenery.c b/src/windows/scenery.c index 02ad9a6ac3..38ae82ddd9 100644 --- a/src/windows/scenery.c +++ b/src/windows/scenery.c @@ -174,7 +174,7 @@ static rct_widget window_scenery_widgets[] = { { WIDGETS_END }, }; -static sint16 window_scenery_tab_entries[0x13][SCENERY_ENTRIES_BY_TAB + 1]; +static sint16 window_scenery_tab_entries[0x14][SCENERY_ENTRIES_BY_TAB + 1]; /* * Was part of 0x006DFA00 diff --git a/src/world/climate.c b/src/world/climate.c index ba4acc4212..5bb9e4183a 100644 --- a/src/world/climate.c +++ b/src/world/climate.c @@ -100,6 +100,9 @@ void climate_reset(int climate) RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_WEATHER_EFFECT, sint8) = climate_weather_data[weather].effect_level; RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_WEATHER_GLOOM, sint8) = climate_weather_data[weather].gloom_level; RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_RAIN_LEVEL, sint8) = climate_weather_data[weather].rain_level; + + _lightningTimer = 0; + _thunderTimer = 0; climate_determine_future_weather(); } @@ -153,6 +156,8 @@ void climate_update() if (temperature == target_temperature) { if (cur_gloom == next_gloom) { _climateCurrentWeatherEffect = _climateNextWeatherEffect; + _thunderTimer = 0; + _lightningTimer = 0; if (cur_rain == next_rain) { RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_WEATHER, sint8) = gClimateNextWeather; @@ -224,7 +229,7 @@ void climate_update_sound() return; if (!(RCT2_GLOBAL(0x009AF59D, uint8) & 1)) return; - if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 1) + if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & (1< Date: Sun, 14 Dec 2014 21:02:38 +0000 Subject: [PATCH 2/2] Fix rain continuing on main menu. Added comment about screen flags --- src/rct2.h | 2 ++ src/world/climate.c | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/rct2.h b/src/rct2.h index af4c77fe19..85ff1868c2 100644 --- a/src/rct2.h +++ b/src/rct2.h @@ -104,6 +104,8 @@ typedef void (EMPTY_ARGS_VOID_POINTER)(); typedef unsigned short rct_string_id; enum { + // Although this is labeled a flag it actually means when + // zero the screen is in playing mode. SCREEN_FLAGS_PLAYING = 0, SCREEN_FLAGS_TITLE_DEMO = 1, SCREEN_FLAGS_SCENARIO_EDITOR = 2, diff --git a/src/world/climate.c b/src/world/climate.c index 5bb9e4183a..54e3a295a1 100644 --- a/src/world/climate.c +++ b/src/world/climate.c @@ -103,6 +103,17 @@ void climate_reset(int climate) _lightningTimer = 0; _thunderTimer = 0; + if (_rainVolume != 1){ +#ifdef USE_MIXER + if (_rainSoundChannel) { + Mixer_Stop_Channel(_rainSoundChannel); + _rainSoundChannel = 0; + } +#else + sound_stop(&_rainSoundInstance); +#endif + _rainVolume = 1; + } climate_determine_future_weather(); } @@ -229,7 +240,7 @@ void climate_update_sound() return; if (!(RCT2_GLOBAL(0x009AF59D, uint8) & 1)) return; - if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & (1<