diff options
-rw-r--r-- | common/advancedDetector.cpp | 51 | ||||
-rw-r--r-- | common/advancedDetector.h | 33 | ||||
-rw-r--r-- | engines/agi/detection.cpp | 6 | ||||
-rw-r--r-- | engines/agos/detection.cpp | 2 | ||||
-rw-r--r-- | engines/cine/detection.cpp | 2 | ||||
-rw-r--r-- | engines/cruise/detection.cpp | 2 | ||||
-rw-r--r-- | engines/drascula/detection.cpp | 6 | ||||
-rw-r--r-- | engines/gob/detection.cpp | 2 | ||||
-rw-r--r-- | engines/igor/detection.cpp | 1 | ||||
-rw-r--r-- | engines/kyra/detection.cpp | 2 | ||||
-rw-r--r-- | engines/lure/detection.cpp | 2 | ||||
-rw-r--r-- | engines/parallaction/detection.cpp | 2 | ||||
-rw-r--r-- | engines/saga/detection.cpp | 2 | ||||
-rw-r--r-- | engines/touche/detection.cpp | 1 |
14 files changed, 48 insertions, 66 deletions
diff --git a/common/advancedDetector.cpp b/common/advancedDetector.cpp index 5ff124a43c..ccb32a5188 100644 --- a/common/advancedDetector.cpp +++ b/common/advancedDetector.cpp @@ -34,6 +34,8 @@ namespace Common { +using namespace AdvancedDetector; + namespace AdvancedDetector { // FIXME/TODO: Rename this function to something more sensible. @@ -209,16 +211,15 @@ static void updateGameDescriptor(GameDescriptor &desc, const ADGameDescription * desc["extra"] = realDesc->extra; } -GameList detectAllGames( - const FSList &fslist, - const Common::ADParams ¶ms - ) { +} // End of namespace AdvancedDetector + +GameList AdvancedMetaEngine::detectGames(const FSList &fslist) const { ADGameDescList matches = detectGame(&fslist, params, Common::UNK_LANG, Common::kPlatformUnknown, ""); GameList detectedGames; // Use fallback detector if there were no matches by other means - if (matches.empty() && params.fallbackDetectFunc != NULL) { - EncapsulatedADGameDesc fallbackDesc = (*params.fallbackDetectFunc)(&fslist); + if (matches.empty()) { + EncapsulatedADGameDesc fallbackDesc = fallbackDetect(&fslist); if (fallbackDesc.realDesc != 0) { GameDescriptor desc(toGameDescriptor(fallbackDesc, params.list)); updateGameDescriptor(desc, fallbackDesc.realDesc, params); @@ -233,9 +234,10 @@ GameList detectAllGames( return detectedGames; } -EncapsulatedADGameDesc detectBestMatchingGame( - const Common::ADParams ¶ms - ) { +PluginError AdvancedMetaEngine::createInstance(OSystem *syst, Engine **engine) const { + assert(engine); + Common::AdvancedDetector::upgradeTargetIfNecessary(params); + const ADGameDescription *agdDesc = 0; EncapsulatedADGameDesc result; Common::Language language = Common::UNK_LANG; @@ -267,8 +269,9 @@ EncapsulatedADGameDesc detectBestMatchingGame( if (agdDesc != 0) { // Check if we found a match without fallback detection result = EncapsulatedADGameDesc(agdDesc); - } else if (params.fallbackDetectFunc != NULL) { // Use fallback detector if there were no matches by other means - EncapsulatedADGameDesc fallbackDesc = (*params.fallbackDetectFunc)(NULL); + } else { + // Use fallback detector if there were no matches by other means + EncapsulatedADGameDesc fallbackDesc = fallbackDetect(NULL); if (fallbackDesc.realDesc != 0 && (params.singleid != NULL || fallbackDesc.getGameID() == gameid)) { result = fallbackDesc; // Found a fallback match } @@ -278,9 +281,17 @@ EncapsulatedADGameDesc detectBestMatchingGame( debug(2, "Running %s", toGameDescriptor(result, params.list).description().c_str()); } - return result; + if (result.realDesc == 0) { + return kNoGameDataFoundError; + } + if (!createInstance(syst, engine, result)) { + return kNoGameDataFoundError; + } + return kNoError; } +namespace AdvancedDetector { + void reportUnknown(StringMap &filesMD5, HashMap<String, int32, Common::CaseSensitiveString_Hash, Common::CaseSensitiveString_EqualTo> &filesSize) { // TODO: This message should be cleaned up / made more specific. // For example, we should specify at least which engine triggered this. @@ -571,21 +582,5 @@ GameList AdvancedMetaEngine::getSupportedGames() const { GameDescriptor AdvancedMetaEngine::findGame(const char *gameid) const { return Common::AdvancedDetector::findGameID(gameid, params.list, params.obsoleteList); } -GameList AdvancedMetaEngine::detectGames(const FSList &fslist) const { - return Common::AdvancedDetector::detectAllGames(fslist, params); -} - -PluginError AdvancedMetaEngine::createInstance(OSystem *syst, Engine **engine) const { - assert(engine); - Common::AdvancedDetector::upgradeTargetIfNecessary(params); - Common::EncapsulatedADGameDesc encapsulatedDesc = Common::AdvancedDetector::detectBestMatchingGame(params); - if (encapsulatedDesc.realDesc == 0) { - return kNoGameDataFoundError; - } - if (!createInstance(syst,engine,encapsulatedDesc)) { - return kNoGameDataFoundError; - } - return kNoError; -} } // End of namespace Common diff --git a/common/advancedDetector.h b/common/advancedDetector.h index f694e9896a..5702243484 100644 --- a/common/advancedDetector.h +++ b/common/advancedDetector.h @@ -67,6 +67,8 @@ struct ADGameDescription { /** * Encapsulates ADGameDescription and makes gameid and extra strings dynamic. * Used in fallback detection when dynamically creating string content. + * + * @todo Get rid of this once the fallback detection is a member of AdvancedMetaEngine. */ struct EncapsulatedADGameDesc { Common::String gameid; @@ -76,8 +78,8 @@ struct EncapsulatedADGameDesc { // Constructor for the EncapsulatedADGameDesc EncapsulatedADGameDesc() : realDesc(0) {} EncapsulatedADGameDesc(const ADGameDescription *paramRealDesc, - Common::String paramGameID = Common::String(""), - Common::String paramExtra = Common::String("")) + Common::String paramGameID = Common::String(), + Common::String paramExtra = Common::String()) : realDesc(paramRealDesc), gameid(paramGameID), extra(paramExtra) { assert(paramRealDesc != NULL); } @@ -193,20 +195,6 @@ struct ADParams { const ADFileBasedFallback *fileBasedFallback; /** - * A callback pointing to an (optional) generic fallback detect - * function. If present, this callback is invoked if both the regular - * MD5 based detection as well as the file based fallback failed - * to detect anything. - * - * @note The fslist parameter may be 0 -- in that case, it is assumed - * that the callback searchs the current directory. - * - * @todo Change this to a member method of AdvancedMetaEngine which can - * be overriden via subclassing. - */ - EncapsulatedADGameDesc (*fallbackDetectFunc)(const FSList *fslist); - - /** * A bitmask of flags which can be used to configure the behavior * of the AdvancedDetector. Refer to ADFlags for a list of flags * that can be ORed together and passed here. @@ -245,6 +233,19 @@ public: // To be provided by subclasses virtual bool createInstance(OSystem *syst, Engine **engine, const Common::EncapsulatedADGameDesc &encapsulatedDesc) const = 0; + + + /** + * 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. + * + * @note The fslist parameter may be 0 -- in that case, it is assumed + * that the callback searchs the current directory. + */ + EncapsulatedADGameDesc fallbackDetect(const FSList *fslist) const { + return EncapsulatedADGameDesc(); + } }; } // End of namespace Common diff --git a/engines/agi/detection.cpp b/engines/agi/detection.cpp index c9fdde4ac4..d2912898ea 100644 --- a/engines/agi/detection.cpp +++ b/engines/agi/detection.cpp @@ -2255,8 +2255,6 @@ static const Common::ADParams detectionParams = { "agi", // List of files for file-based fallback detection (optional) 0, - // Fallback callback - Agi::fallbackDetector, // Flags Common::kADFlagAugmentPreferredTarget }; @@ -2273,6 +2271,10 @@ public: } virtual bool createInstance(OSystem *syst, Engine **engine, const Common::EncapsulatedADGameDesc &encapsulatedDesc) const; + + Common::EncapsulatedADGameDesc fallbackDetect(const FSList *fslist) const { + return Agi::fallbackDetector(fslist); + } }; bool AgiMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::EncapsulatedADGameDesc &encapsulatedDesc) const { diff --git a/engines/agos/detection.cpp b/engines/agos/detection.cpp index 03b3322555..ce3e4f34de 100644 --- a/engines/agos/detection.cpp +++ b/engines/agos/detection.cpp @@ -93,8 +93,6 @@ static const Common::ADParams detectionParams = { 0, // List of files for file-based fallback detection (optional) 0, - // Fallback callback - 0, // Flags Common::kADFlagAugmentPreferredTarget }; diff --git a/engines/cine/detection.cpp b/engines/cine/detection.cpp index 6c05c9a2e2..d9765a6b5c 100644 --- a/engines/cine/detection.cpp +++ b/engines/cine/detection.cpp @@ -482,8 +482,6 @@ static const Common::ADParams detectionParams = { "cine", // List of files for file-based fallback detection (optional) 0, - // Fallback callback - 0, // Flags Common::kADFlagAugmentPreferredTarget }; diff --git a/engines/cruise/detection.cpp b/engines/cruise/detection.cpp index 568c131b31..07d2ab7c8e 100644 --- a/engines/cruise/detection.cpp +++ b/engines/cruise/detection.cpp @@ -117,8 +117,6 @@ static const Common::ADParams detectionParams = { "cruise", // List of files for file-based fallback detection (optional) 0, - // Fallback callback - 0, // Flags Common::kADFlagAugmentPreferredTarget }; diff --git a/engines/drascula/detection.cpp b/engines/drascula/detection.cpp index e3b5b0dc44..3c9ac41ba4 100644 --- a/engines/drascula/detection.cpp +++ b/engines/drascula/detection.cpp @@ -157,8 +157,6 @@ static const Common::ADParams detectionParams = { "drascula", // List of files for file-based fallback detection (optional) 0, - // Fallback callback - Drascula::fallbackDetector, // Flags Common::kADFlagAugmentPreferredTarget }; @@ -176,6 +174,10 @@ public: } virtual bool createInstance(OSystem *syst, Engine **engine, const Common::EncapsulatedADGameDesc &encapsulatedDesc) const; + + Common::EncapsulatedADGameDesc fallbackDetect(const FSList *fslist) const { + return Drascula::fallbackDetector(fslist); + } }; bool DrasculaMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::EncapsulatedADGameDesc &encapsulatedDesc) const { diff --git a/engines/gob/detection.cpp b/engines/gob/detection.cpp index 8fcaeb7530..f3ff11ba75 100644 --- a/engines/gob/detection.cpp +++ b/engines/gob/detection.cpp @@ -1853,8 +1853,6 @@ static const ADParams detectionParams = { "gob", // List of files for file-based fallback detection (optional) Gob::fileBased, - // Fallback callback - 0, // Flags kADFlagAugmentPreferredTarget }; diff --git a/engines/igor/detection.cpp b/engines/igor/detection.cpp index c86d027a91..c938a77c1e 100644 --- a/engines/igor/detection.cpp +++ b/engines/igor/detection.cpp @@ -101,7 +101,6 @@ static const Common::ADParams igorDetectionParams = { 0, "igor", 0, - 0, Common::kADFlagAugmentPreferredTarget }; diff --git a/engines/kyra/detection.cpp b/engines/kyra/detection.cpp index f76a435b8a..f02c23a127 100644 --- a/engines/kyra/detection.cpp +++ b/engines/kyra/detection.cpp @@ -422,8 +422,6 @@ const Common::ADParams detectionParams = { 0, // List of files for file-based fallback detection (optional) 0, - // Fallback callback - 0, // Flags 0 }; diff --git a/engines/lure/detection.cpp b/engines/lure/detection.cpp index 6138bbc3a5..e7b4d1bcd8 100644 --- a/engines/lure/detection.cpp +++ b/engines/lure/detection.cpp @@ -168,8 +168,6 @@ static const Common::ADParams detectionParams = { "lure", // List of files for file-based fallback detection (optional) 0, - // Fallback callback - 0, // Flags Common::kADFlagAugmentPreferredTarget | Common::kADFlagUseExtraAsHint }; diff --git a/engines/parallaction/detection.cpp b/engines/parallaction/detection.cpp index 4d8b54085a..c608f58100 100644 --- a/engines/parallaction/detection.cpp +++ b/engines/parallaction/detection.cpp @@ -178,8 +178,6 @@ static const Common::ADParams detectionParams = { "parallaction", // List of files for file-based fallback detection (optional) 0, - // Fallback callback - 0, // Flags Common::kADFlagAugmentPreferredTarget }; diff --git a/engines/saga/detection.cpp b/engines/saga/detection.cpp index 1a04c7a001..2ac314cf73 100644 --- a/engines/saga/detection.cpp +++ b/engines/saga/detection.cpp @@ -135,8 +135,6 @@ static const Common::ADParams detectionParams = { "saga", // List of files for file-based fallback detection (optional) 0, - // Fallback callback - 0, // Flags Common::kADFlagAugmentPreferredTarget }; diff --git a/engines/touche/detection.cpp b/engines/touche/detection.cpp index 2b85f9f489..2fde7e9da1 100644 --- a/engines/touche/detection.cpp +++ b/engines/touche/detection.cpp @@ -120,7 +120,6 @@ static const Common::ADParams detectionParams = { 0, // no obsolete targets data "touche", Touche::fileBasedFallback, // file-based detection data to enable not yet known versions to start - 0, // no fallback callback Common::kADFlagAugmentPreferredTarget | Common::kADFlagPrintWarningOnFileBasedFallback }; |