AGS: Improve detection
For unknown variants it now checks that the file is actually an AGS game to avoid false positive due to generic names used by some of the detection entries (such as 'game.exe'). Also unknown variants can now be added.
This commit is contained in:
parent
456a82d937
commit
6d2a62fe72
4 changed files with 53 additions and 1 deletions
|
@ -198,7 +198,7 @@ DetectedGame AdvancedMetaEngineDetection::toDetectedGame(const ADDetectedGame &a
|
|||
return game;
|
||||
}
|
||||
|
||||
bool cleanupPirated(ADDetectedGames &matched) {
|
||||
bool AdvancedMetaEngineDetection::cleanupPirated(ADDetectedGames &matched) const {
|
||||
// OKay, now let's sense presence of pirated games
|
||||
if (!matched.empty()) {
|
||||
for (uint j = 0; j < matched.size();) {
|
||||
|
|
|
@ -428,6 +428,9 @@ protected:
|
|||
/** Convert an AD game description into the shared game description format. */
|
||||
virtual DetectedGame toDetectedGame(const ADDetectedGame &adGame) const;
|
||||
|
||||
/** Check for pirated games in the given detected games */
|
||||
bool cleanupPirated(ADDetectedGames &matched) const;
|
||||
|
||||
friend class FileMapArchive;
|
||||
};
|
||||
|
||||
|
|
|
@ -168,6 +168,53 @@ AGSMetaEngineDetection::AGSMetaEngineDetection() : AdvancedMetaEngineDetection(A
|
|||
sizeof(AGS::AGSGameDescription), AGS::GAME_NAMES) {
|
||||
}
|
||||
|
||||
DetectedGames AGSMetaEngineDetection::detectGames(const Common::FSList &fslist) const {
|
||||
FileMap allFiles;
|
||||
|
||||
if (fslist.empty())
|
||||
return DetectedGames();
|
||||
|
||||
// Compose a hashmap of all files in fslist.
|
||||
composeFileHashMap(allFiles, fslist, (_maxScanDepth == 0 ? 1 : _maxScanDepth));
|
||||
|
||||
// Run the detector on this
|
||||
ADDetectedGames matches = detectGame(fslist.begin()->getParent(), allFiles, Common::UNK_LANG, Common::kPlatformUnknown, "");
|
||||
|
||||
cleanupPirated(matches);
|
||||
|
||||
bool foundKnownGames = false;
|
||||
DetectedGames detectedGames;
|
||||
for (uint i = 0; i < matches.size(); i++) {
|
||||
DetectedGame game = toDetectedGame(matches[i]);
|
||||
if (game.hasUnknownFiles) {
|
||||
// Check the game is an AGS game
|
||||
for (FilePropertiesMap::const_iterator it = game.matchedFiles.begin(); it != game.matchedFiles.end(); it++) {
|
||||
Common::File f;
|
||||
if (f.open(allFiles[it->_key]) && AGS3::isAGSFile(f)) {
|
||||
detectedGames.push_back(game);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
detectedGames.push_back(game);
|
||||
foundKnownGames = true;
|
||||
}
|
||||
}
|
||||
|
||||
// If we didn't find a known game, also add a fallback detection
|
||||
if (!foundKnownGames) {
|
||||
// Use fallback detector if there were no matches by other means
|
||||
ADDetectedGame fallbackDetectionResult = fallbackDetect(allFiles, fslist);
|
||||
if (fallbackDetectionResult.desc) {
|
||||
DetectedGame fallbackDetectedGame = toDetectedGame(fallbackDetectionResult);
|
||||
fallbackDetectedGame.preferredTarget += "-fallback";
|
||||
|
||||
detectedGames.push_back(fallbackDetectedGame);
|
||||
}
|
||||
}
|
||||
return detectedGames;
|
||||
}
|
||||
|
||||
ADDetectedGame AGSMetaEngineDetection::fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const {
|
||||
// Set the default values for the fallback descriptor's ADGameDescription part.
|
||||
AGS::g_fallbackDesc.desc.language = Common::UNK_LANG;
|
||||
|
|
|
@ -69,6 +69,8 @@ public:
|
|||
return "AGS Engine (C) Chris Jones";
|
||||
}
|
||||
|
||||
DetectedGames detectGames(const Common::FSList &fslist) const override;
|
||||
|
||||
ADDetectedGame fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const override;
|
||||
|
||||
GUI::OptionsContainerWidget *buildEngineOptionsWidgetStatic(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue