Skip to content

Commit

Permalink
SCI32: Initialize Sound:handle for non-preload samples
Browse files Browse the repository at this point in the history
Fixes bug #13500 where LSL6HIRES doesn't play the audio for the death
message after the security guard launches a missile.

Thanks to @RayKoopa for reporting this and other discrepancies
  • Loading branch information
sluicebox committed May 27, 2022
1 parent fdfede6 commit fd146d7
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions engines/sci/sound/soundcmd.cpp
Expand Up @@ -35,6 +35,11 @@

namespace Sci {

enum SoundFlags {
kSoundFlagFixedPriority = 2,
kSoundFlagPreload = 4
};

SoundCommandParser::SoundCommandParser(ResourceManager *resMan, SegManager *segMan, Kernel *kernel, AudioPlayer *audio, SciVersion soundVersion) :
_resMan(resMan), _segMan(segMan), _kernel(kernel), _audio(audio), _soundVersion(soundVersion) {

Expand Down Expand Up @@ -253,6 +258,16 @@ void SoundCommandParser::processPlaySound(reg_t obj, bool playBed, bool restorin
_audio->incrementPlayCounter();
}

if (_soundVersion >= SCI_VERSION_2_1_EARLY && musicSlot->isSample) {
// When playing a sample without the preload flag, set the
// handle to -1 instead of the object. LSL6HIRES depends on
// this to play certain death messages. Fixes bug #13500
uint16 flags = readSelectorValue(_segMan, obj, SELECTOR(flags));
if (!(flags & kSoundFlagPreload)) {
writeSelectorValue(_segMan, obj, SELECTOR(handle), -1);
}
}

// Reset any left-over signals
musicSlot->signal = 0;
musicSlot->fadeStep = 0;
Expand Down Expand Up @@ -805,12 +820,12 @@ reg_t SoundCommandParser::kDoSoundSetPriority(EngineState *s, int argc, reg_t *a

// NB: It seems SSCI doesn't actually reset the priority here.

writeSelectorValue(_segMan, obj, SELECTOR(flags), readSelectorValue(_segMan, obj, SELECTOR(flags)) & 0xFD);
writeSelectorValue(_segMan, obj, SELECTOR(flags), readSelectorValue(_segMan, obj, SELECTOR(flags)) & ~kSoundFlagFixedPriority);
} else {
// Scripted priority
musicSlot->overridePriority = true;

writeSelectorValue(_segMan, obj, SELECTOR(flags), readSelectorValue(_segMan, obj, SELECTOR(flags)) | 2);
writeSelectorValue(_segMan, obj, SELECTOR(flags), readSelectorValue(_segMan, obj, SELECTOR(flags)) | kSoundFlagFixedPriority);

_music->soundSetPriority(musicSlot, value);
}
Expand Down

0 comments on commit fd146d7

Please sign in to comment.