aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorMax Horn2007-02-13 23:37:44 +0000
committerMax Horn2007-02-13 23:37:44 +0000
commit7572d2b4f2ac98cf31602d6c5e4ed7399de54a30 (patch)
treed96c82e9cae2736feef9b6d5ac7801273c5107a7 /common
parentde02e840a6dd619e221a750b0b2a63d157f05114 (diff)
downloadscummvm-rg350-7572d2b4f2ac98cf31602d6c5e4ed7399de54a30.tar.gz
scummvm-rg350-7572d2b4f2ac98cf31602d6c5e4ed7399de54a30.tar.bz2
scummvm-rg350-7572d2b4f2ac98cf31602d6c5e4ed7399de54a30.zip
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
Diffstat (limited to 'common')
-rw-r--r--common/advancedDetector.cpp33
-rw-r--r--common/advancedDetector.h46
2 files changed, 47 insertions, 32 deletions
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 &params
) {
+ 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 &params, 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 &params, 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 &params, 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 &params, 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;
}
diff --git a/common/advancedDetector.h b/common/advancedDetector.h
index 592b019c9b..799c796d3f 100644
--- a/common/advancedDetector.h
+++ b/common/advancedDetector.h
@@ -120,7 +120,7 @@ struct ADParams {
const PlainGameDescriptor *list;
/**
- * Structure for autoupgrading obsolete targets (optional)
+ * Structure for autoupgrading obsolete targets (optional).
*
* @todo Properly explain this.
*/
@@ -134,13 +134,31 @@ struct ADParams {
const char *singleid;
/**
- * List of files for file-based fallback detection (optional)
-
+ * List of files for file-based fallback detection (optional).
+ * This is used if the regular MD5 based detection failed to
+ * detect anything.
+ *
* @todo Properly explain this
*/
const char **fileBasedFallback;
+
+ /**
+ * A callback pointing to an (optional) generic fallback detect
+ * function. If present, this gets called if both the regular
+ * MD5 based detection as well as the file based fallback failed
+ * to detect anything. It is supposed
+ *
+ * @note The fslist parameter may be 0 -- in that case, it is assumed
+ * that the callback searchs the current directory.
+ */
+ //GameList (*fallbackDetectFunc)(const FSList *fslist);
+ uint dummy;
- /** Flags */
+ /**
+ * 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.
+ */
uint32 flags;
};
@@ -158,31 +176,19 @@ GameList gameIDList(const Common::ADParams &params);
* 'gameid' in there. If a match is found, returns a GameDescriptor
* with gameid and description set.
*/
-GameDescriptor findGameID(
- const char *gameid,
- const Common::ADParams &params
- );
-
+GameDescriptor findGameID(const char *gameid, const Common::ADParams &params);
// FIXME/TODO: Rename this function to something more sensible.
-GameList detectAllGames(
- const FSList &fslist,
- const Common::ADParams &params
- );
-
+GameList detectAllGames(const FSList &fslist, const Common::ADParams &params);
// FIXME/TODO: Rename this function to something more sensible.
-int detectBestMatchingGame(
- const Common::ADParams &params
- );
+const ADGameDescription *detectBestMatchingGame(const Common::ADParams &params);
// FIXME/TODO: Rename this function to something more sensible.
void upgradeTargetIfNecessary(const Common::ADParams &params);
// FIXME/TODO: Rename this function to something more sensible.
-PluginError detectGameForEngineCreation(
- const Common::ADParams &params
- );
+PluginError detectGameForEngineCreation(const Common::ADParams &params);
// FIXME: It would probably be good to merge detectBestMatchingGame