[Scummvm-git-logs] scummvm master -> 0d16892c1d2e6617d747164c26926ec1995761d6

sluicebox noreply at scummvm.org
Thu May 12 19:09:11 UTC 2022


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
0d16892c1d SCI32: Fix GK2 lockups when music volume is turned off


Commit: 0d16892c1d2e6617d747164c26926ec1995761d6
    https://github.com/scummvm/scummvm/commit/0d16892c1d2e6617d747164c26926ec1995761d6
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2022-05-12T14:59:53-04:00

Commit Message:
SCI32: Fix GK2 lockups when music volume is turned off

Fixes a bug in the original that locks up many scenes and room
transitions if the music volume slider is lowered all the way

Changed paths:
    engines/sci/engine/script_patches.cpp
    engines/sci/sound/audio32.cpp


diff --git a/engines/sci/engine/script_patches.cpp b/engines/sci/engine/script_patches.cpp
index 926d602398a..0555be0de4a 100644
--- a/engines/sci/engine/script_patches.cpp
+++ b/engines/sci/engine/script_patches.cpp
@@ -4217,6 +4217,8 @@ static const uint16 gk2BenchmarkPatch[] = {
 //
 // We fix this by clearing SoundManager's timer state in SoundManager:play.
 //  This prevents the delay timer from ever running while music is playing.
+//  Note that this bug is unrelated to lockups when the music volume slider
+//  is set to its lowest value. We fix that in Sci::Audio32::fadeChannel().
 //
 // Applies to: All versions
 // Responsible method: SoundManager:play
diff --git a/engines/sci/sound/audio32.cpp b/engines/sci/sound/audio32.cpp
index ee7f3d3bfb9..fd855331dab 100644
--- a/engines/sci/sound/audio32.cpp
+++ b/engines/sci/sound/audio32.cpp
@@ -1121,10 +1121,32 @@ bool Audio32::fadeChannel(const int16 channelIndex, const int16 targetVolume, co
 
 	AudioChannel &channel = getChannel(channelIndex);
 
-	if (channel.id.getType() != kResourceTypeAudio || channel.volume == targetVolume) {
+	if (channel.id.getType() != kResourceTypeAudio) {
 		return false;
 	}
 
+	// Do nothing when volume is already at the target
+	if (channel.volume == targetVolume) {
+		// WORKAROUND: GK2 has a script bug that locks up the game in many places
+		// when the music volume slider is set to lowest. This also occurs in
+		// the original. Instead of using kDoSoundMasterVolume, the slider sets
+		// the volume of every sound object along with a global that limits the
+		// maximum volume that any sound object can be set to. At the lowest
+		// setting, all sound object volumes are zero and can only be set or
+		// faded to zero. GK2 also fades many sounds and waits for them to
+		// complete in HandsOff mode. But the interpreter ignores attempts to
+		// fade a sound whose volume is already at the target, turning every
+		// fade wait into a lockup. We work around this by allowing GK2 fades
+		// to proceed if the current and target volume are both zero.
+		// Ideally this would be a script patch, but it's unclear how to do that
+		// and keep the expected delays that fading provides. 
+		// Example: Start of chapter 1, exit the farm interior and re-enter.
+		bool allowFadeToCurrent = (g_sci->getGameId() == GID_GK2 && targetVolume == 0);
+		if (!allowFadeToCurrent) {
+			return false;
+		}
+	}
+
 	if (steps && speed) {
 		channel.fadeStartTick = g_sci->getTickCount();
 		channel.fadeStartVolume = channel.volume;




More information about the Scummvm-git-logs mailing list