diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 08358f90330..28e0b3af6ed 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -53,7 +53,8 @@ namespace Wintermute { ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// -BaseFileManager::BaseFileManager(Common::Language lang) { +BaseFileManager::BaseFileManager(Common::Language lang, bool detectionMode) { + _detectionMode = detectionMode; _language = lang; _resources = nullptr; initResources(); @@ -232,12 +233,14 @@ bool BaseFileManager::registerPackage(Common::FSNode file, const Common::String void BaseFileManager::initResources() { _resources = Common::makeZipArchive("wintermute.zip"); - if (!_resources) { + if (!_resources && !_detectionMode) { // Wintermute.zip is unavailable during detection error("Couldn't load wintermute.zip"); } - assert(_resources->hasFile("syste_font.bmp")); - assert(_resources->hasFile("invalid.bmp")); - assert(_resources->hasFile("invalid_debug.bmp")); + if (_resources) { + assert(_resources->hasFile("syste_font.bmp")); + assert(_resources->hasFile("invalid.bmp")); + assert(_resources->hasFile("invalid_debug.bmp")); + } } ////////////////////////////////////////////////////////////////////////// @@ -277,7 +280,7 @@ bool BaseFileManager::hasFile(const Common::String &filename) { if (_packages.hasFile(filename)) { return true; // We don't bother checking if the file can actually be opened, something bigger is wrong if that is the case. } - if (_resources->hasFile(filename)) { + if (!_detectionMode && _resources->hasFile(filename)) { return true; } return false; @@ -337,7 +340,9 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f return ret; } - ret = _resources->createReadStreamForMember(filename); + if (!_detectionMode) { + ret = _resources->createReadStreamForMember(filename); + } if (ret) { return ret; } diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index 5fc626a314c..7ed3a6c7cbf 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -45,7 +45,7 @@ public: Common::SeekableReadStream *openFile(const Common::String &filename, bool absPathWarning = true, bool keepTrackOf = true); byte *readWholeFile(const Common::String &filename, uint32 *size = nullptr, bool mustExist = true); - BaseFileManager(Common::Language lang); + BaseFileManager(Common::Language lang, bool detectionMode = false); virtual ~BaseFileManager(); // Used only for detection bool registerPackages(const Common::FSList &fslist); @@ -65,6 +65,7 @@ private: Common::FSList _packagePaths; bool findPackageSignature(Common::SeekableReadStream *f, uint32 *offset); bool registerPackage(Common::FSNode package, const Common::String &filename = "", bool searchSignature = false); + bool _detectionMode; Common::SearchSet _packages; Common::Array _openFiles; Common::Language _language; diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index f33452d11cb..ad26c425106 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -311,7 +311,7 @@ bool WintermuteEngine::getGameInfo(const Common::FSList &fslist, Common::String caption = name = "(invalid)"; Common::SeekableReadStream *stream = nullptr; // Quick-fix, instead of possibly breaking the persistence-system, let's just roll with it - BaseFileManager *fileMan = new BaseFileManager(Common::UNK_LANG); + BaseFileManager *fileMan = new BaseFileManager(Common::UNK_LANG, true); fileMan->registerPackages(fslist); stream = fileMan->openFile("startup.settings", false, false);