From 01f806c2dbd06d42c8e56b0a46493cf5d5a68a11 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Tue, 14 Jun 2011 18:11:14 +0200 Subject: [PATCH] DETECTOR: Treat file based fallback like any other fallback method --- engines/advancedDetector.cpp | 10 ++-------- engines/advancedDetector.h | 17 +++-------------- engines/gob/detection.cpp | 5 ++++- engines/mohawk/detection.cpp | 6 +++++- engines/toon/detection.cpp | 6 +++++- engines/touche/detection.cpp | 6 +++++- 6 files changed, 24 insertions(+), 26 deletions(-) diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp index c9f4f38b779..82efb0d8407 100644 --- a/engines/advancedDetector.cpp +++ b/engines/advancedDetector.cpp @@ -472,24 +472,19 @@ ADGameDescList AdvancedMetaEngine::detectGame(const Common::FSNode &parent, cons } // Filename based fallback - if (_fileBasedFallback != 0) { - g = detectGameFilebased(allFiles); - if (g) - matched.push_back(g); - } } return matched; } -const ADGameDescription *AdvancedMetaEngine::detectGameFilebased(const FileMap &allFiles) const { +const ADGameDescription *AdvancedMetaEngine::detectGameFilebased(const FileMap &allFiles, const ADFileBasedFallback *fileBasedFallback) const { const ADFileBasedFallback *ptr; const char* const* filenames; int maxNumMatchedFiles = 0; const ADGameDescription *matchedDesc = 0; - for (ptr = _fileBasedFallback; ptr->desc; ++ptr) { + for (ptr = fileBasedFallback; ptr->desc; ++ptr) { const ADGameDescription *agdesc = (const ADGameDescription *)ptr->desc; int numMatchedFiles = 0; bool fileMissing = false; @@ -566,7 +561,6 @@ AdvancedMetaEngine::AdvancedMetaEngine(const void *descs, uint descItemSize, con _md5Bytes = 5000; _singleid = NULL; - _fileBasedFallback = NULL; _flags = 0; _guioptions = Common::GUIO_NONE; _maxScanDepth = 1; diff --git a/engines/advancedDetector.h b/engines/advancedDetector.h index c48e4a98153..300ce7bbb52 100644 --- a/engines/advancedDetector.h +++ b/engines/advancedDetector.h @@ -172,16 +172,6 @@ protected: */ const char *_singleid; - /** - * List of files for file-based fallback detection (optional). - * This is used if the regular MD5 based detection failed to - * detect anything. - * As usual this list is terminated by an all-zero entry. - * - * @todo Properly explain this - */ - const ADFileBasedFallback *_fileBasedFallback; - /** * A bitmask of flags which can be used to configure the behavior * of the AdvancedDetector. Refer to ADFlags for a list of flags @@ -234,8 +224,7 @@ protected: /** * An (optional) generic fallback detect function which is invoked - * if both the regular MD5 based detection as well as the file - * based fallback failed to detect anything. + * if the regular MD5 based detection failed to detect anything. */ virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const { return 0; @@ -256,7 +245,7 @@ protected: ADGameDescList detectGame(const Common::FSNode &parent, const FileMap &allFiles, Common::Language language, Common::Platform platform, const Common::String &extra) const; /** - * Iterates over all ADFileBasedFallback records inside _fileBasedFallback. + * Iterates over all ADFileBasedFallback records inside fileBasedFallback. * This then returns the record (or rather, the ADGameDescription * contained in it) for which all files described by it are present, and * among those the one with the maximal number of matching files. @@ -265,7 +254,7 @@ protected: * @param allFiles a map describing all present files * @param fileBasedFallback a list of ADFileBasedFallback records, zero-terminated */ - const ADGameDescription *detectGameFilebased(const FileMap &allFiles) const; + const ADGameDescription *detectGameFilebased(const FileMap &allFiles, const ADFileBasedFallback *fileBasedFallback) const; // TODO void updateGameDescriptor(GameDescriptor &desc, const ADGameDescription *realDesc) const; diff --git a/engines/gob/detection.cpp b/engines/gob/detection.cpp index 2050539d604..9a554b54290 100644 --- a/engines/gob/detection.cpp +++ b/engines/gob/detection.cpp @@ -91,7 +91,6 @@ class GobMetaEngine : public AdvancedMetaEngine { public: GobMetaEngine() : AdvancedMetaEngine(Gob::gameDescriptions, sizeof(Gob::GOBGameDescription), gobGames) { _singleid = "gob"; - _fileBasedFallback = Gob::fileBased; _guioptions = Common::GUIO_NOLAUNCHLOAD; } @@ -99,6 +98,10 @@ public: return Engines::findGameID(gameid, _gameids, obsoleteGameIDsTable); } + virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const { + return detectGameFilebased(allFiles, Gob::fileBased); + } + virtual const char *getName() const { return "Gob"; } diff --git a/engines/mohawk/detection.cpp b/engines/mohawk/detection.cpp index e6f60e3cb52..f0c657897dc 100644 --- a/engines/mohawk/detection.cpp +++ b/engines/mohawk/detection.cpp @@ -162,10 +162,14 @@ class MohawkMetaEngine : public AdvancedMetaEngine { public: MohawkMetaEngine() : AdvancedMetaEngine(Mohawk::gameDescriptions, sizeof(Mohawk::MohawkGameDescription), mohawkGames) { _singleid = "mohawk"; - _fileBasedFallback = Mohawk::fileBased; _maxScanDepth = 2; _directoryGlobs = directoryGlobs; } + + virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const { + return detectGameFilebased(allFiles, Mohawk::fileBased); + } + virtual const char *getName() const { return "Mohawk"; } diff --git a/engines/toon/detection.cpp b/engines/toon/detection.cpp index e72c61ac688..810a37720ad 100644 --- a/engines/toon/detection.cpp +++ b/engines/toon/detection.cpp @@ -121,10 +121,14 @@ class ToonMetaEngine : public AdvancedMetaEngine { public: ToonMetaEngine() : AdvancedMetaEngine(Toon::gameDescriptions, sizeof(ADGameDescription), toonGames) { _singleid = "toon"; - _fileBasedFallback = Toon::fileBasedFallback; _maxScanDepth = 3; _directoryGlobs = directoryGlobs; } + + virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const { + return detectGameFilebased(allFiles, Toon::fileBasedFallback); + } + virtual const char *getName() const { return "Toon"; } diff --git a/engines/touche/detection.cpp b/engines/touche/detection.cpp index d1dde96f59f..723fecec3a6 100644 --- a/engines/touche/detection.cpp +++ b/engines/touche/detection.cpp @@ -131,11 +131,15 @@ public: ToucheMetaEngine() : AdvancedMetaEngine(Touche::gameDescriptions, sizeof(ADGameDescription), toucheGames) { _md5Bytes = 4096; _singleid = "touche"; - _fileBasedFallback = Touche::fileBasedFallback; _flags = kADFlagPrintWarningOnFileBasedFallback; _maxScanDepth = 2; _directoryGlobs = directoryGlobs; } + + virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const { + return detectGameFilebased(allFiles, Touche::fileBasedFallback); + } + virtual const char *getName() const { return "Touche"; }