From 46300f216f895a8a2437ed00fd04aee674fbec15 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 20 May 2018 02:21:44 +0100 Subject: [PATCH] Fix #7544: Freeze when starting headless server with no arguments Fixes #7313: Loading an invalid path with openrct2 produces results different than expected Do not load title sequences in headless mode and prevent use of null audio mixer when ride music is stopped. --- distribution/changelog.txt | 2 ++ src/openrct2/Context.cpp | 15 +++++++++++++-- src/openrct2/OpenRCT2.h | 1 + src/openrct2/audio/AudioMixer.cpp | 6 +++++- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index de0ca6859e..0bf8d3de50 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -17,6 +17,7 @@ - Fix: [#6141] CSS50.dat is never loaded. - Fix: [#7176] Mechanics sometimes fall down from rides. - Fix: [#7303] Visual glitch with virtual floor near map edges. +- Fix: [#7313] Loading an invalid path with openrct2 produces results different than expected. - Fix: [#7327] Abstract scenery and stations don't get fully See-Through when hiding them (original bug). - Fix: [#7331] Invention list in scenario editor crashes upon removing previously-enabled ride/stall entries. - Fix: [#7341] Staff may auto-spawn on guests walking outside of paths. @@ -29,6 +30,7 @@ - Fix: [#7436] Only the first 32 vehicles of a train can be painted. - Fix: [#7480] Graphs skip values of 0. - Fix: [#7528] In park entrance pricing tab, switching tabs happens on mouse-down instead of mouse-up +- Fix: [#7544] Starting a headless server with no arguments causes the game to freeze. - Improved: [#2989] Multiplayer window now changes title when tab changes. - Improved: [#5339] Change eyedropper icon to actual eyedropper and change cursor to crosshair. - Improved: [#7302] Raising land near the map edge makes the affected area smaller instead of showing an 'off edge map' error. diff --git a/src/openrct2/Context.cpp b/src/openrct2/Context.cpp index f09f37de80..67801e53e7 100644 --- a/src/openrct2/Context.cpp +++ b/src/openrct2/Context.cpp @@ -657,9 +657,20 @@ namespace OpenRCT2 void Launch() { gIntroState = INTRO_STATE_NONE; - if ((gOpenRCT2StartupAction == STARTUP_ACTION_TITLE) && gConfigGeneral.play_intro) + if (gOpenRCT2Headless) { - gOpenRCT2StartupAction = STARTUP_ACTION_INTRO; + // NONE or OPEN are the only allowed actions for headless mode + if (gOpenRCT2StartupAction != STARTUP_ACTION_OPEN) + { + gOpenRCT2StartupAction = STARTUP_ACTION_NONE; + } + } + else + { + if ((gOpenRCT2StartupAction == STARTUP_ACTION_TITLE) && gConfigGeneral.play_intro) + { + gOpenRCT2StartupAction = STARTUP_ACTION_INTRO; + } } switch (gOpenRCT2StartupAction) { diff --git a/src/openrct2/OpenRCT2.h b/src/openrct2/OpenRCT2.h index 989680d12d..940b9f0a02 100644 --- a/src/openrct2/OpenRCT2.h +++ b/src/openrct2/OpenRCT2.h @@ -24,6 +24,7 @@ enum STARTUP_ACTION { + STARTUP_ACTION_NONE, STARTUP_ACTION_INTRO, STARTUP_ACTION_TITLE, STARTUP_ACTION_OPEN, diff --git a/src/openrct2/audio/AudioMixer.cpp b/src/openrct2/audio/AudioMixer.cpp index edd2f64108..db51509b0a 100644 --- a/src/openrct2/audio/AudioMixer.cpp +++ b/src/openrct2/audio/AudioMixer.cpp @@ -74,7 +74,11 @@ void * Mixer_Play_Effect(size_t id, sint32 loop, sint32 volume, float pan, doubl void Mixer_Stop_Channel(void * channel) { - GetMixer()->Stop(static_cast(channel)); + auto mixer = GetMixer(); + if (mixer != nullptr) + { + mixer->Stop(static_cast(channel)); + } } void Mixer_Channel_Volume(void * channel, sint32 volume)