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

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Thu Feb 15 00:46:40 CET 2007


Revision: 25599
          http://scummvm.svn.sourceforge.net/scummvm/?rev=25599&view=rev
Author:   fingolfin
Date:     2007-02-14 15:46:39 -0800 (Wed, 14 Feb 2007)

Log Message:
-----------
AdvancedDetector: revamped the file based fallback code

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

Modified: scummvm/trunk/common/advancedDetector.cpp
===================================================================
--- scummvm/trunk/common/advancedDetector.cpp	2007-02-14 23:29:13 UTC (rev 25598)
+++ scummvm/trunk/common/advancedDetector.cpp	2007-02-14 23:46:39 UTC (rev 25599)
@@ -341,11 +341,6 @@
 			continue;
 		}
 
-		if (g->filesDescriptions[0].fileName == 0) {
-			debug(5, "Skipping dummy entry: %s", g->gameid);
-			continue;
-		}
-
 		// Try to open all files for this game
 		for (fileDesc = g->filesDescriptions; fileDesc->fileName; fileDesc++) {
 			tstr = fileDesc->fileName;
@@ -423,18 +418,17 @@
 		// to be present in order to generate a match; the row is terminated
 		// by a zero byte.
 		// The whole list is terminated by another zero byte (i.e. a zero gameid).
-		const char **ptr = params.fileBasedFallback;
+		const ADFileBasedFallback *ptr = params.fileBasedFallback;
+		const char* const* filenames = 0;
 
 		// First we create list of files required for detection.
 		if (allFiles.empty()) {
 			File testFile;
 
-			for (; *ptr; ptr++) {
-				// skip the gameid
-				ptr++;
-
-				for (; *ptr; ptr++) {
-					tstr = String(*ptr);
+			for (; ptr->desc; ptr++) {
+				filenames = ptr->filenames;
+				for (; *filenames; filenames++) {
+					tstr = String(*filenames);
 					tstr.toLowercase();
 
 					if (!allFiles.contains(tstr)) {
@@ -449,26 +443,27 @@
 		}
 
 		int maxNumMatchedFiles = 0;
-		const char *matchedGameid = 0;
+		const ADGameDescription *matchedDesc = 0;
 
 		ptr = params.fileBasedFallback;
 
-		for (; *ptr; ptr++) {
-			const char *entryGameid = *ptr++;
-			fileMissing = false;
+		for (; ptr->desc; ptr++) {
+			const ADGameDescription *agdesc = (const ADGameDescription *)ptr->desc;
 			int numMatchedFiles = 0;
+			fileMissing = false;
 
-			for (; *ptr; ptr++) {
+			filenames = ptr->filenames;
+			for (; *filenames; filenames++) {
 				if (fileMissing) {
 					continue;
 				}
 
-				tstr = String(*ptr);
+				tstr = String(*filenames);
 
 				tstr.toLowercase();
 				tstr2 = tstr + ".";
 
-				debug(3, "++ %s", *ptr);
+				debug(3, "++ %s", *filenames);
 				if (!allFiles.contains(tstr) && !allFiles.contains(tstr2)) {
 					fileMissing = true;
 					continue;
@@ -478,29 +473,22 @@
 			}
 
 			if (!fileMissing)
-				debug(4, "Matched: %s", entryGameid);
+				debug(4, "Matched: %s", agdesc->gameid);
 
 			if (!fileMissing && numMatchedFiles > maxNumMatchedFiles) {
-				matchedGameid = entryGameid;
+				matchedDesc = agdesc;
 				maxNumMatchedFiles = numMatchedFiles;
 
 				debug(4, "and overriden");
 			}
 		}
 
-		if (matchedGameid) { // We got a match
-			for (descPtr = params.descs; ((const ADGameDescription *)descPtr)->gameid != 0; descPtr += params.descItemSize) {
-				g = (const ADGameDescription *)descPtr;
-				if (g->filesDescriptions[0].fileName == 0) {
-					if (!scumm_stricmp(g->gameid, matchedGameid)) {
-						// FIXME: This warning, if ever seen by somebody, is
-						// extremly cryptic!
-						warning("But it looks like unknown variant of %s", matchedGameid);
+		if (matchedDesc) { // We got a match
+			// FIXME: This warning, if ever seen by somebody, is
+			// extremly cryptic!
+			warning("But it looks like unknown variant of %s", matchedDesc->gameid);
 
-						matched.push_back(g);
-					}
-				}
-			}
+			matched.push_back(matchedDesc);
 		}
 	}
 

Modified: scummvm/trunk/common/advancedDetector.h
===================================================================
--- scummvm/trunk/common/advancedDetector.h	2007-02-14 23:29:13 UTC (rev 25598)
+++ scummvm/trunk/common/advancedDetector.h	2007-02-14 23:46:39 UTC (rev 25599)
@@ -79,6 +79,21 @@
 	Common::Platform platform;
 };
 
+struct ADFileBasedFallback {
+	/**
+	 * Pointer to an ADGameDescription or subclass thereof.
+	 */
+	const void *desc;
+	
+	/**
+	 * A zero-terminated list of filenames.
+	 *
+	 * @todo Properly explain this
+	 */
+	const char *filenames[10];
+};
+
+
 enum ADFlags {
 	/**
 	 * Generate/augment preferred target with information on the language (if
@@ -142,10 +157,11 @@
 	 * List of files for file-based fallback detection (optional).
 	 * This is used if the regular MD5 based detection failed to 
 	 * detect anything.
+	 * As usual this list is terminated by an all-zero entry.
 	 *
 	 * @todo Properly explain this
 	 */
-	const char **fileBasedFallback;
+	const ADFileBasedFallback *fileBasedFallback;
 	
 	/** 
 	 * A callback pointing to an (optional) generic fallback detect

Modified: scummvm/trunk/engines/gob/detection.cpp
===================================================================
--- scummvm/trunk/engines/gob/detection.cpp	2007-02-14 23:29:13 UTC (rev 25598)
+++ scummvm/trunk/engines/gob/detection.cpp	2007-02-14 23:46:39 UTC (rev 25599)
@@ -64,18 +64,6 @@
 namespace Gob {
 
 static const GOBGameDescription gameDescriptions[] = {
-	{ // Dummy entry for fallback detection
-		{
-			"gob1",
-			"unknown",
-			AD_ENTRY1(0, 0),
-			UNK_LANG,
-			kPlatformPC,
-			Common::ADGF_NO_FLAGS
-		},
-		GF_GOB1,
-		"intro"
-	},
 	{ // Supplied by Florian Zeitz on scummvm-devel
 		{
 			"gob1",
@@ -112,18 +100,6 @@
 		GF_GOB1,
 		"intro"
 	},
-	{ // Dummy entry for fallback detection
-		{
-			"gob1cd",
-			"unknown",
-			AD_ENTRY1(0, 0),
-			UNK_LANG,
-			kPlatformPC,
-			Common::ADGF_NO_FLAGS
-		},
-		GF_GOB1 | GF_CD,
-		"intro"
-	},
 	{ // CD 1.000 version.
 		{
 			"gob1cd",
@@ -328,18 +304,6 @@
 		GF_GOB1,
 		"intro"
 	},
-	{ // Dummy entry for fallback detection
-		{
-			"gob2",
-			"unknown",
-			AD_ENTRY1(0, 0),
-			UNK_LANG,
-			kPlatformPC,
-			Common::ADGF_NO_FLAGS
-		},
-		GF_GOB2,
-		"intro"
-	},
 	{
 		{
 			"gob2",
@@ -440,18 +404,6 @@
 		GF_GOB2,
 		"intro"
 	},
-	{ // Dummy entry for fallback detection
-		{
-			"gob2cd",
-			"unknown",
-			AD_ENTRY1(0, 0),
-			UNK_LANG,
-			kPlatformPC,
-			Common::ADGF_NO_FLAGS
-		},
-		GF_GOB2 | GF_CD,
-		"intro"
-	},
 	{
 		{
 			"gob2cd",
@@ -887,15 +839,66 @@
 	{ AD_TABLE_END_MARKER, 0, NULL }
 };
 
-static const char *fileBased[] = {
-	"gob1",   "intro.stk", "disk1.stk", "disk2.stk", "disk3.stk", "disk4.stk", 0,
-	"gob1cd", "intro.stk", "gob.lic", 0,
-	"gob2",   "intro.stk", 0,
-	"gob2",   "intro.stk", "disk2.stk", "disk3.stk", 0,
-	"gob2cd", "intro.stk", "gobnew.lic", 0,
-	0
+static const GOBGameDescription fallbackDescs[] = {
+	{
+		{
+			"gob1",
+			"unknown",
+			AD_ENTRY1(0, 0),
+			UNK_LANG,
+			kPlatformPC,
+			Common::ADGF_NO_FLAGS
+		},
+		GF_GOB1,
+		"intro"
+	},
+	{
+		{
+			"gob1cd",
+			"unknown",
+			AD_ENTRY1(0, 0),
+			UNK_LANG,
+			kPlatformPC,
+			Common::ADGF_NO_FLAGS
+		},
+		GF_GOB1 | GF_CD,
+		"intro"
+	},
+	{
+		{
+			"gob2",
+			"unknown",
+			AD_ENTRY1(0, 0),
+			UNK_LANG,
+			kPlatformPC,
+			Common::ADGF_NO_FLAGS
+		},
+		GF_GOB2,
+		"intro"
+	},
+	{
+		{
+			"gob2cd",
+			"unknown",
+			AD_ENTRY1(0, 0),
+			UNK_LANG,
+			kPlatformPC,
+			Common::ADGF_NO_FLAGS
+		},
+		GF_GOB2 | GF_CD,
+		"intro"
+	},
 };
 
+static const ADFileBasedFallback fileBased[] = {
+	{ &fallbackDescs[0], { "intro.stk", "disk1.stk", "disk2.stk", "disk3.stk", "disk4.stk", 0 } },
+	{ &fallbackDescs[1], { "intro.stk", "gob.lic", 0 } },
+	{ &fallbackDescs[2], { "intro.stk", 0 } },
+	{ &fallbackDescs[2], { "intro.stk", "disk2.stk", "disk3.stk", 0 } },
+	{ &fallbackDescs[3], { "intro.stk", "gobnew.lic", 0 } },
+	{ 0, { 0 } }
+};
+
 }
 
 static const ADParams detectionParams = {


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