diff options
author | Paul Gilbert | 2015-08-11 20:55:07 -0400 |
---|---|---|
committer | Paul Gilbert | 2015-08-11 20:55:07 -0400 |
commit | 6dd78a703f0ba89d51a4572ca90ab4783cc8fb61 (patch) | |
tree | 71235ae94e2a932151d148cf274ce2417facafaa | |
parent | 237d1149b5ab8cd00baa902ad951a01889383362 (diff) | |
download | scummvm-rg350-6dd78a703f0ba89d51a4572ca90ab4783cc8fb61.tar.gz scummvm-rg350-6dd78a703f0ba89d51a4572ca90ab4783cc8fb61.tar.bz2 scummvm-rg350-6dd78a703f0ba89d51a4572ca90ab4783cc8fb61.zip |
SHERLOCK: RT: Improved version of ignoring missing voice resources
-rw-r--r-- | engines/sherlock/resources.cpp | 13 | ||||
-rw-r--r-- | engines/sherlock/resources.h | 2 | ||||
-rw-r--r-- | engines/sherlock/sound.cpp | 13 |
3 files changed, 18 insertions, 10 deletions
diff --git a/engines/sherlock/resources.cpp b/engines/sherlock/resources.cpp index 8ec2c8c440..a1de73e0c0 100644 --- a/engines/sherlock/resources.cpp +++ b/engines/sherlock/resources.cpp @@ -195,16 +195,25 @@ void Resources::decompressIfNecessary(Common::SeekableReadStream *&stream) { } } -Common::SeekableReadStream *Resources::load(const Common::String &filename, const Common::String &libraryFile) { +Common::SeekableReadStream *Resources::load(const Common::String &filename, const Common::String &libraryFile, + bool suppressErrors) { // Open up the library for access Common::SeekableReadStream *libStream = load(libraryFile); // Check if the library has already had it's index read, and if not, load it if (!_indexes.contains(libraryFile)) loadLibraryIndex(libraryFile, libStream, false); + LibraryIndex &libIndex = _indexes[libraryFile]; + + // Handle if resource is not present + if (!libIndex.contains(filename)) { + if (!suppressErrors) + error("Could not find resource - %s", filename.c_str()); + return nullptr; + } // Extract the data for the specified resource and return it - LibraryEntry &entry = _indexes[libraryFile][filename]; + LibraryEntry &entry = libIndex[filename]; libStream->seek(entry._offset); Common::SeekableReadStream *stream = libStream->readStream(entry._size); decompressIfNecessary(stream); diff --git a/engines/sherlock/resources.h b/engines/sherlock/resources.h index 8e0216d69d..cb8816c2ec 100644 --- a/engines/sherlock/resources.h +++ b/engines/sherlock/resources.h @@ -125,7 +125,7 @@ public: /** * Loads a specific resource from a given library file */ - Common::SeekableReadStream *load(const Common::String &filename, const Common::String &libraryFile); + Common::SeekableReadStream *load(const Common::String &filename, const Common::String &libraryFile, bool suppressErrors = false); /** * Returns true if the given file exists on disk or in the cache diff --git a/engines/sherlock/sound.cpp b/engines/sherlock/sound.cpp index 013b0fdb70..f72b053c14 100644 --- a/engines/sherlock/sound.cpp +++ b/engines/sherlock/sound.cpp @@ -281,14 +281,13 @@ void Sound::playSpeech(const Common::String &name) { // Ensure the given library is in the cache res.addToCache(libraryName); - if (!res.exists(name)) - // No voice resource for the given name, so we have nothing to play - return; + Common::SeekableReadStream *stream = res.load(name, libraryName, true); + Audio::AudioStream *audioStream = !stream ? nullptr : Audio::makeRawStream(stream, 11025, Audio::FLAG_UNSIGNED); - Common::SeekableReadStream *stream = res.load(name, libraryName); - Audio::AudioStream *audioStream = Audio::makeRawStream(stream, 11025, Audio::FLAG_UNSIGNED); - _mixer->playStream(Audio::Mixer::kSpeechSoundType, &_speechHandle, audioStream, -1, Audio::Mixer::kMaxChannelVolume); - _speechPlaying = true; + if (audioStream) { + _mixer->playStream(Audio::Mixer::kSpeechSoundType, &_speechHandle, audioStream, -1, Audio::Mixer::kMaxChannelVolume); + _speechPlaying = true; + } } void Sound::stopSpeech() { |