diff options
-rw-r--r-- | engines/sci/resource.cpp | 20 | ||||
-rw-r--r-- | engines/sci/resource.h | 2 | ||||
-rw-r--r-- | engines/sci/resource_audio.cpp | 7 |
3 files changed, 10 insertions, 19 deletions
diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp index b17117a1cd..f22c4d75fe 100644 --- a/engines/sci/resource.cpp +++ b/engines/sci/resource.cpp @@ -299,10 +299,15 @@ bool ResourceManager::loadFromPatchFile(Resource *res) { return loadPatch(res, &file); } -Common::File *ResourceManager::getVolumeFile(const char *filename) { +Common::SeekableReadStream *ResourceManager::getVolumeFile(ResourceSource *source) { Common::List<Common::File *>::iterator it = _volumeFiles.begin(); Common::File *file; + if (source->resourceFile) + return source->resourceFile->createReadStream(); + + const char *filename = source->location_name.c_str(); + // check if file is already opened while (it != _volumeFiles.end()) { file = *it; @@ -353,13 +358,7 @@ void ResourceManager::loadResource(Resource *res) { return; } - Common::SeekableReadStream *fileStream; - - // Either loading from volume or patch loading failed - if (res->_source->resourceFile) - fileStream = res->_source->resourceFile->createReadStream(); - else - fileStream = getVolumeFile(res->_source->location_name.c_str()); + Common::SeekableReadStream *fileStream = getVolumeFile(res->_source); if (!fileStream) { warning("Failed to open %s", res->_source->location_name.c_str()); @@ -1604,10 +1603,7 @@ ResourceCompression ResourceManager::getViewCompression() { if (res->_source->source_type != kSourceVolume) continue; - if (res->_source->resourceFile) - fileStream = res->_source->resourceFile->createReadStream(); - else - fileStream = getVolumeFile(res->_source->location_name.c_str()); + fileStream = getVolumeFile(res->_source); if (!fileStream) continue; diff --git a/engines/sci/resource.h b/engines/sci/resource.h index bc08154fed..4c7068c580 100644 --- a/engines/sci/resource.h +++ b/engines/sci/resource.h @@ -393,7 +393,7 @@ protected: */ const char *versionDescription(ResVersion version) const; - Common::File *getVolumeFile(const char *filename); + Common::SeekableReadStream *getVolumeFile(ResourceSource *source); void loadResource(Resource *res); bool loadPatch(Resource *res, Common::SeekableReadStream *file); bool loadFromPatchFile(Resource *res); diff --git a/engines/sci/resource_audio.cpp b/engines/sci/resource_audio.cpp index ebc549c772..57efbdcb38 100644 --- a/engines/sci/resource_audio.cpp +++ b/engines/sci/resource_audio.cpp @@ -33,12 +33,7 @@ namespace Sci { void ResourceManager::checkIfAudioVolumeIsCompressed(ResourceSource *source) { - Common::SeekableReadStream *fileStream; - - if (source->resourceFile) - fileStream = source->resourceFile->createReadStream(); - else - fileStream = getVolumeFile(source->location_name.c_str()); + Common::SeekableReadStream *fileStream = getVolumeFile(source); if (!fileStream) { warning("Failed to open %s", source->location_name.c_str()); |