diff options
author | Max Horn | 2007-02-14 23:46:39 +0000 |
---|---|---|
committer | Max Horn | 2007-02-14 23:46:39 +0000 |
commit | ec27c53491a60258ecb8a67a023964d5ff94b9ab (patch) | |
tree | f67139506f8d96ac5d32542e0bb8e0ee1bd5c77e /common | |
parent | 247110b19b97971295b1b9972aa9457971d18181 (diff) | |
download | scummvm-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')
-rw-r--r-- | common/advancedDetector.cpp | 54 | ||||
-rw-r--r-- | common/advancedDetector.h | 18 |
2 files changed, 38 insertions, 34 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); } } diff --git a/common/advancedDetector.h b/common/advancedDetector.h index 937c190b19..7640cf945a 100644 --- a/common/advancedDetector.h +++ b/common/advancedDetector.h @@ -79,6 +79,21 @@ struct ADObsoleteGameID { Common::Platform platform; }; +struct ADFileBasedFallback { + /** + * Pointer to an ADGameDescription or subclass thereof. + */ + const void *desc; + + /** + * A zero-terminated list of filenames. + * + * @todo Properly explain this + */ + const char *filenames[10]; +}; + + enum ADFlags { /** * Generate/augment preferred target with information on the language (if @@ -142,10 +157,11 @@ struct ADParams { * List of files for file-based fallback detection (optional). * This is used if the regular MD5 based detection failed to * detect anything. + * As usual this list is terminated by an all-zero entry. * * @todo Properly explain this */ - const char **fileBasedFallback; + const ADFileBasedFallback *fileBasedFallback; /** * A callback pointing to an (optional) generic fallback detect |