[Scummvm-git-logs] scummvm master -> 967c8eaf5ea69b70dba9f25f66ef3646398e5a52

sev- noreply at scummvm.org
Mon Jul 3 10:54:55 UTC 2023


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

Summary:
5f3e062f97 BASE: Add --dump-all-detection-entries command
bb20579bee BASE: Add dumpAllDetectionEntries() to commandLine
c09ef64b7f BASE: Update dumpDetectionEntries() and md5PropToGameFile()
41d9855273 BASE: Add metadata to dumped detection entries
967c8eaf5e BASE: Update dumpDetectionEntries() outputs


Commit: 5f3e062f97dcd3f31cb8a5c2fb5b96e73ecb4d77
    https://github.com/scummvm/scummvm/commit/5f3e062f97dcd3f31cb8a5c2fb5b96e73ecb4d77
Author: Abhinav Chennubhotla (51199011+PhoenixFlame101 at users.noreply.github.com)
Date: 2023-07-03T13:54:50+03:00

Commit Message:
BASE: Add --dump-all-detection-entries command

 - Creates metaengine instances for all engines, which will
   contain detection md5s of the engine

Changed paths:
    base/commandLine.cpp


diff --git a/base/commandLine.cpp b/base/commandLine.cpp
index 2f284d5322d..81b4e75bcf6 100644
--- a/base/commandLine.cpp
+++ b/base/commandLine.cpp
@@ -76,6 +76,7 @@ static const char HELP_STRING1[] =
 	"  -t, --list-targets       Display list of configured targets and exit\n"
 	"  --list-engines           Display list of supported engines and exit\n"
 	"  --list-all-engines       Display list of all detection engines and exit\n"
+	"  --dump-all-detection-entries Create a DAT file containing MD5s from detection entries of all engines\n"
 	"  --stats                  Display statistics about engines and games and exit\n"
 	"  --list-debugflags=engine Display list of engine specified debugflags\n"
 	"                           if engine=global or engine is not specified, then it will list global debugflags\n"
@@ -620,6 +621,9 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, const cha
 			DO_LONG_COMMAND("list-all-engines")
 			END_COMMAND
 
+			DO_LONG_COMMAND("dump-all-detection-entries")
+			END_COMMAND
+
 			DO_LONG_COMMAND("stats")
 			END_COMMAND
 
@@ -1419,6 +1423,16 @@ static void listAudioDevices() {
 	}
 }
 
+/** Dump MD5s from detection entries into STDOUT */
+/** WIP: Current only creates a metaengine instance for each engine */
+static void dumpAllDetectionEntries() {
+	// We need to create one file for each engine
+	const PluginList &plugins = EngineMan.getPlugins();
+	for (PluginList::const_iterator iter = plugins.begin(); iter != plugins.end(); iter++) {
+		const MetaEngineDetection &metaEngine = (*iter)->get<MetaEngineDetection>();
+	}
+}
+
 /** Display all games in the given directory, or current directory if empty */
 static DetectedGames getGameList(const Common::FSNode &dir) {
 	Common::FSList files;
@@ -1860,6 +1874,9 @@ bool processSettings(Common::String &command, Common::StringMap &settings, Commo
 	} else if (command == "list-all-engines") {
 		listAllEngines();
 		return cmdDoExit;
+	} else if (command == "dump-all-detection-entries") {
+		dumpAllDetectionEntries();
+		return cmdDoExit;
 	} else if (command == "stats") {
 		printStatistics(settings["engine"]);
 		return cmdDoExit;


Commit: bb20579bee4d86e05699107f19882294178deb64
    https://github.com/scummvm/scummvm/commit/bb20579bee4d86e05699107f19882294178deb64
Author: Abhinav Chennubhotla (51199011+PhoenixFlame101 at users.noreply.github.com)
Date: 2023-07-03T13:54:50+03:00

Commit Message:
BASE: Add dumpAllDetectionEntries() to commandLine

 - Add virtual function dumpDetectionEntries() to
   MetaEngine
 - Glk, Sky and SCUMM do not have proper
   definitions for dumpDetectionEntries()
 - Add md5PropToGameFile() to extract prefixes for
   md5s
 - AdvancedDetector writes content of DAT file to
   STDOUT

Changed paths:
    base/commandLine.cpp
    engines/advancedDetector.cpp
    engines/advancedDetector.h
    engines/glk/detection.h
    engines/metaengine.h
    engines/scumm/detection.cpp
    engines/sky/detection.cpp


diff --git a/base/commandLine.cpp b/base/commandLine.cpp
index 81b4e75bcf6..83a51829147 100644
--- a/base/commandLine.cpp
+++ b/base/commandLine.cpp
@@ -1424,12 +1424,11 @@ static void listAudioDevices() {
 }
 
 /** Dump MD5s from detection entries into STDOUT */
-/** WIP: Current only creates a metaengine instance for each engine */
 static void dumpAllDetectionEntries() {
-	// We need to create one file for each engine
 	const PluginList &plugins = EngineMan.getPlugins();
 	for (PluginList::const_iterator iter = plugins.begin(); iter != plugins.end(); iter++) {
 		const MetaEngineDetection &metaEngine = (*iter)->get<MetaEngineDetection>();
+		metaEngine.dumpDetectionEntries();
 	}
 }
 
diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp
index 18a602a71d6..78072188760 100644
--- a/engines/advancedDetector.cpp
+++ b/engines/advancedDetector.cpp
@@ -545,6 +545,32 @@ static MD5Properties gameFileToMD5Props(const ADGameFileDescription *fileEntry,
 	return ret;
 }
 
+const char *md5PropToGameFile(MD5Properties flags) {
+	switch (flags & kMD5MacMask) {
+	case kMD5MacDataFork: {
+		if (flags & kMD5Tail)
+			return "dt";
+		return "d";
+	}
+
+	case kMD5MacResOrDataFork: {
+		if (flags & kMD5Tail)
+			return "mt";
+		return "m";
+	}
+
+	case kMD5MacResFork: {
+		if (flags & kMD5Tail)
+			return "rt";
+		return "r";
+	}
+
+	default: {
+		return "";
+	}
+	}
+}
+
 static bool getFilePropertiesIntern(uint md5Bytes, const AdvancedMetaEngine::FileMap &allFiles, MD5Properties md5prop, const Common::String &fname, FileProperties &fileProps);
 
 bool AdvancedMetaEngineDetection::getFileProperties(const FileMap &allFiles, MD5Properties md5prop, const Common::String &fname, FileProperties &fileProps) const {
@@ -626,6 +652,38 @@ static bool getFilePropertiesIntern(uint md5Bytes, const AdvancedMetaEngine::Fil
 	return true;
 }
 
+void AdvancedMetaEngineDetection::dumpDetectionEntries() const {
+	const byte *descPtr;
+
+	debug("scummvm (");
+	// debug("version %s", commitHash);
+	// debug("date %s", date);
+	debug("\tauthor scummvm");
+	debug(")\n");
+	for (descPtr = _gameDescriptors; ((const ADGameDescription *)descPtr)->gameId != nullptr; descPtr += _descItemSize) {
+		auto g = ((const ADGameDescription *)descPtr);
+		auto gameid = g->gameId;
+
+		debug("game (");
+		debug("\tname %s", gameid);
+		// debug("\tsourcefile %s"); // Not necessary for now
+		// debug("\tromof %s"); // Not sure where i get this from
+		for (auto fileDesc = g->filesDescriptions; fileDesc->fileName; fileDesc++) {
+			Common::String fname = fileDesc->fileName;
+			int64 fsize = fileDesc->fileSize;
+			Common::String md5 = fileDesc->md5;
+			MD5Properties md5prop = gameFileToMD5Props(fileDesc, g->flags);
+			auto md5Prefix = Common::String(md5PropToGameFile(md5prop));
+			Common::String key = fname.c_str();
+			if (md5Prefix != "")
+				key = Common::String::format("%s:%s", md5Prefix.c_str(), fname.c_str());
+
+			debug("\trom ( name %s size %ld md5-%d %s )", fname.c_str(), fsize, _md5Bytes, key.c_str());
+		}
+		debug(")\n");
+	}
+}
+
 ADDetectedGames AdvancedMetaEngineDetection::detectGame(const Common::FSNode &parent, const FileMap &allFiles, Common::Language language, Common::Platform platform, const Common::String &extra, uint32 skipADFlags, bool skipIncomplete) {
 	FilePropertiesMap filesProps;
 	ADDetectedGames matched;
diff --git a/engines/advancedDetector.h b/engines/advancedDetector.h
index b7a4e5f9671..c639f94be15 100644
--- a/engines/advancedDetector.h
+++ b/engines/advancedDetector.h
@@ -403,6 +403,8 @@ public:
 		return count;
 	}
 
+	void dumpDetectionEntries() const override final;
+
 protected:
 	/**
 	 * A hashmap of files and their MD5 checksums.
diff --git a/engines/glk/detection.h b/engines/glk/detection.h
index 025c0b43167..ca637ca0213 100644
--- a/engines/glk/detection.h
+++ b/engines/glk/detection.h
@@ -69,6 +69,8 @@ public:
 	void detectClashes() const;
 
 	uint getMD5Bytes() const override;
+
+	void dumpDetectionEntries() const override final {}
 };
 
 namespace Glk {
diff --git a/engines/metaengine.h b/engines/metaengine.h
index 625f53be55e..ea960f604a8 100644
--- a/engines/metaengine.h
+++ b/engines/metaengine.h
@@ -170,6 +170,9 @@ public:
 		return -1;
 	}
 
+	/** Returns formatted data from game descriptor for dumping into a file */
+	virtual void dumpDetectionEntries() const = 0;
+
 	/**
 	 * The default version of this method will just parse the options string from
 	 * the config manager. However it also allows the meta engine to post process
diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp
index 0ee4ac7fc96..de9f65065a5 100644
--- a/engines/scumm/detection.cpp
+++ b/engines/scumm/detection.cpp
@@ -96,6 +96,8 @@ public:
 	}
 
 	Common::String parseAndCustomizeGuiOptions(const Common::String &optionsString, const Common::String &domain) const override;
+
+	void dumpDetectionEntries() const override final {}
 };
 
 PlainGameList ScummMetaEngineDetection::getSupportedGames() const {
diff --git a/engines/sky/detection.cpp b/engines/sky/detection.cpp
index 021f5df93b9..148c51ef99f 100644
--- a/engines/sky/detection.cpp
+++ b/engines/sky/detection.cpp
@@ -73,6 +73,8 @@ public:
 		return 0;
 	}
 
+	void dumpDetectionEntries() const override final {}
+
 	int getGameVariantCount() const override {
 		int entries = 0;
 		for (const SkyVersion *sv = skyVersions; sv->dinnerTableEntries; ++sv)


Commit: c09ef64b7f59621f61f6e9bf266190bc06e751c9
    https://github.com/scummvm/scummvm/commit/c09ef64b7f59621f61f6e9bf266190bc06e751c9
Author: Abhinav Chennubhotla (51199011+PhoenixFlame101 at users.noreply.github.com)
Date: 2023-07-03T13:54:50+03:00

Commit Message:
BASE: Update dumpDetectionEntries() and md5PropToGameFile()

Changed paths:
    engines/advancedDetector.cpp


diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp
index 78072188760..7bb1bb0004b 100644
--- a/engines/advancedDetector.cpp
+++ b/engines/advancedDetector.cpp
@@ -546,29 +546,28 @@ static MD5Properties gameFileToMD5Props(const ADGameFileDescription *fileEntry,
 }
 
 const char *md5PropToGameFile(MD5Properties flags) {
-	switch (flags & kMD5MacMask) {
+	switch (flags & kMD5MacMask)
 	case kMD5MacDataFork: {
 		if (flags & kMD5Tail)
 			return "dt";
 		return "d";
-	}
 
-	case kMD5MacResOrDataFork: {
+	case kMD5MacResOrDataFork:
 		if (flags & kMD5Tail)
 			return "mt";
 		return "m";
-	}
 
-	case kMD5MacResFork: {
+	case kMD5MacResFork:
 		if (flags & kMD5Tail)
 			return "rt";
 		return "r";
-	}
 
-	default: {
+	case kMD5Tail:
+		return "t";
+
+	default:
 		return "";
 	}
-	}
 }
 
 static bool getFilePropertiesIntern(uint md5Bytes, const AdvancedMetaEngine::FileMap &allFiles, MD5Properties md5prop, const Common::String &fname, FileProperties &fileProps);
@@ -655,30 +654,25 @@ static bool getFilePropertiesIntern(uint md5Bytes, const AdvancedMetaEngine::Fil
 void AdvancedMetaEngineDetection::dumpDetectionEntries() const {
 	const byte *descPtr;
 
-	debug("scummvm (");
-	// debug("version %s", commitHash);
-	// debug("date %s", date);
-	debug("\tauthor scummvm");
-	debug(")\n");
 	for (descPtr = _gameDescriptors; ((const ADGameDescription *)descPtr)->gameId != nullptr; descPtr += _descItemSize) {
 		auto g = ((const ADGameDescription *)descPtr);
 		auto gameid = g->gameId;
+		auto variant = g->extra;
 
 		debug("game (");
-		debug("\tname %s", gameid);
-		// debug("\tsourcefile %s"); // Not necessary for now
-		// debug("\tromof %s"); // Not sure where i get this from
+		debug("\tname %s %s", gameid, variant);
+		debug("\tsourcefile %s", getName());
 		for (auto fileDesc = g->filesDescriptions; fileDesc->fileName; fileDesc++) {
 			Common::String fname = fileDesc->fileName;
 			int64 fsize = fileDesc->fileSize;
 			Common::String md5 = fileDesc->md5;
 			MD5Properties md5prop = gameFileToMD5Props(fileDesc, g->flags);
 			auto md5Prefix = Common::String(md5PropToGameFile(md5prop));
-			Common::String key = fname.c_str();
+			Common::String key = md5.c_str();
 			if (md5Prefix != "")
 				key = Common::String::format("%s:%s", md5Prefix.c_str(), fname.c_str());
 
-			debug("\trom ( name %s size %ld md5-%d %s )", fname.c_str(), fsize, _md5Bytes, key.c_str());
+			debug("\trom ( name \"%s\" size %ld md5-%d %s )", fname.c_str(), fsize, _md5Bytes, key.c_str());
 		}
 		debug(")\n");
 	}


Commit: 41d985527300abde1ef705bda3078864e4e80e6b
    https://github.com/scummvm/scummvm/commit/41d985527300abde1ef705bda3078864e4e80e6b
Author: Abhinav Chennubhotla (51199011+PhoenixFlame101 at users.noreply.github.com)
Date: 2023-07-03T13:54:50+03:00

Commit Message:
BASE: Add metadata to dumped detection entries

 - Add title, extra, platform and language to
   differentiate b/w different variants of a game
 - Create escapeString() func to add backslashes
   to strings containing certain special chars

Changed paths:
    engines/advancedDetector.cpp


diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp
index 7bb1bb0004b..be1efe95dcf 100644
--- a/engines/advancedDetector.cpp
+++ b/engines/advancedDetector.cpp
@@ -651,17 +651,38 @@ static bool getFilePropertiesIntern(uint md5Bytes, const AdvancedMetaEngine::Fil
 	return true;
 }
 
+// Add backslash before double quotes (") and backslashes themselves (\)
+Common::String escapeString(const char *string) {
+	if (string == nullptr || Common::String(string) == "")
+		return "NULL";
+
+	Common::String res = "";
+
+	for (int i = 0; string[i] != '\0'; i++) {
+		if (string[i] == '"' || string[i] == '\\')
+			res += "\\";
+
+		res += string[i];
+	}
+
+	return res;
+}
+
 void AdvancedMetaEngineDetection::dumpDetectionEntries() const {
 	const byte *descPtr;
 
 	for (descPtr = _gameDescriptors; ((const ADGameDescription *)descPtr)->gameId != nullptr; descPtr += _descItemSize) {
 		auto g = ((const ADGameDescription *)descPtr);
-		auto gameid = g->gameId;
-		auto variant = g->extra;
+		const char *title = ((const PlainGameDescriptor *)_gameIds)->description;
 
 		debug("game (");
-		debug("\tname %s %s", gameid, variant);
-		debug("\tsourcefile %s", getName());
+		debug("\tname %s", escapeString(g->gameId).c_str());
+		debug("\ttitle %s", escapeString(title).c_str());
+		debug("\textra %s", escapeString(g->extra).c_str());
+		debug("\tlanguage %s", escapeString(getLanguageLocale(g->language)).c_str());
+		debug("\tplatform %s", escapeString(getPlatformCode(g->platform)).c_str());
+		debug("\tsourcefile %s", escapeString(getName()).c_str());
+
 		for (auto fileDesc = g->filesDescriptions; fileDesc->fileName; fileDesc++) {
 			Common::String fname = fileDesc->fileName;
 			int64 fsize = fileDesc->fileSize;
@@ -669,12 +690,12 @@ void AdvancedMetaEngineDetection::dumpDetectionEntries() const {
 			MD5Properties md5prop = gameFileToMD5Props(fileDesc, g->flags);
 			auto md5Prefix = Common::String(md5PropToGameFile(md5prop));
 			Common::String key = md5.c_str();
-			if (md5Prefix != "")
-				key = Common::String::format("%s:%s", md5Prefix.c_str(), fname.c_str());
+			if (md5Prefix != "" && md5.find(':') == Common::String::npos)
+				key = Common::String::format("%s:%s", md5Prefix.c_str(), md5.c_str());
 
-			debug("\trom ( name \"%s\" size %ld md5-%d %s )", fname.c_str(), fsize, _md5Bytes, key.c_str());
+			debug("\trom ( name \"%s\" size %ld md5-%d %s )", escapeString(fname.c_str()).c_str(), fsize, _md5Bytes, key.c_str());
 		}
-		debug(")\n");
+		debug(")\n"); // Closing for 'game ('
 	}
 }
 


Commit: 967c8eaf5ea69b70dba9f25f66ef3646398e5a52
    https://github.com/scummvm/scummvm/commit/967c8eaf5ea69b70dba9f25f66ef3646398e5a52
Author: Abhinav Chennubhotla (51199011+PhoenixFlame101 at users.noreply.github.com)
Date: 2023-07-03T13:54:50+03:00

Commit Message:
BASE: Update dumpDetectionEntries() outputs

 - Use printf() instead of debug()
 - Remove unnecessary type conversions

Changed paths:
    engines/advancedDetector.cpp


diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp
index be1efe95dcf..a696b56d31f 100644
--- a/engines/advancedDetector.cpp
+++ b/engines/advancedDetector.cpp
@@ -19,6 +19,8 @@
  *
  */
 
+#define FORBIDDEN_SYMBOL_EXCEPTION_printf
+
 #include "common/debug.h"
 #include "common/util.h"
 #include "common/file.h"
@@ -675,27 +677,27 @@ void AdvancedMetaEngineDetection::dumpDetectionEntries() const {
 		auto g = ((const ADGameDescription *)descPtr);
 		const char *title = ((const PlainGameDescriptor *)_gameIds)->description;
 
-		debug("game (");
-		debug("\tname %s", escapeString(g->gameId).c_str());
-		debug("\ttitle %s", escapeString(title).c_str());
-		debug("\textra %s", escapeString(g->extra).c_str());
-		debug("\tlanguage %s", escapeString(getLanguageLocale(g->language)).c_str());
-		debug("\tplatform %s", escapeString(getPlatformCode(g->platform)).c_str());
-		debug("\tsourcefile %s", escapeString(getName()).c_str());
+		printf("game (\n");
+		printf("\tname %s\n", escapeString(g->gameId).c_str());
+		printf("\ttitle %s\n", escapeString(title).c_str());
+		printf("\textra %s\n", escapeString(g->extra).c_str());
+		printf("\tlanguage %s\n", escapeString(getLanguageLocale(g->language)).c_str());
+		printf("\tplatform %s\n", escapeString(getPlatformCode(g->platform)).c_str());
+		printf("\tsourcefile %s\n", escapeString(getName()).c_str());
 
 		for (auto fileDesc = g->filesDescriptions; fileDesc->fileName; fileDesc++) {
-			Common::String fname = fileDesc->fileName;
+			const char *fname = fileDesc->fileName;
 			int64 fsize = fileDesc->fileSize;
 			Common::String md5 = fileDesc->md5;
 			MD5Properties md5prop = gameFileToMD5Props(fileDesc, g->flags);
-			auto md5Prefix = Common::String(md5PropToGameFile(md5prop));
-			Common::String key = md5.c_str();
+			Common::String md5Prefix = md5PropToGameFile(md5prop);
+			Common::String key = md5;
 			if (md5Prefix != "" && md5.find(':') == Common::String::npos)
-				key = Common::String::format("%s:%s", md5Prefix.c_str(), md5.c_str());
+				key = md5Prefix + md5;
 
-			debug("\trom ( name \"%s\" size %ld md5-%d %s )", escapeString(fname.c_str()).c_str(), fsize, _md5Bytes, key.c_str());
+			printf("\trom ( name \"%s\" size %ld md5-%d %s )\n", escapeString(fname).c_str(), fsize, _md5Bytes, key.c_str());
 		}
-		debug(")\n"); // Closing for 'game ('
+		printf(")\n\n"); // Closing for 'game ('
 	}
 }
 




More information about the Scummvm-git-logs mailing list