[Scummvm-cvs-logs] SF.net SVN: scummvm:[54118] scummvm/trunk/engines

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sun Nov 7 18:15:29 CET 2010


Revision: 54118
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54118&view=rev
Author:   fingolfin
Date:     2010-11-07 17:15:27 +0000 (Sun, 07 Nov 2010)

Log Message:
-----------
DETECTOR: Get rid of ADGF_KEEPMATCH

Also fix some typos, and minor tweaks

Modified Paths:
--------------
    scummvm/trunk/engines/advancedDetector.cpp
    scummvm/trunk/engines/advancedDetector.h
    scummvm/trunk/engines/drascula/detection.cpp
    scummvm/trunk/engines/tinsel/detection.cpp

Modified: scummvm/trunk/engines/advancedDetector.cpp
===================================================================
--- scummvm/trunk/engines/advancedDetector.cpp	2010-11-07 15:04:47 UTC (rev 54117)
+++ scummvm/trunk/engines/advancedDetector.cpp	2010-11-07 17:15:27 UTC (rev 54118)
@@ -244,18 +244,21 @@
 	if (cleanupPirated(matches))
 		return detectedGames;
 
-	// Use fallback detector if there were no matches by other means
 	if (matches.empty()) {
+		// Use fallback detector if there were no matches by other means
 		const ADGameDescription *fallbackDesc = fallbackDetect(fslist);
 		if (fallbackDesc != 0) {
 			GameDescriptor desc(toGameDescriptor(*fallbackDesc, params.list));
 			updateGameDescriptor(desc, fallbackDesc, params);
 			detectedGames.push_back(desc);
 		}
-	} else for (uint i = 0; i < matches.size(); i++) { // Otherwise use the found matches
-		GameDescriptor desc(toGameDescriptor(*matches[i], params.list));
-		updateGameDescriptor(desc, matches[i], params);
-		detectedGames.push_back(desc);
+	} else {
+		// Otherwise use the found matches
+		for (uint i = 0; i < matches.size(); i++) {
+			GameDescriptor desc(toGameDescriptor(*matches[i], params.list));
+			updateGameDescriptor(desc, matches[i], params);
+			detectedGames.push_back(desc);
+		}
 	}
 
 	return detectedGames;
@@ -502,6 +505,7 @@
 			continue;
 
 		bool allFilesPresent = true;
+		int curFilesMatched = 0;
 
 		// Try to match all files for this game
 		for (fileDesc = g->filesDescriptions; fileDesc->fileName; fileDesc++) {
@@ -526,12 +530,13 @@
 			}
 
 			debug(3, "Matched file: %s", tstr.c_str());
+			curFilesMatched++;
 		}
 
 		// We found at least one entry with all required files present.
 		// That means that we got new variant of the game.
 		//
-		// Wihtout this check we would have errorneous checksum display
+		// Without this check we would have erroneous checksum display
 		// where only located files will be enlisted.
 		//
 		// Potentially this could rule out variants where some particular file
@@ -544,22 +549,11 @@
 			debug(2, "Found game: %s (%s %s/%s) (%d)", g->gameid, g->extra,
 			 getPlatformDescription(g->platform), getLanguageDescription(g->language), i);
 
-			// Count the number of matching files. Then, only keep those
-			// entries which match a maximal amount of files.
-			int curFilesMatched = 0;
-			for (fileDesc = g->filesDescriptions; fileDesc->fileName; fileDesc++)
-				curFilesMatched++;
-
 			if (curFilesMatched > maxFilesMatched) {
 				debug(2, " ... new best match, removing all previous candidates");
 				maxFilesMatched = curFilesMatched;
 
-				for (uint j = 0; j < matched.size();) {
-					if (matched[j]->flags & ADGF_KEEPMATCH)
-						 ++j;
-					else
-						matched.remove_at(j);
-				}
+				matched.clear();	// Remove any prior, lower ranked matches.
 				matched.push_back(g);
 			} else if (curFilesMatched == maxFilesMatched) {
 				matched.push_back(g);

Modified: scummvm/trunk/engines/advancedDetector.h
===================================================================
--- scummvm/trunk/engines/advancedDetector.h	2010-11-07 15:04:47 UTC (rev 54117)
+++ scummvm/trunk/engines/advancedDetector.h	2010-11-07 17:15:27 UTC (rev 54118)
@@ -49,7 +49,6 @@
 	ADGF_ADDENGLISH = (1 << 24), // always add English as language option
 	ADGF_MACRESFORK = (1 << 25), // the md5 for this entry will be calculated from the resource fork
 	ADGF_USEEXTRAASTITLE = (1 << 26), // Extra field value will be used as main game title, not gameid
-	ADGF_KEEPMATCH = (1 << 27), // this entry is kept even when there are matched entries with more files
 	ADGF_DROPLANGUAGE = (1 << 28), // don't add language to gameid
 	ADGF_CD = (1 << 29),    	// add "-cd" to gameid
 	ADGF_DEMO = (1 << 30)   	// add "-demo" to gameid

Modified: scummvm/trunk/engines/drascula/detection.cpp
===================================================================
--- scummvm/trunk/engines/drascula/detection.cpp	2010-11-07 15:04:47 UTC (rev 54117)
+++ scummvm/trunk/engines/drascula/detection.cpp	2010-11-07 17:15:27 UTC (rev 54118)
@@ -88,10 +88,17 @@
 		{
 			"drascula",
 			0,
-			AD_ENTRY1s("packet.001", "c6a8697396e213a18472542d5f547cb4", 32847563),
+			{
+				{"packet.001", 0, "c6a8697396e213a18472542d5f547cb4", 32847563},
+				// HACK: List packet.001 twice to ensure this detector entry
+				// is ranked just as high as the others (which each have two
+				// detection files).
+				{"packet.001", 0, "c6a8697396e213a18472542d5f547cb4", 32847563},
+				{NULL, 0, NULL, 0}
+			},
 			Common::EN_ANY,
 			Common::kPlatformPC,
-			ADGF_KEEPMATCH | GF_PACKED,
+			GF_PACKED,
 			GUIO_NONE
 		},
 	},

Modified: scummvm/trunk/engines/tinsel/detection.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/detection.cpp	2010-11-07 15:04:47 UTC (rev 54117)
+++ scummvm/trunk/engines/tinsel/detection.cpp	2010-11-07 17:15:27 UTC (rev 54118)
@@ -212,8 +212,13 @@
 	if (fslist.empty())
 		return NULL;
 
+	// TODO: The following code is essentially a slightly modified copy of the
+	// complete code of function detectGame() in engines/advancedDetector.cpp.
+	// That quite some hefty and undesirable code duplication. Its only purpose
+	// seems to be to treat filenames of the form "foo1.ext" as "foo.ext".
+	// It would be nice to avoid this code duplication.
+
 	// First we compose a hashmap of all files in fslist.
-	// Includes nifty stuff like removing trailing dots and ignoring case.
 	for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
 		if (file->isDirectory()) {
 			if (!scumm_stricmp(file->getName().c_str(), "dw2")) {
@@ -337,12 +342,7 @@
 			if (curFilesMatched > maxFilesMatched) {
 				maxFilesMatched = curFilesMatched;
 
-				for (uint j = 0; j < matched.size();) {
-					if (matched[j]->flags & ADGF_KEEPMATCH)
-						 ++j;
-					else
-						matched.remove_at(j);
-				}
+				matched.clear();	// Remove any prior, lower ranked matches.
 				matched.push_back((const ADGameDescription *)g);
 			} else if (curFilesMatched == maxFilesMatched) {
 				matched.push_back((const ADGameDescription *)g);


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