DETECTOR: Change detectGameFilebased return value

This commit is contained in:
Max Horn 2011-06-14 17:32:13 +02:00
parent 0686204792
commit 64e523141f
2 changed files with 16 additions and 12 deletions

View File

@ -461,14 +461,17 @@ ADGameDescList AdvancedMetaEngine::detectGame(const Common::FSList &fslist, Comm
}
// Filename based fallback
if (_fileBasedFallback != 0)
matched = detectGameFilebased(allFiles);
if (_fileBasedFallback != 0) {
g = detectGameFilebased(allFiles);
if (g)
matched.push_back(g);
}
}
return matched;
}
ADGameDescList AdvancedMetaEngine::detectGameFilebased(const FileMap &allFiles) const {
const ADGameDescription *AdvancedMetaEngine::detectGameFilebased(const FileMap &allFiles) const {
const ADFileBasedFallback *ptr;
const char* const* filenames;
@ -502,10 +505,7 @@ ADGameDescList AdvancedMetaEngine::detectGameFilebased(const FileMap &allFiles)
}
}
ADGameDescList matched;
if (matchedDesc) { // We got a match
matched.push_back(matchedDesc);
if (_flags & kADFlagPrintWarningOnFileBasedFallback) {
Common::String report = Common::String::format(_("Your game version has been detected using "
"filename matching as a variant of %s."), matchedDesc->gameid);
@ -518,7 +518,7 @@ ADGameDescList AdvancedMetaEngine::detectGameFilebased(const FileMap &allFiles)
}
}
return matched;
return matchedDesc;
}
GameList AdvancedMetaEngine::getSupportedGames() const {

View File

@ -257,12 +257,16 @@ protected:
ADGameDescList detectGame(const Common::FSList &fslist, Common::Language language, Common::Platform platform, const Common::String &extra) const;
/**
* Check for each ADFileBasedFallback record whether all files listed
* in it are present. If multiple pass this test, we pick the one with
* the maximal number of matching files. In case of a tie, the entry
* coming first in the list is chosen.
* Iterates over all ADFileBasedFallback records inside _fileBasedFallback.
* This then returns the record (or rather, the ADGameDescription
* contained in it) for which all files described by it are present, and
* among those the one with the maximal number of matching files.
* In case of a tie, the entry coming first in the list is chosen.
*
* @param allFiles a map describing all present files
* @param fileBasedFallback a list of ADFileBasedFallback records, zero-terminated
*/
ADGameDescList detectGameFilebased(const FileMap &allFiles) const;
const ADGameDescription *detectGameFilebased(const FileMap &allFiles) const;
// TODO
void updateGameDescriptor(GameDescriptor &desc, const ADGameDescription *realDesc) const;