[Scummvm-cvs-logs] scummvm master -> 996deff15b347f05f95b2a6b9d0e382d25d0db3e

bluegr md5 at scummvm.org
Thu Aug 25 01:57:28 CEST 2011


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:
996deff15b SCI: Fixed bug #3392767 - "SCI: SQ4 (English/CD/Win): Engine Abort In Timepod Hangar"


Commit: 996deff15b347f05f95b2a6b9d0e382d25d0db3e
    https://github.com/scummvm/scummvm/commit/996deff15b347f05f95b2a6b9d0e382d25d0db3e
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2011-08-24T16:52:58-07:00

Commit Message:
SCI: Fixed bug #3392767 - "SCI: SQ4 (English/CD/Win): Engine Abort In Timepod Hangar"

This bug only manifested in the Windows version of SQ4CD. Some Windows
MIDI music tracks are missing from room 530, which messed up the
animations in that scene, and led to a crash. Moved the code that
obtains the song number from an object into a separate function. Also,
fixed a bug in kDoSoundSetPriority().

Changed paths:
    engines/sci/sound/soundcmd.cpp
    engines/sci/sound/soundcmd.h



diff --git a/engines/sci/sound/soundcmd.cpp b/engines/sci/sound/soundcmd.cpp
index 4ea290f..d4cff76 100644
--- a/engines/sci/sound/soundcmd.cpp
+++ b/engines/sci/sound/soundcmd.cpp
@@ -49,11 +49,22 @@ reg_t SoundCommandParser::kDoSoundInit(int argc, reg_t *argv, reg_t acc) {
 	return acc;
 }
 
-void SoundCommandParser::processInitSound(reg_t obj) {
-	int resourceId = readSelectorValue(_segMan, obj, SELECTOR(number));
+int SoundCommandParser::getSoundResourceId(reg_t obj) {
+	int resourceId = obj.segment ? readSelectorValue(_segMan, obj, SELECTOR(number)) : -1;
 	// Modify the resourceId for the Windows versions that have an alternate MIDI soundtrack, like SSCI did.
-	if (g_sci && g_sci->_features->useAltWinGMSound())
-		resourceId += 1000;
+	if (g_sci && g_sci->_features->useAltWinGMSound()) {
+		// Check if the alternate MIDI song actually exists...
+		// There are cases where it just doesn't exist (e.g. SQ4, room 530 -
+		// bug #3392767). In these cases, use the DOS tracks instead.
+		if (resourceId && _resMan->testResource(ResourceId(kResourceTypeSound, resourceId + 1000)))
+			resourceId += 1000;
+	}
+
+	return resourceId;
+}
+
+void SoundCommandParser::processInitSound(reg_t obj) {
+	int resourceId = getSoundResourceId(obj);
 
 	// Check if a track with the same sound object is already playing
 	MusicEntry *oldSound = _music->getSlot(obj);
@@ -123,10 +134,7 @@ void SoundCommandParser::processPlaySound(reg_t obj) {
 		return;
 	}
 
-	int resourceId = obj.segment ? readSelectorValue(_segMan, obj, SELECTOR(number)) : -1;
-	// Modify the resourceId for the Windows versions that have an alternate MIDI soundtrack, like SSCI did.
-	if (g_sci && g_sci->_features->useAltWinGMSound())
-		resourceId += 1000;
+	int resourceId = getSoundResourceId(obj);
 
 	if (musicSlot->resourceId != resourceId) { // another sound loaded into struct
 		processDisposeSound(obj);
@@ -618,13 +626,10 @@ reg_t SoundCommandParser::kDoSoundSetPriority(int argc, reg_t *argv, reg_t acc)
 	}
 
 	if (value == -1) {
-		uint16 resourceNr = musicSlot->resourceId;
-		// Modify the resourceId for the Windows versions that have an alternate MIDI soundtrack, like SSCI did.
-		if (g_sci && g_sci->_features->useAltWinGMSound())
-			resourceNr += 1000;
+		uint16 resourceId = musicSlot->resourceId;
 
 		// Set priority from the song data
-		Resource *song = _resMan->findResource(ResourceId(kResourceTypeSound, resourceNr), 0);
+		Resource *song = _resMan->findResource(ResourceId(kResourceTypeSound, resourceId), 0);
 		if (song->data[0] == 0xf0)
 			_music->soundSetPriority(musicSlot, song->data[1]);
 		else
diff --git a/engines/sci/sound/soundcmd.h b/engines/sci/sound/soundcmd.h
index a542a8b..7f6e2a0 100644
--- a/engines/sci/sound/soundcmd.h
+++ b/engines/sci/sound/soundcmd.h
@@ -113,6 +113,7 @@ private:
 	void processInitSound(reg_t obj);
 	void processDisposeSound(reg_t obj);
 	void processUpdateCues(reg_t obj);
+	int getSoundResourceId(reg_t obj);
 };
 
 } // End of namespace Sci






More information about the Scummvm-git-logs mailing list