aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2010-11-07 17:15:27 +0000
committerMax Horn2010-11-07 17:15:27 +0000
commitc5598664cef2091036c60eb55dec0168f507cbc4 (patch)
tree84238087294defbe142bd3ab3ef232f8127a3700
parent1cbab9885bc7af3ee758c4ca9ce61bb9cb3e5af9 (diff)
downloadscummvm-rg350-c5598664cef2091036c60eb55dec0168f507cbc4.tar.gz
scummvm-rg350-c5598664cef2091036c60eb55dec0168f507cbc4.tar.bz2
scummvm-rg350-c5598664cef2091036c60eb55dec0168f507cbc4.zip
DETECTOR: Get rid of ADGF_KEEPMATCH
Also fix some typos, and minor tweaks svn-id: r54118
-rw-r--r--engines/advancedDetector.cpp30
-rw-r--r--engines/advancedDetector.h1
-rw-r--r--engines/drascula/detection.cpp11
-rw-r--r--engines/tinsel/detection.cpp14
4 files changed, 28 insertions, 28 deletions
diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp
index d31330b69e..e030cba72a 100644
--- a/engines/advancedDetector.cpp
+++ b/engines/advancedDetector.cpp
@@ -244,18 +244,21 @@ GameList AdvancedMetaEngine::detectGames(const Common::FSList &fslist) const {
if (cleanupPirated(matches))
return detectedGames;
- // Use fallback detector if there were no matches by other means
if (matches.empty()) {
+ // Use fallback detector if there were no matches by other means
const ADGameDescription *fallbackDesc = fallbackDetect(fslist);
if (fallbackDesc != 0) {
GameDescriptor desc(toGameDescriptor(*fallbackDesc, params.list));
updateGameDescriptor(desc, fallbackDesc, params);
detectedGames.push_back(desc);
}
- } else for (uint i = 0; i < matches.size(); i++) { // Otherwise use the found matches
- GameDescriptor desc(toGameDescriptor(*matches[i], params.list));
- updateGameDescriptor(desc, matches[i], params);
- detectedGames.push_back(desc);
+ } else {
+ // Otherwise use the found matches
+ for (uint i = 0; i < matches.size(); i++) {
+ GameDescriptor desc(toGameDescriptor(*matches[i], params.list));
+ updateGameDescriptor(desc, matches[i], params);
+ detectedGames.push_back(desc);
+ }
}
return detectedGames;
@@ -502,6 +505,7 @@ static ADGameDescList detectGame(const Common::FSList &fslist, const ADParams &p
continue;
bool allFilesPresent = true;
+ int curFilesMatched = 0;
// Try to match all files for this game
for (fileDesc = g->filesDescriptions; fileDesc->fileName; fileDesc++) {
@@ -526,12 +530,13 @@ static ADGameDescList detectGame(const Common::FSList &fslist, const ADParams &p
}
debug(3, "Matched file: %s", tstr.c_str());
+ curFilesMatched++;
}
// We found at least one entry with all required files present.
// That means that we got new variant of the game.
//
- // Wihtout this check we would have errorneous checksum display
+ // Without this check we would have erroneous checksum display
// where only located files will be enlisted.
//
// Potentially this could rule out variants where some particular file
@@ -544,22 +549,11 @@ static ADGameDescList detectGame(const Common::FSList &fslist, const ADParams &p
debug(2, "Found game: %s (%s %s/%s) (%d)", g->gameid, g->extra,
getPlatformDescription(g->platform), getLanguageDescription(g->language), i);
- // Count the number of matching files. Then, only keep those
- // entries which match a maximal amount of files.
- int curFilesMatched = 0;
- for (fileDesc = g->filesDescriptions; fileDesc->fileName; fileDesc++)
- curFilesMatched++;
-
if (curFilesMatched > maxFilesMatched) {
debug(2, " ... new best match, removing all previous candidates");
maxFilesMatched = curFilesMatched;
- for (uint j = 0; j < matched.size();) {
- if (matched[j]->flags & ADGF_KEEPMATCH)
- ++j;
- else
- matched.remove_at(j);
- }
+ matched.clear(); // Remove any prior, lower ranked matches.
matched.push_back(g);
} else if (curFilesMatched == maxFilesMatched) {
matched.push_back(g);
diff --git a/engines/advancedDetector.h b/engines/advancedDetector.h
index 0ebb264f74..515127b23d 100644
--- a/engines/advancedDetector.h
+++ b/engines/advancedDetector.h
@@ -49,7 +49,6 @@ enum ADGameFlags {
ADGF_ADDENGLISH = (1 << 24), // always add English as language option
ADGF_MACRESFORK = (1 << 25), // the md5 for this entry will be calculated from the resource fork
ADGF_USEEXTRAASTITLE = (1 << 26), // Extra field value will be used as main game title, not gameid
- ADGF_KEEPMATCH = (1 << 27), // this entry is kept even when there are matched entries with more files
ADGF_DROPLANGUAGE = (1 << 28), // don't add language to gameid
ADGF_CD = (1 << 29), // add "-cd" to gameid
ADGF_DEMO = (1 << 30) // add "-demo" to gameid
diff --git a/engines/drascula/detection.cpp b/engines/drascula/detection.cpp
index 0dafcdc3cd..82b42c7390 100644
--- a/engines/drascula/detection.cpp
+++ b/engines/drascula/detection.cpp
@@ -88,10 +88,17 @@ static const DrasculaGameDescription gameDescriptions[] = {
{
"drascula",
0,
- AD_ENTRY1s("packet.001", "c6a8697396e213a18472542d5f547cb4", 32847563),
+ {
+ {"packet.001", 0, "c6a8697396e213a18472542d5f547cb4", 32847563},
+ // HACK: List packet.001 twice to ensure this detector entry
+ // is ranked just as high as the others (which each have two
+ // detection files).
+ {"packet.001", 0, "c6a8697396e213a18472542d5f547cb4", 32847563},
+ {NULL, 0, NULL, 0}
+ },
Common::EN_ANY,
Common::kPlatformPC,
- ADGF_KEEPMATCH | GF_PACKED,
+ GF_PACKED,
GUIO_NONE
},
},
diff --git a/engines/tinsel/detection.cpp b/engines/tinsel/detection.cpp
index b32e742e6d..cbd0ba267b 100644
--- a/engines/tinsel/detection.cpp
+++ b/engines/tinsel/detection.cpp
@@ -212,8 +212,13 @@ const ADGameDescription *TinselMetaEngine::fallbackDetect(const Common::FSList &
if (fslist.empty())
return NULL;
+ // TODO: The following code is essentially a slightly modified copy of the
+ // complete code of function detectGame() in engines/advancedDetector.cpp.
+ // That quite some hefty and undesirable code duplication. Its only purpose
+ // seems to be to treat filenames of the form "foo1.ext" as "foo.ext".
+ // It would be nice to avoid this code duplication.
+
// First we compose a hashmap of all files in fslist.
- // Includes nifty stuff like removing trailing dots and ignoring case.
for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
if (file->isDirectory()) {
if (!scumm_stricmp(file->getName().c_str(), "dw2")) {
@@ -337,12 +342,7 @@ const ADGameDescription *TinselMetaEngine::fallbackDetect(const Common::FSList &
if (curFilesMatched > maxFilesMatched) {
maxFilesMatched = curFilesMatched;
- for (uint j = 0; j < matched.size();) {
- if (matched[j]->flags & ADGF_KEEPMATCH)
- ++j;
- else
- matched.remove_at(j);
- }
+ matched.clear(); // Remove any prior, lower ranked matches.
matched.push_back((const ADGameDescription *)g);
} else if (curFilesMatched == maxFilesMatched) {
matched.push_back((const ADGameDescription *)g);