[Scummvm-cvs-logs] SF.net SVN: scummvm: [29293] scummvm/trunk/common

sev at users.sourceforge.net sev at users.sourceforge.net
Sun Oct 28 17:29:31 CET 2007


Revision: 29293
          http://scummvm.svn.sourceforge.net/scummvm/?rev=29293&view=rev
Author:   sev
Date:     2007-10-28 09:29:31 -0700 (Sun, 28 Oct 2007)

Log Message:
-----------
Patch #1814831: "Unify the way to report unknown versions of games"

Modified Paths:
--------------
    scummvm/trunk/common/advancedDetector.cpp
    scummvm/trunk/common/advancedDetector.h

Modified: scummvm/trunk/common/advancedDetector.cpp
===================================================================
--- scummvm/trunk/common/advancedDetector.cpp	2007-10-28 16:10:05 UTC (rev 29292)
+++ scummvm/trunk/common/advancedDetector.cpp	2007-10-28 16:29:31 UTC (rev 29293)
@@ -301,6 +301,45 @@
 	return kNoGameDataFoundError;
 }
 
+void reportUnknown(StringMap &filesMD5, HashMap<String, int32, Common::CaseSensitiveString_Hash, Common::CaseSensitiveString_EqualTo> &filesSize) {
+	// TODO: This message should be cleaned up / made more specific.
+	// For example, we should specify at least which engine triggered this.
+	//
+	// Might also be helpful to display the full path (for when this is used
+	// from the mass detector).
+	printf("Your game version appears to be unknown. Please, report the following\n");
+	printf("data to the ScummVM team along with name of the game you tried to add\n");
+	printf("and its version/language/etc.:\n");
+
+	for (StringMap::const_iterator file = filesMD5.begin(); file != filesMD5.end(); ++file)
+		printf("  \"%s\", \"%s\", %d\n", file->_key.c_str(), file->_value.c_str(), filesSize[file->_key]);
+
+	printf("\n");
+}
+
+void reportUnknown(StringList &files, int md5Bytes) {
+	StringMap filesMD5;
+	HashMap<String, int32, Common::CaseSensitiveString_Hash, Common::CaseSensitiveString_EqualTo> filesSize;
+
+	char md5str[32+1];
+	File testFile;
+
+	// Fill the data structures for the requested files
+	for (StringList::iterator file = files.begin(); file != files.end(); file++) {
+
+		if (testFile.open(*file)) {
+			filesSize[*file] = (int32)testFile.size();
+
+			if (md5_file_string(testFile, md5str, md5Bytes))
+				filesMD5[*file] = md5str;
+
+			testFile.close();
+		}
+	}
+
+	reportUnknown(filesMD5, filesSize);
+}
+
 static ADGameDescList detectGame(const FSList *fslist, const Common::ADParams &params, Language language, Platform platform) {
 	typedef HashMap<String, bool, CaseSensitiveString_Hash, CaseSensitiveString_EqualTo> StringSet;
 	StringSet filesList;
@@ -460,22 +499,9 @@
 	if (!matched.empty())
 		return matched;
 
-	if (!filesMD5.empty()) {
-		// TODO: This message should be cleaned up / made more specific.
-		// For example, we should specify at least which engine triggered this.
-		//
-		// Might also be helpful to display the full path (for when this is used
-		// from the mass detector).
-		printf("Your game version appears to be unknown. Please, report the following\n");
-		printf("data to the ScummVM team along with name of the game you tried to add\n");
-		printf("and its version/language/etc.:\n");
+	if (!filesMD5.empty())
+		reportUnknown(filesMD5, filesSize);
 
-		for (StringMap::const_iterator file = filesMD5.begin(); file != filesMD5.end(); ++file)
-			printf("  \"%s\", \"%s\", %d\n", file->_key.c_str(), file->_value.c_str(), filesSize[file->_key]);
-
-		printf("\n");
-	}
-
 	// Filename based fallback
 	if (params.fileBasedFallback != 0) {
 		const ADFileBasedFallback *ptr = params.fileBasedFallback;

Modified: scummvm/trunk/common/advancedDetector.h
===================================================================
--- scummvm/trunk/common/advancedDetector.h	2007-10-28 16:10:05 UTC (rev 29292)
+++ scummvm/trunk/common/advancedDetector.h	2007-10-28 16:29:31 UTC (rev 29293)
@@ -240,6 +240,9 @@
 // Only used by ADVANCED_DETECTOR_DEFINE_PLUGIN_WITH_FUNC
 PluginError detectGameForEngineCreation(const Common::ADParams &params);
 
+// Helper function to announce an unknown version of the game (useful for
+// fallback detection functions).
+void reportUnknown(StringList &files, int md5Bytes);
 
 // FIXME: It would probably be good to merge detectBestMatchingGame
 // and detectGameForEngineCreation into a single function. Right now, the


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list