From cf1ebf29516bd74927fd7b632b72fd8973f72e98 Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Sat, 2 Dec 2017 17:14:22 +0100 Subject: ENGINES: Add unknown game variants to the game detector results --- base/commandLine.cpp | 38 ++++++++++++++++++++++++++++++-------- base/plugins.cpp | 20 +++++++++++++++----- 2 files changed, 45 insertions(+), 13 deletions(-) (limited to 'base') diff --git a/base/commandLine.cpp b/base/commandLine.cpp index 83c7b56171..8e701408ef 100644 --- a/base/commandLine.cpp +++ b/base/commandLine.cpp @@ -864,12 +864,20 @@ static GameList getGameList(const Common::FSNode &dir) { } // detect Games - GameList candidates(EngineMan.detectGames(files)); - Common::String dataPath = dir.getPath(); - // add game data path - for (GameList::iterator v = candidates.begin(); v != candidates.end(); ++v) { - (*v)["path"] = dataPath; + DetectionResults detectionResults = EngineMan.detectGames(files); + + if (detectionResults.foundUnknownGames()) { + Common::String report = detectionResults.generateUnknownGameReport(false, 80); + g_system->logMessage(LogMessageType::kInfo, report.c_str()); } + + DetectedGames detectedGames = detectionResults.listRecognizedGames(); + + GameList candidates; + for (uint i = 0; i < detectedGames.size(); i++) { + candidates.push_back(detectedGames[i].matchedGame); + } + return candidates; } @@ -1014,7 +1022,14 @@ static void runDetectorTest() { continue; } - GameList candidates(EngineMan.detectGames(files)); + DetectionResults detectionResults = EngineMan.detectGames(files); + DetectedGames detectedGames = detectionResults.listRecognizedGames(); + + GameList candidates; + for (uint i = 0; i < detectedGames.size(); i++) { + candidates.push_back(detectedGames[i].matchedGame); + } + bool gameidDiffers = false; GameList::iterator x; for (x = candidates.begin(); x != candidates.end(); ++x) { @@ -1092,7 +1107,14 @@ void upgradeTargets() { Common::Platform plat = Common::parsePlatform(dom.getVal("platform")); Common::String desc(dom.getVal("description")); - GameList candidates(EngineMan.detectGames(files)); + DetectionResults detectionResults = EngineMan.detectGames(files); + DetectedGames detectedGames = detectionResults.listRecognizedGames(); + + GameList candidates; + for (uint i = 0; i < detectedGames.size(); i++) { + candidates.push_back(detectedGames[i].matchedGame); + } + GameDescriptor *g = 0; // We proceed as follows: @@ -1100,7 +1122,7 @@ void upgradeTargets() { // * If there is a unique detector match, trust it. // * If there are multiple match, run over them comparing gameid, language and platform. // If we end up with a unique match, use it. Otherwise, skip. - if (candidates.size() == 0) { + if (candidates.empty()) { printf(" ... failed to detect game, skipping\n"); continue; } diff --git a/base/plugins.cpp b/base/plugins.cpp index 852786919b..02f6998ad9 100644 --- a/base/plugins.cpp +++ b/base/plugins.cpp @@ -22,6 +22,7 @@ #include "base/plugins.h" +#include "common/translation.h" #include "common/func.h" #include "common/debug.h" #include "common/config-manager.h" @@ -514,8 +515,9 @@ GameDescriptor EngineManager::findGameInLoadedPlugins(const Common::String &game return result; } -GameList EngineManager::detectGames(const Common::FSList &fslist, bool useUnknownGameDialog) const { - GameList candidates; +DetectionResults EngineManager::detectGames(const Common::FSList &fslist) const { + DetectedGames candidates; + Common::String path = fslist.begin()->getParent().getPath(); PluginList plugins; PluginList::const_iterator iter; PluginManager::instance().loadFirstPlugin(); @@ -524,17 +526,25 @@ GameList EngineManager::detectGames(const Common::FSList &fslist, bool useUnknow // Iterate over all known games and for each check if it might be // the game in the presented directory. for (iter = plugins.begin(); iter != plugins.end(); ++iter) { - candidates.push_back((*iter)->get().detectGames(fslist, useUnknownGameDialog)); + const MetaEngine &metaEngine = (*iter)->get(); + DetectedGames engineCandidates = metaEngine.detectGames(fslist); + + for (uint i = 0; i < engineCandidates.size(); i++) { + engineCandidates[i].engineName = metaEngine.getName(); + engineCandidates[i].matchedGame["path"] = path; + candidates.push_back(engineCandidates[i]); + } + } } while (PluginManager::instance().loadNextPlugin()); - return candidates; + + return DetectionResults(candidates); } const PluginList &EngineManager::getPlugins() const { return PluginManager::instance().getPlugins(PLUGIN_TYPE_ENGINE); } - // Music plugins #include "audio/musicplugin.h" -- cgit v1.2.3