WINTERMUTE: Avoid REQUIRING wintermute.zip during detection.

This commit is contained in:
Einar Johan Trøan Sømåen 2013-03-23 18:08:08 +01:00
parent 94893636e4
commit dedde93d1e
3 changed files with 15 additions and 9 deletions

View File

@ -53,7 +53,8 @@ namespace Wintermute {
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
BaseFileManager::BaseFileManager(Common::Language lang) { BaseFileManager::BaseFileManager(Common::Language lang, bool detectionMode) {
_detectionMode = detectionMode;
_language = lang; _language = lang;
_resources = nullptr; _resources = nullptr;
initResources(); initResources();
@ -232,12 +233,14 @@ bool BaseFileManager::registerPackage(Common::FSNode file, const Common::String
void BaseFileManager::initResources() { void BaseFileManager::initResources() {
_resources = Common::makeZipArchive("wintermute.zip"); _resources = Common::makeZipArchive("wintermute.zip");
if (!_resources) { if (!_resources && !_detectionMode) { // Wintermute.zip is unavailable during detection
error("Couldn't load wintermute.zip"); error("Couldn't load wintermute.zip");
} }
assert(_resources->hasFile("syste_font.bmp")); if (_resources) {
assert(_resources->hasFile("invalid.bmp")); assert(_resources->hasFile("syste_font.bmp"));
assert(_resources->hasFile("invalid_debug.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)) { 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. 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 true;
} }
return false; return false;
@ -337,7 +340,9 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f
return ret; return ret;
} }
ret = _resources->createReadStreamForMember(filename); if (!_detectionMode) {
ret = _resources->createReadStreamForMember(filename);
}
if (ret) { if (ret) {
return ret; return ret;
} }

View File

@ -45,7 +45,7 @@ public:
Common::SeekableReadStream *openFile(const Common::String &filename, bool absPathWarning = true, bool keepTrackOf = true); 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); 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(); virtual ~BaseFileManager();
// Used only for detection // Used only for detection
bool registerPackages(const Common::FSList &fslist); bool registerPackages(const Common::FSList &fslist);
@ -65,6 +65,7 @@ private:
Common::FSList _packagePaths; Common::FSList _packagePaths;
bool findPackageSignature(Common::SeekableReadStream *f, uint32 *offset); bool findPackageSignature(Common::SeekableReadStream *f, uint32 *offset);
bool registerPackage(Common::FSNode package, const Common::String &filename = "", bool searchSignature = false); bool registerPackage(Common::FSNode package, const Common::String &filename = "", bool searchSignature = false);
bool _detectionMode;
Common::SearchSet _packages; Common::SearchSet _packages;
Common::Array<Common::SeekableReadStream *> _openFiles; Common::Array<Common::SeekableReadStream *> _openFiles;
Common::Language _language; Common::Language _language;

View File

@ -311,7 +311,7 @@ bool WintermuteEngine::getGameInfo(const Common::FSList &fslist, Common::String
caption = name = "(invalid)"; caption = name = "(invalid)";
Common::SeekableReadStream *stream = nullptr; Common::SeekableReadStream *stream = nullptr;
// Quick-fix, instead of possibly breaking the persistence-system, let's just roll with it // 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); fileMan->registerPackages(fslist);
stream = fileMan->openFile("startup.settings", false, false); stream = fileMan->openFile("startup.settings", false, false);