Skip to content

Commit

Permalink
ENGINES: Continue to check file presence after a hash/size mismatch
Browse files Browse the repository at this point in the history
If an early file in the game's signature list has a hash/size
mismatch, it is still necessary to continue to check the rest of
the candidate files for existence, since the non-existence of
candidate files is supposed to disqualify a game description as
matching a game to an unknown variant.

By quitting the file check early, the detector had been allowing
descriptions to randomly match if there happened to be an early
file in the detection list with the right name but wrong hash/size,
even if some of the other signature files did not exist at all.
  • Loading branch information
csnover committed Nov 10, 2017
1 parent dda0f77 commit 66826a8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions engines/advancedDetector.cpp
Expand Up @@ -466,6 +466,7 @@ ADGameDescList AdvancedMetaEngine::detectGame(const Common::FSNode &parent, cons

bool allFilesPresent = true;
int curFilesMatched = 0;
bool hashOrSizeMismatch = false;

// Try to match all files for this game
for (fileDesc = g->filesDescriptions; fileDesc->fileName; fileDesc++) {
Expand All @@ -477,16 +478,21 @@ ADGameDescList AdvancedMetaEngine::detectGame(const Common::FSNode &parent, cons
break;
}

if (hashOrSizeMismatch)
continue;

if (fileDesc->md5 != NULL && fileDesc->md5 != filesProps[tstr].md5) {
debug(3, "MD5 Mismatch. Skipping (%s) (%s)", fileDesc->md5, filesProps[tstr].md5.c_str());
fileMissing = true;
break;
hashOrSizeMismatch = true;
continue;
}

if (fileDesc->fileSize != -1 && fileDesc->fileSize != filesProps[tstr].size) {
debug(3, "Size Mismatch. Skipping");
fileMissing = true;
break;
hashOrSizeMismatch = true;
continue;
}

debug(3, "Matched file: %s", tstr.c_str());
Expand Down

0 comments on commit 66826a8

Please sign in to comment.