From 938b63323897e9e673191e12e0339b2ec032a624 Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Fri, 24 Dec 2010 11:04:25 +0000 Subject: MOHAWK: Fix playing sound from aliases in Myst ME. svn-id: r55031 --- engines/mohawk/sound.cpp | 25 +++++++++++++++++++++---- engines/mohawk/sound.h | 1 + 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/engines/mohawk/sound.cpp b/engines/mohawk/sound.cpp index aec01dcdd5..fd825b1575 100644 --- a/engines/mohawk/sound.cpp +++ b/engines/mohawk/sound.cpp @@ -130,13 +130,13 @@ Audio::SoundHandle *Sound::replaceSound(uint16 id, byte volume, bool loop) { //TODO: The original engine does fading - Common::String name = _vm->getResourceName(ID_MSND, id); + Common::String name = getName(id); // Check if sound is already playing for (uint32 i = 0; i < _handles.size(); i++) if (_handles[i].type == kUsedHandle && _vm->_mixer->isSoundHandleActive(_handles[i].handle) - && name.equals(_vm->getResourceName(ID_MSND, _handles[i].id))) + && name.equals(getName(_handles[i].id))) return &_handles[i].handle; stopSound(); @@ -562,13 +562,13 @@ Audio::SoundHandle *Sound::replaceBackground(uint16 id, uint16 volume) { //TODO: The original engine does fading - Common::String name = _vm->getResourceName(ID_MSND, id); + Common::String name = getName(id); // Check if sound is already playing for (uint32 i = 0; i < _handles.size(); i++) if (_handles[i].type == kBackgroundHandle && _vm->_mixer->isSoundHandleActive(_handles[i].handle) - && name.equals(_vm->getResourceName(ID_MSND, _handles[i].id))) + && name.equals(getName(_handles[i].id))) return &_handles[i].handle; // Stop old background sound @@ -619,4 +619,21 @@ void Sound::changeBackgroundVolume(uint16 vol) { _vm->_mixer->setChannelVolume(_handles[i].handle, vol >> 8); } +Common::String Sound::getName(uint16 id) { + if (_vm->getFeatures() & GF_ME) { + // Myst ME is a bit more efficient with sound storage than Myst + // Myst has lots of sounds repeated. To overcome this, Myst ME + // has MJMP resources which provide a link to the actual MSND + // resource we're looking for. This saves a lot of space from + // repeated data. + if (_vm->hasResource(ID_MJMP, id)) { + Common::SeekableReadStream *mjmpStream = _vm->getResource(ID_MJMP, id); + id = mjmpStream->readUint16LE(); + delete mjmpStream; + } + } + + return _vm->getResourceName(ID_MSND, id); +} + } // End of namespace Mohawk diff --git a/engines/mohawk/sound.h b/engines/mohawk/sound.h index daadd765eb..3c16939556 100644 --- a/engines/mohawk/sound.h +++ b/engines/mohawk/sound.h @@ -157,6 +157,7 @@ private: Common::Array _handles; SndHandle *getHandle(); Audio::AudioStream *makeAudioStream(uint16 id); + Common::String getName(uint16 id); // Riven-specific void playSLSTSound(uint16 index, bool fade, bool loop, uint16 volume, int16 balance); -- cgit v1.2.3