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

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Wed Dec 20 00:37:18 CET 2006


Revision: 24895
          http://scummvm.svn.sourceforge.net/scummvm/?rev=24895&view=rev
Author:   fingolfin
Date:     2006-12-19 15:37:03 -0800 (Tue, 19 Dec 2006)

Log Message:
-----------
Further AdvancedDetector cleanup (in particular, renamed ADGameDescription::name to the more suitable ADGameDescription::gameid)

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

Modified: scummvm/trunk/common/advancedDetector.cpp
===================================================================
--- scummvm/trunk/common/advancedDetector.cpp	2006-12-19 23:14:15 UTC (rev 24894)
+++ scummvm/trunk/common/advancedDetector.cpp	2006-12-19 23:37:03 UTC (rev 24895)
@@ -104,12 +104,12 @@
 	const char *title = 0;
 
 	while (sg->gameid) {
-		if (!scumm_stricmp(g.name, sg->gameid))
+		if (!scumm_stricmp(g.gameid, sg->gameid))
 			title = sg->description;
 		sg++;
 	}
 
-	DetectedGame dg(g.name, title, g.language, g.platform);
+	DetectedGame dg(g.gameid, title, g.language, g.platform);
 	dg.updateDesc(g.extra);
 	return dg;
 }
@@ -132,7 +132,7 @@
 
 	ad.registerGameDescriptions(descList);
 
-	debug(3, "%s: cnt: %d", ((const ADGameDescription *)descs)->name,  descList.size());
+	debug(3, "%s: cnt: %d", ((const ADGameDescription *)descs)->gameid,  descList.size());
 
 	matches = ad.detectGame(&fslist, md5Bytes, Common::UNK_LANG, Common::kPlatformUnknown);
 
@@ -190,11 +190,10 @@
 }
 
 
-String AdvancedDetector::getDescription(int num) const {
+static String getDescription(const ADGameDescription *g) {
 	char tmp[256];
-	const ADGameDescription *g = _gameDescriptions[num];
 
-	snprintf(tmp, 256, "%s (%s %s/%s)", g->name, g->extra,
+	snprintf(tmp, 256, "%s (%s %s/%s)", g->gameid, g->extra,
 			 getPlatformDescription(g->platform), getLanguageDescription(g->language));
 
 	return String(tmp);
@@ -274,18 +273,19 @@
 	int maxFilesMatched = 0;
 
 	for (i = 0; i < _gameDescriptions.size(); i++) {
+		const ADGameDescription *g = _gameDescriptions[i];
 		fileMissing = false;
 
 		// Do not even bother to look at entries which do not have matching
 		// language and platform (if specified).
-		if ((_gameDescriptions[i]->language != language && language != UNK_LANG) ||
-			(_gameDescriptions[i]->platform != platform && platform != kPlatformUnknown)) {
+		if ((g->language != language && language != UNK_LANG) ||
+			(g->platform != platform && platform != kPlatformUnknown)) {
 			continue;
 		}
 		
 		// Try to open all files for this game
-		for (j = 0; _gameDescriptions[i]->filesDescriptions[j].fileName; j++) {
-			fileDesc = &_gameDescriptions[i]->filesDescriptions[j];
+		for (j = 0; g->filesDescriptions[j].fileName; j++) {
+			fileDesc = &g->filesDescriptions[j];
 			tstr = fileDesc->fileName;
 			tstr.toLowercase();
 			tstr2 = tstr + ".";
@@ -301,12 +301,12 @@
 			debug(3, "Matched file: %s", tstr.c_str());
 		}
 		if (!fileMissing) {
-			debug(2, "Found game: %s (%d)", getDescription(i).c_str(), i);
+			debug(2, "Found game: %s (%d)", getDescription(g).c_str(), i);
 
 			// Count the number of matching files. Then, only keep those
 			// entries which match a maximal amount of files.
 			int curFilesMatched = 0;
-			for (j = 0; _gameDescriptions[i]->filesDescriptions[j].fileName; j++)
+			for (j = 0; g->filesDescriptions[j].fileName; j++)
 				curFilesMatched++;
 			
 			if (curFilesMatched > maxFilesMatched) {
@@ -321,7 +321,7 @@
 			}
 
 		} else {
-			debug(5, "Skipping game: %s (%d)", getDescription(i).c_str(), i);
+			debug(5, "Skipping game: %s (%d)", getDescription(g).c_str(), i);
 		}
 	}
 

Modified: scummvm/trunk/common/advancedDetector.h
===================================================================
--- scummvm/trunk/common/advancedDetector.h	2006-12-19 23:14:15 UTC (rev 24894)
+++ scummvm/trunk/common/advancedDetector.h	2006-12-19 23:37:03 UTC (rev 24895)
@@ -37,7 +37,7 @@
 };
 
 struct ADGameDescription {
-	const char *name;
+	const char *gameid;
 	const char *extra;
 	const ADGameFileDescription *filesDescriptions;
 	Language language;
@@ -65,12 +65,8 @@
 // function, w/o a class or instantiating object... ? Or is there a deeper
 // reason I miss?
 class AdvancedDetector {
-
 public:
-	AdvancedDetector() {}
-	~AdvancedDetector() {}
 
-
 	void registerGameDescriptions(ADGameDescList gameDescriptions) {
 		_gameDescriptions = gameDescriptions;
 	}
@@ -91,8 +87,6 @@
 
 private:
 	ADGameDescList _gameDescriptions;
-
-	String getDescription(int num) const;
 };
 
 
@@ -107,9 +101,6 @@
 
 // FIXME/TODO: Rename this function to something more sensible.
 // Possibly move it inside class AdvancedDetector ?
-// Also, we could get rid of the descSize parameter, if we simply terminated the
-// list of game descriptions by an all-zero entry (like the SCUMM engine does in
-// similar cases).
 DetectedGameList real_ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
 	const FSList &fslist,
 	const byte *descs,
@@ -121,9 +112,6 @@
 
 // FIXME/TODO: Rename this function to something more sensible.
 // Possibly move it inside class AdvancedDetector ?
-// Also, we could get rid of the descSize parameter, if we simply terminated the
-// list of game descriptions by an all-zero entry (like the SCUMM engine does in
-// similar cases).
 int real_ADVANCED_DETECTOR_DETECT_INIT_GAME(
 	const byte *descs,
 	const int descItemSize,
@@ -139,13 +127,16 @@
 	);
 
 
-#define ADVANCED_DETECTOR_DETECT_GAMES(engine,detectFunc) \
+#define ADVANCED_DETECTOR_DEFINE_PLUGIN(engine,createFunction,detectFunc,list,obsoleteList) \
+	GameList Engine_##engine##_gameIDList() { \
+		return GameList(list); \
+	} \
+	GameDescriptor Engine_##engine##_findGameID(const char *gameid) { \
+		return Common::real_ADVANCED_DETECTOR_FIND_GAMEID(gameid,list,obsoleteList); \
+	} \
 	DetectedGameList Engine_##engine##_detectGames(const FSList &fslist) { \
 		return detectFunc(fslist);						\
 	} \
-	void dummyFuncToAllowTrailingSemicolon()
-
-#define ADVANCED_DETECTOR_ENGINE_CREATE(engine,createFunction,detectFunc,obsoleteList) \
 	PluginError Engine_##engine##_create(OSystem *syst, Engine **engine) { \
 		assert(syst); \
 		assert(engine); \
@@ -156,17 +147,7 @@
 	} \
 	void dummyFuncToAllowTrailingSemicolon()
 
-#define ADVANCED_DETECTOR_DEFINE_PLUGIN(engine,createFunction,detectFunc,list,obsoleteList) \
-	GameList Engine_##engine##_gameIDList() { \
-		return GameList(list); \
-	} \
-	GameDescriptor Engine_##engine##_findGameID(const char *gameid) { \
-		return Common::real_ADVANCED_DETECTOR_FIND_GAMEID(gameid,list,obsoleteList); \
-	} \
-	ADVANCED_DETECTOR_DETECT_GAMES(engine, detectFunc); \
-	ADVANCED_DETECTOR_ENGINE_CREATE(engine, createFunction, detectFunc, obsoleteList)
 
-
 }	// End of namespace Common
 
 #endif

Modified: scummvm/trunk/engines/kyra/plugin.cpp
===================================================================
--- scummvm/trunk/engines/kyra/plugin.cpp	2006-12-19 23:14:15 UTC (rev 24894)
+++ scummvm/trunk/engines/kyra/plugin.cpp	2006-12-19 23:37:03 UTC (rev 24895)
@@ -231,7 +231,8 @@
 	ADList games = detectKyraGames(fslist);
 
 	for (ADList::const_iterator pos = games.begin(); pos != games.end(); ++pos) {
-		DetectedGame game(adGameDescs[*pos].id, adGameDescs[*pos].desc.name, adGameDescs[*pos].desc.language, adGameDescs[*pos].desc.platform);
+		// FIXME: The 'gameid' field is being abused as a description field here!
+		DetectedGame game(adGameDescs[*pos].id, adGameDescs[*pos].desc.gameid, adGameDescs[*pos].desc.language, adGameDescs[*pos].desc.platform);
 		game.updateDesc(adGameDescs[*pos].desc.extra);
 		detectedGames.push_back(game);
 	}


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