[Scummvm-cvs-logs] SF.net SVN: scummvm: [25575] scummvm/trunk/common/advancedDetector.cpp

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Wed Feb 14 00:47:42 CET 2007


Revision: 25575
          http://scummvm.svn.sourceforge.net/scummvm/?rev=25575&view=rev
Author:   fingolfin
Date:     2007-02-13 15:47:41 -0800 (Tue, 13 Feb 2007)

Log Message:
-----------
Since detectBestMatchingGame now returns a ADGameDescription pointer, we can change detectGame to return a ADGameDescList

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

Modified: scummvm/trunk/common/advancedDetector.cpp
===================================================================
--- scummvm/trunk/common/advancedDetector.cpp	2007-02-13 23:37:44 UTC (rev 25574)
+++ scummvm/trunk/common/advancedDetector.cpp	2007-02-13 23:47:41 UTC (rev 25575)
@@ -33,7 +33,6 @@
 
 namespace Common {
 
-typedef Array<int> ADList;
 typedef Array<const ADGameDescription*> ADGameDescList;
 
 namespace AdvancedDetector {
@@ -48,9 +47,9 @@
  * @param params	a ADParams struct containing various parameters
  * @param language	restrict results to specified language only
  * @param platform	restrict results to specified platform only
- * @return	list of indexes to GameDescriptions of matched games
+ * @return	list of ADGameDescription (or subclass) pointers corresponding to matched games
  */
-static ADList detectGame(const FSList *fslist, const Common::ADParams &params, Language language, Platform platform);
+static ADGameDescList detectGame(const FSList *fslist, const Common::ADParams &params, Language language, Platform platform);
 
 
 GameList gameIDList(const Common::ADParams &params) {
@@ -163,12 +162,11 @@
 	const FSList &fslist,
 	const Common::ADParams &params
 	) {
-	Common::ADList matches = detectGame(&fslist, params, Common::UNK_LANG, Common::kPlatformUnknown);
+	ADGameDescList matches = detectGame(&fslist, params, Common::UNK_LANG, Common::kPlatformUnknown);
 
 	GameList detectedGames;
 	for (uint i = 0; i < matches.size(); i++) {
-		const ADGameDescription *adgDesc = (const ADGameDescription *)(params.descs + matches[i] * params.descItemSize);
-		GameDescriptor desc(toGameDescriptor(*adgDesc, params.list));
+		GameDescriptor desc(toGameDescriptor(*matches[i], params.list));
 
 		if (params.singleid != NULL) {
 			desc["preferredtarget"] = desc["gameid"];
@@ -179,7 +177,7 @@
 			if (!desc.contains("preferredtarget"))
 				desc["preferredtarget"] = desc["gameid"];
 
-			desc["preferredtarget"] = generatePreferredTarget(desc["preferredtarget"], adgDesc);
+			desc["preferredtarget"] = generatePreferredTarget(desc["preferredtarget"], matches[i]);
 		}
 
 		detectedGames.push_back(desc);
@@ -202,18 +200,17 @@
 
 	Common::String gameid = ConfMan.get("gameid");
 
-	Common::ADList matches = detectGame(0, params, language, platform);
+	ADGameDescList matches = detectGame(0, params, language, platform);
 
 	if (params.singleid == NULL) {
 		for (uint i = 0; i < matches.size(); i++) {
-			agdDesc = (const ADGameDescription *)(params.descs + matches[i] * params.descItemSize);
-			if (agdDesc->gameid == gameid) {
+			if (matches[i]->gameid == gameid) {
+				agdDesc = matches[i];
 				break;
 			}
-			agdDesc = 0;
 		}
 	} else if (matches.size() > 0) {
-		agdDesc = (const ADGameDescription *)(params.descs + matches[0] * params.descItemSize);
+		agdDesc = matches[0];
 	}
 
 	if (agdDesc != 0) {
@@ -234,15 +231,14 @@
 		return kInvalidPathError;
 	}
 
-	Common::ADList matches = detectGame(&fslist, params, Common::UNK_LANG, Common::kPlatformUnknown);
+	ADGameDescList matches = detectGame(&fslist, params, Common::UNK_LANG, Common::kPlatformUnknown);
 
 	// We have single ID set, so we have a game if there are hits
 	if (params.singleid != NULL && matches.size())
 		return kNoError;
 
 	for (uint i = 0; i < matches.size(); i++) {
-		const ADGameDescription *adgDesc = (const ADGameDescription *)(params.descs + matches[i] * params.descItemSize);
-		if (adgDesc->gameid == gameid) {
+		if (matches[i]->gameid == gameid) {
 			return kNoError;
 		}
 	}
@@ -250,7 +246,7 @@
 	return kNoGameDataFoundError;
 }
 
-static ADList detectGame(const FSList *fslist, const Common::ADParams &params, Language language, Platform platform) {
+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;
 
@@ -346,7 +342,7 @@
 		}
 	}
 
-	ADList matched;
+	ADGameDescList matched;
 	int maxFilesMatched = 0;
 
 	for (i = 0; i < gameDescriptions.size(); i++) {
@@ -408,9 +404,9 @@
 				debug(2, " ... new best match, removing all previous candidates");
 				maxFilesMatched = curFilesMatched;
 				matched.clear();
-				matched.push_back(i);
+				matched.push_back(g);
 			} else if (curFilesMatched == maxFilesMatched) {
-				matched.push_back(i);
+				matched.push_back(g);
 			} else {
 				debug(2, " ... skipped");
 			}
@@ -521,7 +517,7 @@
 						// extremly cryptic!
 						warning("But it looks like unknown variant of %s", *matchEntry);
 
-						matched.push_back(i);
+						matched.push_back(gameDescriptions[i]);
 					}
 				}
 			}


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