aboutsummaryrefslogtreecommitdiff
path: root/engines/sherlock/resources.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sherlock/resources.cpp')
-rw-r--r--engines/sherlock/resources.cpp13
1 files changed, 11 insertions, 2 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);