[Scummvm-cvs-logs] scummvm master -> 6dd78a703f0ba89d51a4572ca90ab4783cc8fb61

dreammaster dreammaster at scummvm.org
Wed Aug 12 02:55:56 CEST 2015


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:
6dd78a703f SHERLOCK: RT: Improved version of ignoring missing voice resources


Commit: 6dd78a703f0ba89d51a4572ca90ab4783cc8fb61
    https://github.com/scummvm/scummvm/commit/6dd78a703f0ba89d51a4572ca90ab4783cc8fb61
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2015-08-11T20:55:07-04:00

Commit Message:
SHERLOCK: RT: Improved version of ignoring missing voice resources

Changed paths:
    engines/sherlock/resources.cpp
    engines/sherlock/resources.h
    engines/sherlock/sound.cpp



diff --git a/engines/sherlock/resources.cpp b/engines/sherlock/resources.cpp
index 8ec2c8c..a1de73e 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 8e0216d..cb8816c 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 013b0fd..f72b053 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() {






More information about the Scummvm-git-logs mailing list