mirror of
https://github.com/libretro/scummvm.git
synced 2025-04-02 06:41:51 +00:00
DETECTOR: Get rid of ADGF_KEEPMATCH
Also fix some typos, and minor tweaks svn-id: r54118
This commit is contained in:
parent
1cbab9885b
commit
c5598664ce
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
},
|
||||
},
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user