diff options
-rw-r--r-- | common/advancedDetector.cpp | 18 | ||||
-rw-r--r-- | common/advancedDetector.h | 3 |
2 files changed, 16 insertions, 5 deletions
diff --git a/common/advancedDetector.cpp b/common/advancedDetector.cpp index 3b235835f3..6e72b35e44 100644 --- a/common/advancedDetector.cpp +++ b/common/advancedDetector.cpp @@ -48,7 +48,7 @@ namespace AdvancedDetector { * @param platform restrict results to specified platform only * @return list of ADGameDescription (or subclass) pointers corresponding to matched games */ -static ADGameDescList detectGame(const FSList *fslist, const Common::ADParams ¶ms, Language language, Platform platform); +static ADGameDescList detectGame(const FSList *fslist, const Common::ADParams ¶ms, Language language, Platform platform, const Common::String extra); GameList gameIDList(const Common::ADParams ¶ms) { @@ -194,13 +194,16 @@ static void updateGameDescriptor(GameDescriptor &desc, const ADGameDescription * desc["preferredtarget"] = generatePreferredTarget(desc["preferredtarget"], realDesc); } + + if (params.flags & kADFlagUseExtraAsHint) + desc["extra"] = realDesc->extra; } GameList detectAllGames( const FSList &fslist, const Common::ADParams ¶ms ) { - ADGameDescList matches = detectGame(&fslist, params, Common::UNK_LANG, Common::kPlatformUnknown); + ADGameDescList matches = detectGame(&fslist, params, Common::UNK_LANG, Common::kPlatformUnknown, ""); GameList detectedGames; // Use fallback detector if there were no matches by other means @@ -227,15 +230,19 @@ EncapsulatedADGameDesc detectBestMatchingGame( EncapsulatedADGameDesc result; Common::Language language = Common::UNK_LANG; Common::Platform platform = Common::kPlatformUnknown; + Common::String extra(""); if (ConfMan.hasKey("language")) language = Common::parseLanguage(ConfMan.get("language")); if (ConfMan.hasKey("platform")) platform = Common::parsePlatform(ConfMan.get("platform")); + if (params.flags & kADFlagUseExtraAsHint) + if (ConfMan.hasKey("extra")) + extra = ConfMan.get("extra"); Common::String gameid = ConfMan.get("gameid"); - ADGameDescList matches = detectGame(0, params, language, platform); + ADGameDescList matches = detectGame(0, params, language, platform, extra); if (params.singleid == NULL) { for (uint i = 0; i < matches.size(); i++) { @@ -303,7 +310,7 @@ void reportUnknown(StringList &files, int md5Bytes) { reportUnknown(filesMD5, filesSize); } -static ADGameDescList detectGame(const FSList *fslist, const Common::ADParams ¶ms, Language language, Platform platform) { +static ADGameDescList detectGame(const FSList *fslist, const Common::ADParams ¶ms, Language language, Platform platform, const Common::String extra) { typedef HashMap<String, bool, CaseSensitiveString_Hash, CaseSensitiveString_EqualTo> StringSet; StringSet filesList; @@ -404,6 +411,9 @@ static ADGameDescList detectGame(const FSList *fslist, const Common::ADParams &p continue; } + if ((params.flags & kADFlagUseExtraAsHint) && extra != "" && g->extra != extra) + continue; + // Try to match all files for this game for (fileDesc = g->filesDescriptions; fileDesc->fileName; fileDesc++) { tstr = fileDesc->fileName; diff --git a/common/advancedDetector.h b/common/advancedDetector.h index 818bbad740..f0d6c88e4e 100644 --- a/common/advancedDetector.h +++ b/common/advancedDetector.h @@ -126,7 +126,8 @@ enum ADFlags { * not equal to english) and platform (if not equal to PC). */ kADFlagAugmentPreferredTarget = (1 << 0), - kADFlagPrintWarningOnFileBasedFallback = (1 << 1) + kADFlagPrintWarningOnFileBasedFallback = (1 << 1), + kADFlagUseExtraAsHint = (1 << 2) }; /** |