From e01416ef32ba75ce1a645bd3430ca144f3fce240 Mon Sep 17 00:00:00 2001 From: athrxx Date: Sat, 14 May 2022 14:44:26 +0200 Subject: [PATCH] COMMON: (AD) - allow mass add to skip targets with certain ADGF flags I added skipping for the ADGF_WARNING and ADGF_UNSUPPORTED flags. For me, this is mostly about fixing bug no. 13282. We sometimes have bogus entries which only have the purpose of presenting the error message (reasons for being unsupported) contained in the extra field of the detection entry. --- base/plugins.cpp | 4 ++-- engines/adl/detection.cpp | 6 +++--- engines/advancedDetector.cpp | 11 ++++++++--- engines/advancedDetector.h | 15 ++++++++------- engines/ags/detection.cpp | 4 ++-- engines/ags/detection.h | 2 +- engines/glk/detection.cpp | 2 +- engines/glk/detection.h | 2 +- engines/metaengine.h | 6 +++--- engines/scumm/detection.cpp | 4 ++-- engines/sky/detection.cpp | 4 ++-- engines/sword1/detection.cpp | 4 ++-- engines/sword2/detection.cpp | 4 ++-- gui/massadd.cpp | 4 +++- 14 files changed, 40 insertions(+), 32 deletions(-) diff --git a/base/plugins.cpp b/base/plugins.cpp index 694e7bece1e..e3b1f0dc596 100644 --- a/base/plugins.cpp +++ b/base/plugins.cpp @@ -717,7 +717,7 @@ QualifiedGameList EngineManager::findGameInLoadedPlugins(const Common::String &g return results; } -DetectionResults EngineManager::detectGames(const Common::FSList &fslist) { +DetectionResults EngineManager::detectGames(const Common::FSList &fslist, uint32 skipADFlags) { DetectedGames candidates; PluginList plugins; PluginList::const_iterator iter; @@ -735,7 +735,7 @@ DetectionResults EngineManager::detectGames(const Common::FSList &fslist) { MetaEngineDetection &metaEngine = (*iter)->get(); // set the debug flags DebugMan.addAllDebugChannels(metaEngine.getDebugChannels()); - DetectedGames engineCandidates = metaEngine.detectGames(fslist); + DetectedGames engineCandidates = metaEngine.detectGames(fslist, skipADFlags); for (uint i = 0; i < engineCandidates.size(); i++) { engineCandidates[i].path = fslist.begin()->getParent().getPath(); diff --git a/engines/adl/detection.cpp b/engines/adl/detection.cpp index 0355b6b8232..37009499226 100644 --- a/engines/adl/detection.cpp +++ b/engines/adl/detection.cpp @@ -488,7 +488,7 @@ public: return debugFlagList; } - ADDetectedGames detectGame(const Common::FSNode &parent, const FileMap &allFiles, Common::Language language, Common::Platform platform, const Common::String &extra) override; + ADDetectedGames detectGame(const Common::FSNode &parent, const FileMap &allFiles, Common::Language language, Common::Platform platform, const Common::String &extra, uint32 skipADFlags) override; bool addFileProps(const FileMap &allFiles, Common::String fname, FilePropertiesMap &filePropsMap) const; }; @@ -512,9 +512,9 @@ bool AdlMetaEngineDetection::addFileProps(const FileMap &allFiles, Common::Strin } // Based on AdvancedMetaEngine::detectGame -ADDetectedGames AdlMetaEngineDetection::detectGame(const Common::FSNode &parent, const FileMap &allFiles, Common::Language language, Common::Platform platform, const Common::String &extra) { +ADDetectedGames AdlMetaEngineDetection::detectGame(const Common::FSNode &parent, const FileMap &allFiles, Common::Language language, Common::Platform platform, const Common::String &extra, uint32 skipADFlags) { // We run the file-based detector first, if it finds a match we do not search for disk images - ADDetectedGames matched = AdvancedMetaEngineDetection::detectGame(parent, allFiles, language, platform, extra); + ADDetectedGames matched = AdvancedMetaEngineDetection::detectGame(parent, allFiles, language, platform, extra, skipADFlags); if (!matched.empty()) return matched; diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp index 2c2e676aa50..18fda81b8db 100644 --- a/engines/advancedDetector.cpp +++ b/engines/advancedDetector.cpp @@ -252,7 +252,7 @@ bool AdvancedMetaEngineDetection::cleanupPirated(ADDetectedGames &matched) const return false; } -DetectedGames AdvancedMetaEngineDetection::detectGames(const Common::FSList &fslist) { +DetectedGames AdvancedMetaEngineDetection::detectGames(const Common::FSList &fslist, uint32 skipADFlags) { FileMap allFiles; if (fslist.empty()) @@ -266,7 +266,7 @@ DetectedGames AdvancedMetaEngineDetection::detectGames(const Common::FSList &fsl composeFileHashMap(allFiles, fslist, (_maxScanDepth == 0 ? 1 : _maxScanDepth)); // Run the detector on this - ADDetectedGames matches = detectGame(fslist.begin()->getParent(), allFiles, Common::UNK_LANG, Common::kPlatformUnknown, ""); + ADDetectedGames matches = detectGame(fslist.begin()->getParent(), allFiles, Common::UNK_LANG, Common::kPlatformUnknown, "", skipADFlags); cleanupPirated(matches); @@ -573,7 +573,7 @@ static bool getFilePropertiesIntern(uint md5Bytes, const AdvancedMetaEngine::Fil return true; } -ADDetectedGames AdvancedMetaEngineDetection::detectGame(const Common::FSNode &parent, const FileMap &allFiles, Common::Language language, Common::Platform platform, const Common::String &extra) { +ADDetectedGames AdvancedMetaEngineDetection::detectGame(const Common::FSNode &parent, const FileMap &allFiles, Common::Language language, Common::Platform platform, const Common::String &extra, uint32 skipADFlags) { FilePropertiesMap filesProps; ADDetectedGames matched; @@ -627,6 +627,11 @@ ADDetectedGames AdvancedMetaEngineDetection::detectGame(const Common::FSNode &pa if ((_flags & kADFlagUseExtraAsHint) && !extra.empty() && g->extra != extra) continue; + if (g->flags & skipADFlags) { + debugC(3, kDebugGlobalDetection, "Skipping unsupported target for engine '%s' for the following reasons:\n\t'%s'", g->gameId, g->extra); + continue; + } + ADDetectedGame game(g); bool allFilesPresent = true; int curFilesMatched = 0; diff --git a/engines/advancedDetector.h b/engines/advancedDetector.h index 5e78b0c9380..6b51e1a9124 100644 --- a/engines/advancedDetector.h +++ b/engines/advancedDetector.h @@ -358,7 +358,7 @@ public: * (possibly empty) list of games supported by the engine that were * found among the given files. */ - DetectedGames detectGames(const Common::FSList &fslist) override; + DetectedGames detectGames(const Common::FSList &fslist, uint32 skipADFlags) override; /** * A generic createInstance. @@ -419,15 +419,16 @@ protected: * Parameters @p language and @p platform are used to pass the values * specified by the user. This is used to restrict search scope. * - * @param parent Parent node of this file node. - * @param allFiles List of all present files, as computed by the @ref composeFileHashMap. - * @param language Restrict results to the specified language. - * @param platform Restrict results to the specified platform. - * @param extra Restrict results to the specified @c extra string (only if @ref kADFlagUseExtraAsHint is set). + * @param parent Parent node of this file node. + * @param allFiles List of all present files, as computed by the @ref composeFileHashMap. + * @param language Restrict results to the specified language. + * @param platform Restrict results to the specified platform. + * @param extra Restrict results to the specified @c extra string (only if @ref kADFlagUseExtraAsHint is set). + * @param skipADFlags Specify bitmask of ADGF flags to be ignored (for mass add). * * @return A list of @ref ADGameDescription pointers corresponding to the matched games. */ - virtual ADDetectedGames detectGame(const Common::FSNode &parent, const FileMap &allFiles, Common::Language language, Common::Platform platform, const Common::String &extra); + virtual ADDetectedGames detectGame(const Common::FSNode &parent, const FileMap &allFiles, Common::Language language, Common::Platform platform, const Common::String &extra, uint32 skipADFlags = 0); /** * @return True if variant of a game with unknown files can be played with the engine and false otherwise. diff --git a/engines/ags/detection.cpp b/engines/ags/detection.cpp index 45260adb145..ea9ea85e9eb 100644 --- a/engines/ags/detection.cpp +++ b/engines/ags/detection.cpp @@ -74,7 +74,7 @@ AGSMetaEngineDetection::AGSMetaEngineDetection() : AdvancedMetaEngineDetection(A sizeof(AGS::AGSGameDescription), AGS::GAME_NAMES) { } -DetectedGames AGSMetaEngineDetection::detectGames(const Common::FSList &fslist) { +DetectedGames AGSMetaEngineDetection::detectGames(const Common::FSList &fslist, uint32 skipADFlags) { FileMap allFiles; if (fslist.empty()) @@ -84,7 +84,7 @@ DetectedGames AGSMetaEngineDetection::detectGames(const Common::FSList &fslist) composeFileHashMap(allFiles, fslist, (_maxScanDepth == 0 ? 1 : _maxScanDepth)); // Run the detector on this - ADDetectedGames matches = detectGame(fslist.begin()->getParent(), allFiles, Common::UNK_LANG, Common::kPlatformUnknown, ""); + ADDetectedGames matches = detectGame(fslist.begin()->getParent(), allFiles, Common::UNK_LANG, Common::kPlatformUnknown, "", skipADFlags); cleanupPirated(matches); diff --git a/engines/ags/detection.h b/engines/ags/detection.h index 59728685316..b5032a85915 100644 --- a/engines/ags/detection.h +++ b/engines/ags/detection.h @@ -86,7 +86,7 @@ public: return debugFlagList; } - DetectedGames detectGames(const Common::FSList &fslist) override; + DetectedGames detectGames(const Common::FSList &fslist, uint32 skipADFlags) override; ADDetectedGame fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist, ADDetectedGameExtraInfo **extra = nullptr) const override; diff --git a/engines/glk/detection.cpp b/engines/glk/detection.cpp index eaccd819e46..b8cf789529c 100644 --- a/engines/glk/detection.cpp +++ b/engines/glk/detection.cpp @@ -180,7 +180,7 @@ PlainGameDescriptor GlkMetaEngineDetection::findGame(const char *gameId) const { #undef FIND_GAME -DetectedGames GlkMetaEngineDetection::detectGames(const Common::FSList &fslist) { +DetectedGames GlkMetaEngineDetection::detectGames(const Common::FSList &fslist, uint32 /*skipADFlags*/) { #ifndef RELEASE_BUILD // This is as good a place as any to detect multiple sub-engines using the same Ids detectClashes(); diff --git a/engines/glk/detection.h b/engines/glk/detection.h index e433eb91bf8..c990057e28b 100644 --- a/engines/glk/detection.h +++ b/engines/glk/detection.h @@ -56,7 +56,7 @@ public: * (possibly empty) list of games supported by the engine which it was able * to detect amongst the given files. */ - DetectedGames detectGames(const Common::FSList &fslist) override; + DetectedGames detectGames(const Common::FSList &fslist, uint32 /*skipADFlags*/) override; /** * Query the engine for a PlainGameDescriptor for the specified gameid, if any. diff --git a/engines/metaengine.h b/engines/metaengine.h index f35ff98a618..3ded2c1c2e3 100644 --- a/engines/metaengine.h +++ b/engines/metaengine.h @@ -157,7 +157,7 @@ public: * (possibly empty) list of games supported by the engine that were * found among the given files. */ - virtual DetectedGames detectGames(const Common::FSList &fslist) = 0; + virtual DetectedGames detectGames(const Common::FSList &fslist, uint32 skipADFlags = 0) = 0; /** * Return a list of extra GUI options for the specified target. @@ -574,10 +574,10 @@ class EngineManager : public Common::Singleton { public: /** * Given a list of FSNodes in a given directory, detect a set of games contained within. - * + * @ param skipADFlags Ignore results which are flagged with the ADGF flags specified here (for mass add) * Returns an empty list if none are found. */ - DetectionResults detectGames(const Common::FSList &fslist); + DetectionResults detectGames(const Common::FSList &fslist, uint32 skipADFlags = 0); /** Find a plugin by its engine ID. */ const Plugin *findPlugin(const Common::String &engineId) const; diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp index a8351bad242..51122a1c6aa 100644 --- a/engines/scumm/detection.cpp +++ b/engines/scumm/detection.cpp @@ -82,7 +82,7 @@ public: PlainGameList getSupportedGames() const override; PlainGameDescriptor findGame(const char *gameid) const override; - DetectedGames detectGames(const Common::FSList &fslist) override; + DetectedGames detectGames(const Common::FSList &fslist, uint32 /*skipADFlags*/) override; const ExtraGuiOptions getExtraGuiOptions(const Common::String &target) const override; }; @@ -121,7 +121,7 @@ static Common::String generatePreferredTarget(const DetectorResult &x) { return res; } -DetectedGames ScummMetaEngineDetection::detectGames(const Common::FSList &fslist) { +DetectedGames ScummMetaEngineDetection::detectGames(const Common::FSList &fslist, uint32 /*skipADFlags*/) { DetectedGames detectedGames; Common::List results; ::detectGames(fslist, results, nullptr); diff --git a/engines/sky/detection.cpp b/engines/sky/detection.cpp index bd0d971a948..afb4f8855ea 100644 --- a/engines/sky/detection.cpp +++ b/engines/sky/detection.cpp @@ -76,7 +76,7 @@ public: PlainGameList getSupportedGames() const override; const ExtraGuiOptions getExtraGuiOptions(const Common::String &target) const override; PlainGameDescriptor findGame(const char *gameid) const override; - DetectedGames detectGames(const Common::FSList &fslist) override; + DetectedGames detectGames(const Common::FSList &fslist, uint32 /*skipADFlags*/) override; }; const char *SkyMetaEngineDetection::getName() const { @@ -118,7 +118,7 @@ PlainGameDescriptor SkyMetaEngineDetection::findGame(const char *gameid) const { return PlainGameDescriptor::empty(); } -DetectedGames SkyMetaEngineDetection::detectGames(const Common::FSList &fslist) { +DetectedGames SkyMetaEngineDetection::detectGames(const Common::FSList &fslist, uint32 /*skipADFlags*/) { DetectedGames detectedGames; bool hasSkyDsk = false; bool hasSkyDnr = false; diff --git a/engines/sword1/detection.cpp b/engines/sword1/detection.cpp index 8eaf2612703..8065d815579 100644 --- a/engines/sword1/detection.cpp +++ b/engines/sword1/detection.cpp @@ -85,7 +85,7 @@ public: PlainGameList getSupportedGames() const override; PlainGameDescriptor findGame(const char *gameId) const override; - DetectedGames detectGames(const Common::FSList &fslist) override; + DetectedGames detectGames(const Common::FSList &fslist, uint32 /*skipADFlags*/) override; }; PlainGameList SwordMetaEngineDetection::getSupportedGames() const { @@ -132,7 +132,7 @@ void Sword1CheckDirectory(const Common::FSList &fslist, bool *filesFound) { } } -DetectedGames SwordMetaEngineDetection::detectGames(const Common::FSList &fslist) { +DetectedGames SwordMetaEngineDetection::detectGames(const Common::FSList &fslist, uint32 /*skipADFlags*/) { int i, j; DetectedGames detectedGames; bool filesFound[NUM_FILES_TO_CHECK]; diff --git a/engines/sword2/detection.cpp b/engines/sword2/detection.cpp index 5ac8914220f..9b21e57cb2f 100644 --- a/engines/sword2/detection.cpp +++ b/engines/sword2/detection.cpp @@ -53,7 +53,7 @@ public: PlainGameList getSupportedGames() const override; const ExtraGuiOptions getExtraGuiOptions(const Common::String &target) const override; PlainGameDescriptor findGame(const char *gameid) const override; - DetectedGames detectGames(const Common::FSList &fslist) override; + DetectedGames detectGames(const Common::FSList &fslist, uint32 /*skipADFlags*/) override; }; PlainGameList Sword2MetaEngineDetection::getSupportedGames() const { @@ -82,7 +82,7 @@ PlainGameDescriptor Sword2MetaEngineDetection::findGame(const char *gameid) cons return PlainGameDescriptor::of(g->gameid, g->description); } -DetectedGames Sword2MetaEngineDetection::detectGames(const Common::FSList &fslist) { +DetectedGames Sword2MetaEngineDetection::detectGames(const Common::FSList &fslist, uint32 /*skipADFlags*/) { // The required game data files can be located in the game directory, or in // a subdirectory called "clusters". In the latter case, we don't want to // detect the game in that subdirectory, as this will detect the game twice diff --git a/gui/massadd.cpp b/gui/massadd.cpp index 018c96bee7e..3c4db548aaa 100644 --- a/gui/massadd.cpp +++ b/gui/massadd.cpp @@ -27,6 +27,8 @@ #include "common/taskbar.h" #include "common/translation.h" +#include "engines/advancedDetector.h" + #include "gui/massadd.h" #ifndef DISABLE_MASS_ADD @@ -174,7 +176,7 @@ void MassAddDialog::handleTickle() { } // Run the detector on the dir - DetectionResults detectionResults = EngineMan.detectGames(files); + DetectionResults detectionResults = EngineMan.detectGames(files, (ADGF_WARNING | ADGF_UNSUPPORTED)); if (detectionResults.foundUnknownGames()) { Common::U32String report = detectionResults.generateUnknownGameReport(false, 80);