[Scummvm-git-logs] scummvm master -> 6d2a62fe72a773fca04a05baf2c174df1200f686

criezy criezy at scummvm.org
Sat Apr 17 21:21:08 UTC 2021


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
6d2a62fe72 AGS: Improve detection


Commit: 6d2a62fe72a773fca04a05baf2c174df1200f686
    https://github.com/scummvm/scummvm/commit/6d2a62fe72a773fca04a05baf2c174df1200f686
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-04-17T22:20:59+01:00

Commit Message:
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.

Changed paths:
    engines/advancedDetector.cpp
    engines/advancedDetector.h
    engines/ags/detection.cpp
    engines/ags/detection.h


diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp
index ea439475e4..d570b2655d 100644
--- a/engines/advancedDetector.cpp
+++ b/engines/advancedDetector.cpp
@@ -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();) {
diff --git a/engines/advancedDetector.h b/engines/advancedDetector.h
index f2edff8440..7832779f2c 100644
--- a/engines/advancedDetector.h
+++ b/engines/advancedDetector.h
@@ -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;
 };
 
diff --git a/engines/ags/detection.cpp b/engines/ags/detection.cpp
index 8bade67155..78ed984868 100644
--- a/engines/ags/detection.cpp
+++ b/engines/ags/detection.cpp
@@ -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;
diff --git a/engines/ags/detection.h b/engines/ags/detection.h
index 21aebb58a2..63d72d9c14 100644
--- a/engines/ags/detection.h
+++ b/engines/ags/detection.h
@@ -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;




More information about the Scummvm-git-logs mailing list