From c7bfbc31e2f23f899dcf884ef9a9ba3a7bd0ebe8 Mon Sep 17 00:00:00 2001 From: md5 Date: Mon, 28 Feb 2011 00:18:23 +0200 Subject: SCI: Fixed bug #3106107 - "QFG3: Crash when saving outside palace" Ignore requests to alter a song's hold value while it's being faded, and reset a song's hold value when fading starts. This ensures that the song will actually stop when fading is done and won't keep looping forever. --- engines/sci/sound/soundcmd.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'engines/sci/sound') diff --git a/engines/sci/sound/soundcmd.cpp b/engines/sci/sound/soundcmd.cpp index 1e6d0aef87..33be8f4bca 100644 --- a/engines/sci/sound/soundcmd.cpp +++ b/engines/sci/sound/soundcmd.cpp @@ -318,6 +318,9 @@ reg_t SoundCommandParser::kDoSoundFade(int argc, reg_t *argv, reg_t acc) { int volume = musicSlot->volume; + // Reset hold so that the song can actually stop + musicSlot->hold = -1; + // If sound is not playing currently, set signal directly if (musicSlot->status != kSoundPlaying) { debugC(kDebugLevelSound, "kDoSound(fade): %04x:%04x fading requested, but sound is currently not playing", PRINT_REG(obj)); @@ -531,6 +534,12 @@ reg_t SoundCommandParser::kDoSoundSetHold(int argc, reg_t *argv, reg_t acc) { return acc; } + // Is the song being faded? If yes, don't set a hold value, otherwise the + // song will never actually stop. Fixes bug #3106107. + if (musicSlot->fadeStep && argv[1].toSint16() != -1) { + warning("kDoSound(setHold): Attempt to set a hold value (%d) to a song being faded, ignoring", argv[1].toSint16()); + return acc; + } // Set the special hold marker ID where the song should be looped at. musicSlot->hold = argv[1].toSint16(); return acc; -- cgit v1.2.3