aboutsummaryrefslogtreecommitdiff
path: root/common/advancedDetector.cpp
diff options
context:
space:
mode:
authorMax Horn2007-02-14 23:46:39 +0000
committerMax Horn2007-02-14 23:46:39 +0000
commitec27c53491a60258ecb8a67a023964d5ff94b9ab (patch)
treef67139506f8d96ac5d32542e0bb8e0ee1bd5c77e /common/advancedDetector.cpp
parent247110b19b97971295b1b9972aa9457971d18181 (diff)
downloadscummvm-rg350-ec27c53491a60258ecb8a67a023964d5ff94b9ab.tar.gz
scummvm-rg350-ec27c53491a60258ecb8a67a023964d5ff94b9ab.tar.bz2
scummvm-rg350-ec27c53491a60258ecb8a67a023964d5ff94b9ab.zip
AdvancedDetector: revamped the file based fallback code
svn-id: r25599
Diffstat (limited to 'common/advancedDetector.cpp')
-rw-r--r--common/advancedDetector.cpp54
1 files changed, 21 insertions, 33 deletions
diff --git a/common/advancedDetector.cpp b/common/advancedDetector.cpp
index 9ced59659a..809a279281 100644
--- a/common/advancedDetector.cpp
+++ b/common/advancedDetector.cpp
@@ -341,11 +341,6 @@ static ADGameDescList detectGame(const FSList *fslist, const Common::ADParams &p
continue;
}
- if (g->filesDescriptions[0].fileName == 0) {
- debug(5, "Skipping dummy entry: %s", g->gameid);
- continue;
- }
-
// Try to open all files for this game
for (fileDesc = g->filesDescriptions; fileDesc->fileName; fileDesc++) {
tstr = fileDesc->fileName;
@@ -423,18 +418,17 @@ static ADGameDescList detectGame(const FSList *fslist, const Common::ADParams &p
// to be present in order to generate a match; the row is terminated
// by a zero byte.
// The whole list is terminated by another zero byte (i.e. a zero gameid).
- const char **ptr = params.fileBasedFallback;
+ const ADFileBasedFallback *ptr = params.fileBasedFallback;
+ const char* const* filenames = 0;
// First we create list of files required for detection.
if (allFiles.empty()) {
File testFile;
- for (; *ptr; ptr++) {
- // skip the gameid
- ptr++;
-
- for (; *ptr; ptr++) {
- tstr = String(*ptr);
+ for (; ptr->desc; ptr++) {
+ filenames = ptr->filenames;
+ for (; *filenames; filenames++) {
+ tstr = String(*filenames);
tstr.toLowercase();
if (!allFiles.contains(tstr)) {
@@ -449,26 +443,27 @@ static ADGameDescList detectGame(const FSList *fslist, const Common::ADParams &p
}
int maxNumMatchedFiles = 0;
- const char *matchedGameid = 0;
+ const ADGameDescription *matchedDesc = 0;
ptr = params.fileBasedFallback;
- for (; *ptr; ptr++) {
- const char *entryGameid = *ptr++;
- fileMissing = false;
+ for (; ptr->desc; ptr++) {
+ const ADGameDescription *agdesc = (const ADGameDescription *)ptr->desc;
int numMatchedFiles = 0;
+ fileMissing = false;
- for (; *ptr; ptr++) {
+ filenames = ptr->filenames;
+ for (; *filenames; filenames++) {
if (fileMissing) {
continue;
}
- tstr = String(*ptr);
+ tstr = String(*filenames);
tstr.toLowercase();
tstr2 = tstr + ".";
- debug(3, "++ %s", *ptr);
+ debug(3, "++ %s", *filenames);
if (!allFiles.contains(tstr) && !allFiles.contains(tstr2)) {
fileMissing = true;
continue;
@@ -478,29 +473,22 @@ static ADGameDescList detectGame(const FSList *fslist, const Common::ADParams &p
}
if (!fileMissing)
- debug(4, "Matched: %s", entryGameid);
+ debug(4, "Matched: %s", agdesc->gameid);
if (!fileMissing && numMatchedFiles > maxNumMatchedFiles) {
- matchedGameid = entryGameid;
+ matchedDesc = agdesc;
maxNumMatchedFiles = numMatchedFiles;
debug(4, "and overriden");
}
}
- if (matchedGameid) { // We got a match
- for (descPtr = params.descs; ((const ADGameDescription *)descPtr)->gameid != 0; descPtr += params.descItemSize) {
- g = (const ADGameDescription *)descPtr;
- if (g->filesDescriptions[0].fileName == 0) {
- if (!scumm_stricmp(g->gameid, matchedGameid)) {
- // FIXME: This warning, if ever seen by somebody, is
- // extremly cryptic!
- warning("But it looks like unknown variant of %s", matchedGameid);
+ if (matchedDesc) { // We got a match
+ // FIXME: This warning, if ever seen by somebody, is
+ // extremly cryptic!
+ warning("But it looks like unknown variant of %s", matchedDesc->gameid);
- matched.push_back(g);
- }
- }
- }
+ matched.push_back(matchedDesc);
}
}