From 7572d2b4f2ac98cf31602d6c5e4ed7399de54a30 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Tue, 13 Feb 2007 23:37:44 +0000 Subject: Changed detectBestMatchingGame to return a pointer to a ADGameDescription (or a subclass of it); added a (currently fake) fallback callback entry in ADParams svn-id: r25574 --- common/advancedDetector.cpp | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'common/advancedDetector.cpp') diff --git a/common/advancedDetector.cpp b/common/advancedDetector.cpp index d6ec293620..1b0f5e2817 100644 --- a/common/advancedDetector.cpp +++ b/common/advancedDetector.cpp @@ -188,9 +188,10 @@ GameList detectAllGames( return detectedGames; } -int detectBestMatchingGame( +const ADGameDescription *detectBestMatchingGame( const Common::ADParams ¶ms ) { + const ADGameDescription *agdDesc = 0; Common::Language language = Common::UNK_LANG; Common::Platform platform = Common::kPlatformUnknown; @@ -203,24 +204,23 @@ int detectBestMatchingGame( Common::ADList matches = detectGame(0, params, language, platform); - int gameNumber = -1; - if (params.singleid == NULL) { for (uint i = 0; i < matches.size(); i++) { - if (((const ADGameDescription *)(params.descs + matches[i] * params.descItemSize))->gameid == gameid) { - gameNumber = matches[i]; + agdDesc = (const ADGameDescription *)(params.descs + matches[i] * params.descItemSize); + if (agdDesc->gameid == gameid) { break; } + agdDesc = 0; } - } else { - gameNumber = matches[0]; + } else if (matches.size() > 0) { + agdDesc = (const ADGameDescription *)(params.descs + matches[0] * params.descItemSize); } - if (gameNumber >= 0) { - debug(2, "Running %s", toGameDescriptor(*(const ADGameDescription *)(params.descs + gameNumber * params.descItemSize), params.list).description().c_str()); + if (agdDesc != 0) { + debug(2, "Running %s", toGameDescriptor(*agdDesc, params.list).description().c_str()); } - return gameNumber; + return agdDesc; } PluginError detectGameForEngineCreation( @@ -426,6 +426,8 @@ static ADList detectGame(const FSList *fslist, const Common::ADParams ¶ms, L return matched; if (!filesMD5.empty()) { + // TODO: This message should be cleaned up / made more specific. + // For example, we should specify at least which engine triggered this. printf("MD5s of your game version are unknown. Please, report following data to\n"); printf("ScummVM team along with your game name and version:\n"); @@ -505,7 +507,7 @@ static ADList detectGame(const FSList *fslist, const Common::ADParams ¶ms, L matchEntry = entryStart; maxFiles = matchFiles; - debug(4, "and overrided"); + debug(4, "and overriden"); } ptr++; @@ -515,6 +517,8 @@ static ADList detectGame(const FSList *fslist, const Common::ADParams ¶ms, L for (i = 0; i < gameDescriptions.size(); i++) { if (gameDescriptions[i]->filesDescriptions[0].fileName == 0) { if (!scumm_stricmp(gameDescriptions[i]->gameid, *matchEntry)) { + // FIXME: This warning, if ever seen by somebody, is + // extremly cryptic! warning("But it looks like unknown variant of %s", *matchEntry); matched.push_back(i); @@ -523,7 +527,12 @@ static ADList detectGame(const FSList *fslist, const Common::ADParams ¶ms, L } } } - +/* + // If we still haven't got a match, try to use the fallback callback :-) + if (matched.empty() && params.fallbackDetectFunc != 0) { + matched = (*params.fallbackDetectFunc)(fslist); + } +*/ return matched; } -- cgit v1.2.3