diff options
author | Filippos Karapetis | 2011-08-25 02:52:58 +0300 |
---|---|---|
committer | Filippos Karapetis | 2011-08-25 02:52:58 +0300 |
commit | 996deff15b347f05f95b2a6b9d0e382d25d0db3e (patch) | |
tree | 52471b99071de706443e9c12e8934ceeb4d233c9 /engines/sci | |
parent | 3774c38db59dd8528126112011d5345afee111bd (diff) | |
download | scummvm-rg350-996deff15b347f05f95b2a6b9d0e382d25d0db3e.tar.gz scummvm-rg350-996deff15b347f05f95b2a6b9d0e382d25d0db3e.tar.bz2 scummvm-rg350-996deff15b347f05f95b2a6b9d0e382d25d0db3e.zip |
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().
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/sound/soundcmd.cpp | 31 | ||||
-rw-r--r-- | engines/sci/sound/soundcmd.h | 1 |
2 files changed, 19 insertions, 13 deletions
diff --git a/engines/sci/sound/soundcmd.cpp b/engines/sci/sound/soundcmd.cpp index 4ea290ff9e..d4cff7614c 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 a542a8b384..7f6e2a0fe8 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 |