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

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sun Nov 12 04:23:46 CET 2006


Revision: 24685
          http://svn.sourceforge.net/scummvm/?rev=24685&view=rev
Author:   fingolfin
Date:     2006-11-11 19:23:29 -0800 (Sat, 11 Nov 2006)

Log Message:
-----------
Reworked code in the advanced game detector (getting rid of much of the evil #define hell it consisted of previously)

Modified Paths:
--------------
    scummvm/trunk/base/game.h
    scummvm/trunk/base/plugins.h
    scummvm/trunk/common/advancedDetector.cpp
    scummvm/trunk/common/advancedDetector.h
    scummvm/trunk/engines/agos/game.cpp
    scummvm/trunk/engines/cine/detection.cpp
    scummvm/trunk/engines/kyra/plugin.cpp
    scummvm/trunk/engines/saga/game.cpp

Modified: scummvm/trunk/base/game.h
===================================================================
--- scummvm/trunk/base/game.h	2006-11-12 03:21:44 UTC (rev 24684)
+++ scummvm/trunk/base/game.h	2006-11-12 03:23:29 UTC (rev 24685)
@@ -25,6 +25,7 @@
 #define BASE_GAME_H
 
 #include "common/str.h"
+#include "common/array.h"
 
 struct PlainGameDescriptor {
 	const char *gameid;
@@ -53,7 +54,11 @@
 		gameid(g.gameid), description(g.description) {}
 };
 
+/** List of games. */
+typedef Common::Array<GameDescriptor> GameList;
 
+
+
 class Plugin;
 
 namespace Base {

Modified: scummvm/trunk/base/plugins.h
===================================================================
--- scummvm/trunk/base/plugins.h	2006-11-12 03:21:44 UTC (rev 24684)
+++ scummvm/trunk/base/plugins.h	2006-11-12 03:23:29 UTC (rev 24685)
@@ -35,9 +35,6 @@
 class FSList;
 class OSystem;
 
-/** List of games. */
-typedef Common::Array<GameDescriptor> GameList;
-
 /**
  * A detected game. Carries the GameDescriptor, but also (optionally)
  * information about the language and platform of the detected game.

Modified: scummvm/trunk/common/advancedDetector.cpp
===================================================================
--- scummvm/trunk/common/advancedDetector.cpp	2006-11-12 03:21:44 UTC (rev 24684)
+++ scummvm/trunk/common/advancedDetector.cpp	2006-11-12 03:23:29 UTC (rev 24685)
@@ -22,18 +22,184 @@
 
 #include "common/stdafx.h"
 
+#include "base/plugins.h"
+
 #include "common/util.h"
 #include "common/hash-str.h"
 #include "common/file.h"
 #include "common/md5.h"
 #include "common/advancedDetector.h"
+#include "common/config-manager.h"
 
 namespace Common {
 
-bool ADTrue() {
-	return true;
+PluginError real_ADVANCED_DETECTOR_ENGINE_CREATE(
+	DetectedGameList (*detectFunc)(const FSList &fslist),
+	const Common::ADObsoleteGameID *obsoleteList
+	) {
+	const char *gameid = ConfMan.get("gameid").c_str();
+
+	if (obsoleteList != 0) {
+		for (const Common::ADObsoleteGameID *o = obsoleteList; o->from; ++o) {
+			if (!scumm_stricmp(gameid, o->from)) {
+				gameid = o->to;
+				ConfMan.set("gameid", o->to);
+
+				if (o->platform != Common::kPlatformUnknown)
+					ConfMan.set("platform", Common::getPlatformCode(o->platform));
+
+				warning("Target upgraded from %s to %s", o->from, o->to);
+				ConfMan.flushToDisk();
+				break;
+			}
+		}
+	}
+
+	FSList fslist;
+	FilesystemNode dir(ConfMan.get("path"));
+	if (!dir.listDir(fslist, FilesystemNode::kListFilesOnly)) {
+		return kInvalidPathError;
+	}
+
+	DetectedGameList detectedGames = detectFunc(fslist);
+
+	for (uint i = 0; i < detectedGames.size(); i++) {
+		if (detectedGames[i].gameid == gameid) {
+			return kNoError;
+		}
+	}
+
+	return kNoGameDataFoundError;
 }
 
+GameList real_ADVANCED_DETECTOR_GAMEID_LIST(const PlainGameDescriptor *list) {
+	GameList games;
+	const PlainGameDescriptor *g = list;
+	while (g->gameid) {
+		games.push_back(*g);
+		g++;
+	}
+	return games;
+}
+
+GameDescriptor real_ADVANCED_DETECTOR_FIND_GAMEID(
+	const char *gameid,
+	const PlainGameDescriptor *list,
+	const Common::ADObsoleteGameID *obsoleteList
+	) {
+	const PlainGameDescriptor *g = list;
+	while (g->gameid) {
+		if (0 == scumm_stricmp(gameid, g->gameid))
+			return *g;
+		g++;
+	}
+
+	GameDescriptor gs;
+	if (obsoleteList != 0) {
+		const Common::ADObsoleteGameID *o = obsoleteList;
+		while (o->from) {
+			if (0 == scumm_stricmp(gameid, o->from)) {
+				gs.gameid = gameid;
+				gs.description = "Obsolete game ID";
+				return gs;
+			}
+			o++;
+		}
+	} else
+		return *g;
+	return gs;
+}
+
+DetectedGame toDetectedGame(const ADGameDescription &g, const PlainGameDescriptor *sg) {
+	const char *title = 0;
+
+	while (sg->gameid) {
+		if (!scumm_stricmp(g.name, sg->gameid))
+			title = sg->description;
+		sg++;
+	}
+
+	DetectedGame dg(g.name, title, g.language, g.platform);
+	dg.updateDesc(g.extra);
+	return dg;
+}
+
+DetectedGameList real_ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
+	const FSList &fslist,
+	const byte *descs,
+	const int descItemSize,
+	const int descItemCount,
+	const int md5Bytes,
+	const PlainGameDescriptor *list
+	) {
+	DetectedGameList detectedGames;
+	Common::AdvancedDetector AdvDetector;
+	Common::ADList matches;
+	Common::ADGameDescList descList;
+
+	for (int i = 0; i < descItemCount; i++)
+		descList.push_back((const ADGameDescription *)(descs + i * descItemSize));
+
+	AdvDetector.registerGameDescriptions(descList);
+	AdvDetector.setFileMD5Bytes(md5Bytes);
+
+	matches = AdvDetector.detectGame(&fslist, Common::UNK_LANG, Common::kPlatformUnknown);
+
+	for (uint i = 0; i < matches.size(); i++)
+		detectedGames.push_back(toDetectedGame(*(const ADGameDescription *)(descs + matches[i] * descItemSize), list));
+
+	return detectedGames;
+}
+
+int real_ADVANCED_DETECTOR_DETECT_INIT_GAME(
+	const byte *descs,
+	const int descItemSize,
+	const int descItemCount,
+	const int md5Bytes,
+	const PlainGameDescriptor *list
+	) {
+	int gameNumber = -1;
+
+	DetectedGameList detectedGames;
+	Common::AdvancedDetector AdvDetector;
+	Common::ADList matches;
+	Common::ADGameDescList descList;
+
+	Common::Language language = Common::UNK_LANG;
+	Common::Platform platform = Common::kPlatformUnknown;
+
+	if (ConfMan.hasKey("language"))
+		language = Common::parseLanguage(ConfMan.get("language"));
+	if (ConfMan.hasKey("platform"))
+		platform = Common::parsePlatform(ConfMan.get("platform"));
+
+	Common::String gameid = ConfMan.get("gameid");
+
+	for (int i = 0; i < descItemCount; i++)
+		descList.push_back((const ADGameDescription *)(descs + i * descItemSize));
+
+	AdvDetector.registerGameDescriptions(descList);
+	AdvDetector.setFileMD5Bytes(md5Bytes);
+
+	matches = AdvDetector.detectGame(0, language, platform);
+
+	for (uint i = 0; i < matches.size(); i++) {
+		if (toDetectedGame(*(const ADGameDescription *)(descs + matches[i] * descItemSize), list).gameid == gameid) {
+			gameNumber = matches[i];
+			break;
+		}
+	}
+
+	if (gameNumber >= descItemCount || gameNumber == -1) {
+		error("TODO invalid gameNumber %d (max. expected value: %d)", gameNumber, descItemCount );
+	}
+
+	debug(2, "Running %s", toDetectedGame(*(const ADGameDescription *)(descs + gameNumber * descItemSize), list).description.c_str());
+
+	return gameNumber;
+}
+
+
 AdvancedDetector::AdvancedDetector() {
 	_fileMD5Bytes = 0;
 }
@@ -84,7 +250,7 @@
 		}
 	}
 	
-	if (fslist != NULL) {
+	if (fslist != 0) {
 		for (FSList::const_iterator file = fslist->begin(); file != fslist->end(); ++file) {
 			if (file->isDirectory()) continue;
 			tstr = file->name();

Modified: scummvm/trunk/common/advancedDetector.h
===================================================================
--- scummvm/trunk/common/advancedDetector.h	2006-11-12 03:21:44 UTC (rev 24684)
+++ scummvm/trunk/common/advancedDetector.h	2006-11-12 03:23:29 UTC (rev 24685)
@@ -24,6 +24,10 @@
 
 #include "common/fs.h"
 
+#include "base/game.h"	// For PlainGameDescriptor and GameList
+#include "base/plugins.h"	// For DetectedGameList
+
+
 namespace Common {
 
 struct ADGameFileDescription {
@@ -47,186 +51,105 @@
 	Common::Platform platform;
 };
 
-bool ADTrue(void);
-
 typedef Array<int> ADList;
 typedef Array<const ADGameDescription*> ADGameDescList;
 
+// FIXME/TODO: Rename this function to something more sensible.
+// Possibly move it inside class AdvancedDetector ?
+// Maybe rename it to something like asGameList or pgdArrayToGameList,
+// and move it to base/game.h. Or add a constructor to GameList ... ?
+GameList real_ADVANCED_DETECTOR_GAMEID_LIST(const PlainGameDescriptor *list);
+
+// FIXME/TODO: Rename this function to something more sensible.
+// Possibly move it inside class AdvancedDetector ?
+GameDescriptor real_ADVANCED_DETECTOR_FIND_GAMEID(
+	const char *gameid,
+	const PlainGameDescriptor *list,
+	const Common::ADObsoleteGameID *obsoleteList
+	);
+
+
+// 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,
+	const int descItemSize,
+	const int descItemCount,
+	const int md5Bytes,
+	const PlainGameDescriptor *list
+	);
+
+
+// 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,
+	const int descItemCount,
+	const int md5Bytes,
+	const PlainGameDescriptor *list
+	);
+
+// FIXME/TODO: Rename this function to something more sensible.
+// Possibly move it inside class AdvancedDetector ?
+PluginError real_ADVANCED_DETECTOR_ENGINE_CREATE(
+	DetectedGameList (*detectFunc)(const FSList &fslist),
+	const Common::ADObsoleteGameID *obsoleteList
+	);
+
+
 #define ADVANCED_DETECTOR_GAMEID_LIST(engine,list) \
 	GameList Engine_##engine##_gameIDList() { \
-		GameList games; \
-		const PlainGameDescriptor *g = list; \
-		while (g->gameid) { \
-			games.push_back(*g); \
-			g++; \
-		} \
-		 \
-		return games; \
+		return Common::real_ADVANCED_DETECTOR_GAMEID_LIST(list); \
 	} \
 	void dummyFuncToAllowTrailingSemicolon()
 
-#define ADVANCED_DETECTOR_FIND_GAMEID(engine,list,obsoleteList)					  \
+#define ADVANCED_DETECTOR_FIND_GAMEID(engine,list,obsoleteList) \
 	GameDescriptor Engine_##engine##_findGameID(const char *gameid) { \
-		const PlainGameDescriptor *g = list; \
-		while (g->gameid) { \
-			if (0 == scumm_stricmp(gameid, g->gameid)) \
-				return *g; \
-			g++; \
-		} \
-		 \
-		GameDescriptor gs; \
-		if (obsoleteList) {\
-			const Common::ADObsoleteGameID *o = obsoleteList;	\
-			while (o->from) { \
-				if (0 == scumm_stricmp(gameid, o->from)) { \
-					gs.gameid = gameid; \
-					gs.description = "Obsolete game ID"; \
-					return gs; \
-				} \
-				o++; \
-			} \
-		} else \
-			return *g; \
-		return gs; \
+		return Common::real_ADVANCED_DETECTOR_FIND_GAMEID(gameid,list,obsoleteList); \
 	} \
 	void dummyFuncToAllowTrailingSemicolon()
 
-#define ADVANCED_DETECTOR_DETECT_GAMES(engine,function) \
+#define ADVANCED_DETECTOR_DETECT_GAMES(engine,detectFunc) \
 	DetectedGameList Engine_##engine##_detectGames(const FSList &fslist) { \
-		return function(fslist);						\
+		return detectFunc(fslist);						\
 	} \
 	void dummyFuncToAllowTrailingSemicolon()
 
-
-#define ADVANCED_DETECTOR_ENGINE_CREATE(engine,createFunction,engineName,obsoleteList) \
+#define ADVANCED_DETECTOR_ENGINE_CREATE(engine,createFunction,detectFunc,obsoleteList) \
 	PluginError Engine_##engine##_create(OSystem *syst, Engine **engine) { \
 		assert(syst); \
 		assert(engine); \
-		const char *gameid = ConfMan.get("gameid").c_str(); \
-		 \
-		if (obsoleteList) { \
-			for (const Common::ADObsoleteGameID *o = obsoleteList; o->from; ++o) { \
-				if (!scumm_stricmp(gameid, o->from)) { \
-					gameid = o->to; \
-					ConfMan.set("gameid", o->to); \
-					 \
-					if (o->platform != Common::kPlatformUnknown) \
-						ConfMan.set("platform", Common::getPlatformCode(o->platform)); \
-					\
-					warning("Target upgraded from %s to %s", o->from, o->to); \
-					ConfMan.flushToDisk(); \
-					break; \
-				} \
-			} \
-		} \
-		 \
-		FSList fslist; \
-		FilesystemNode dir(ConfMan.get("path")); \
-		if (!dir.listDir(fslist, FilesystemNode::kListFilesOnly)) { \
-			warning("%s: invalid game path '%s'", engineName, dir.path().c_str()); \
-			return kInvalidPathError; \
-		} \
-		 \
-		DetectedGameList detectedGames = Engine_##engine##_detectGames(fslist); \
-		 \
-		for (uint i = 0; i < detectedGames.size(); i++) { \
-			if (detectedGames[i].gameid == gameid) { \
-				*engine = new createFunction(syst); \
-				return kNoError; \
-			} \
-		} \
-		 \
-		warning("%s: Unable to locate game data at path '%s'", engineName, dir.path().c_str()); \
-		return kNoGameDataFoundError; \
+		PluginError err = real_ADVANCED_DETECTOR_ENGINE_CREATE(detectFunc, obsoleteList); \
+		if (err == kNoError) \
+			*engine = new createFunction(syst); \
+		return err; \
 	} \
 	void dummyFuncToAllowTrailingSemicolon()
 
-#define ADVANCED_DETECTOR_TO_DETECTED_GAME(list) \
-	DetectedGame toDetectedGame(const ADGameDescription &g) { \
-		const char *title = 0; \
-		\
-		const PlainGameDescriptor *sg = list; \
-		while (sg->gameid) { \
-			if (!scumm_stricmp(g.name, sg->gameid)) \
-				title = sg->description; \
-			sg++; \
-		} \
-		\
-		DetectedGame dg(g.name, title, g.language, g.platform); \
-		dg.updateDesc(g.extra); \
-		return dg; \
-	} \
-	void dummyFuncToAllowTrailingSemicolon()
+#define ADVANCED_DETECTOR_DEFINE_PLUGIN(engine,createFunction,detectFunc,list,obsoleteList) \
+	ADVANCED_DETECTOR_GAMEID_LIST(engine, list); \
+	ADVANCED_DETECTOR_FIND_GAMEID(engine, list, obsoleteList); \
+	ADVANCED_DETECTOR_DETECT_GAMES(engine, detectFunc); \
+	ADVANCED_DETECTOR_ENGINE_CREATE(engine, createFunction, detectFunc, obsoleteList)
 
-#define ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(function,descriptions) \
-	DetectedGameList function(const FSList &fslist) { \
-		DetectedGameList detectedGames; \
-		Common::AdvancedDetector AdvDetector; \
-		Common::ADList matches; \
-		Common::ADGameDescList descList; \
-		\
-		for (int i = 0; i < ARRAYSIZE(descriptions); i++) \
-			descList.push_back((const ADGameDescription *)&descriptions[i]); \
-		\
-		AdvDetector.registerGameDescriptions(descList); \
-		AdvDetector.setFileMD5Bytes(FILE_MD5_BYTES); \
-		\
-		matches = AdvDetector.detectGame(&fslist, Common::UNK_LANG, Common::kPlatformUnknown); \
-		\
-		for (uint i = 0; i < matches.size(); i++) \
-			detectedGames.push_back(toDetectedGame(descriptions[matches[i]].desc)); \
-		\
-		return detectedGames; \
-	} \
-	void dummyFuncToAllowTrailingSemicolon()
 
-#define ADVANCED_DETECTOR_DETECT_INIT_GAME(function,descriptions,varname,postFunction) \
-	bool function() { \
-		int gameNumber = -1; \
-		\
-		DetectedGameList detectedGames; \
-		Common::AdvancedDetector AdvDetector; \
-		Common::ADList matches; \
-		Common::ADGameDescList descList; \
-		\
-		Common::Language language = Common::UNK_LANG; \
-		Common::Platform platform = Common::kPlatformUnknown; \
-		\
-		if (ConfMan.hasKey("language")) \
-			language = Common::parseLanguage(ConfMan.get("language")); \
-		if (ConfMan.hasKey("platform")) \
-			platform = Common::parsePlatform(ConfMan.get("platform")); \
-		\
-		Common::String gameid = ConfMan.get("gameid"); \
-		\
-		for (int i = 0; i < ARRAYSIZE(descriptions); i++) \
-			descList.push_back((const ADGameDescription *)&descriptions[i]); \
-		\
-		AdvDetector.registerGameDescriptions(descList); \
-		AdvDetector.setFileMD5Bytes(FILE_MD5_BYTES); \
-		\
-		matches = AdvDetector.detectGame(NULL, language, platform); \
-		\
-		for (uint i = 0; i < matches.size(); i++) { \
-			if (toDetectedGame(descriptions[matches[i]].desc).gameid == gameid) { \
-				gameNumber = matches[i]; \
-				break; \
-			} \
-		} \
-		\
-		if (gameNumber >= ARRAYSIZE(descriptions) || gameNumber == -1) { \
-			error("%s wrong gameNumber", "##function##");								\
-		} \
-		\
-		debug(2, "Running %s", toDetectedGame(descriptions[gameNumber].desc).description.c_str()); \
-		\
-		varname = &descriptions[gameNumber]; \
-		\
-		return postFunction(); \
-	} \
-	void dummyFuncToAllowTrailingSemicolon()
-
-
+// TODO/FIXME: Fingolfin asks: Why is AdvancedDetector a class, considering that
+// it is only used as follow:
+//  1) Create an instance of it on the stack
+//  2) invoke registerGameDescriptions and setFileMD5Bytes 
+//  3) invoke detectGame *once*
+// Obviously, 2) could also be handled by passing more params to detectGame.
+// So it seem we could replace this class by a simple advancedDetectGame(...)
+// function, w/o a class or instantiating object... ? Or is there a deeper
+// reason I miss?
 class AdvancedDetector {
 
 public:

Modified: scummvm/trunk/engines/agos/game.cpp
===================================================================
--- scummvm/trunk/engines/agos/game.cpp	2006-11-12 03:21:44 UTC (rev 24684)
+++ scummvm/trunk/engines/agos/game.cpp	2006-11-12 03:23:29 UTC (rev 24685)
@@ -54,7 +54,7 @@
 	{"simon2talkie", "simon2", Common::kPlatformPC},
 	{"simon2mac", "simon2", Common::kPlatformMacintosh},
 	{"simon2win", "simon2",  Common::kPlatformWindows},
-	{NULL, NULL, Common::kPlatformUnknown}
+	{0, 0, Common::kPlatformUnknown}
 };
 
 static const PlainGameDescriptor simonGames[] = {
@@ -68,17 +68,11 @@
 	{"jumble", "Jumble"},
 	{"puzzle", "NoPatience"},
 	{"swampy", "Swampy Adventures"},
-	{NULL, NULL}
+	{0, 0}
 };
 
-ADVANCED_DETECTOR_GAMEID_LIST(AGOS, simonGames);
+ADVANCED_DETECTOR_DEFINE_PLUGIN(AGOS, AGOS::AGOSEngine, AGOS::GAME_detectGames, simonGames, obsoleteGameIDsTable);
 
-ADVANCED_DETECTOR_FIND_GAMEID(AGOS, simonGames, obsoleteGameIDsTable);
-
-ADVANCED_DETECTOR_DETECT_GAMES(AGOS, AGOS::GAME_detectGames);
-
-ADVANCED_DETECTOR_ENGINE_CREATE(AGOS, AGOS::AGOSEngine, "AGOSEngine", obsoleteGameIDsTable);
-
 REGISTER_PLUGIN(AGOS, "AGOS", "AGOS (C) Adventure Soft");
 
 namespace AGOS {
@@ -88,10 +82,27 @@
 
 #include "agosgame.cpp"
 
-ADVANCED_DETECTOR_TO_DETECTED_GAME(simonGames);
+bool AGOSEngine::initGame() {
+	int i = Common::real_ADVANCED_DETECTOR_DETECT_INIT_GAME(
+		(const byte *)gameDescriptions,
+		sizeof(AGOSGameDescription),
+		ARRAYSIZE(gameDescriptions),
+		FILE_MD5_BYTES,
+		simonGames
+		);
+	_gameDescription = &gameDescriptions[i];
+	return true;
+}
 
-ADVANCED_DETECTOR_DETECT_INIT_GAME(AGOSEngine::initGame, gameDescriptions, _gameDescription, Common::ADTrue);
+DetectedGameList GAME_detectGames(const FSList &fslist) {
+	return real_ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
+		fslist,
+		(const byte *)gameDescriptions,
+		sizeof(AGOSGameDescription),
+		ARRAYSIZE(gameDescriptions),
+		FILE_MD5_BYTES,
+		simonGames
+	);
+}
 
-ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(GAME_detectGames, gameDescriptions);
-
 } // End of namespace AGOS

Modified: scummvm/trunk/engines/cine/detection.cpp
===================================================================
--- scummvm/trunk/engines/cine/detection.cpp	2006-11-12 03:21:44 UTC (rev 24684)
+++ scummvm/trunk/engines/cine/detection.cpp	2006-11-12 03:23:29 UTC (rev 24685)
@@ -41,18 +41,11 @@
 static const PlainGameDescriptor cineGames[] = {
 	{"fw", "Future Wars"},
 	{"os", "Operation Stealth"},
-	{NULL, NULL}
+	{0, 0}
 };
 
-ADVANCED_DETECTOR_GAMEID_LIST(CINE, cineGames);
+ADVANCED_DETECTOR_DEFINE_PLUGIN(CINE, Cine::CineEngine, Cine::GAME_detectGames, cineGames, 0);
 
-ADVANCED_DETECTOR_FIND_GAMEID(CINE, cineGames, NULL);
-
-ADVANCED_DETECTOR_DETECT_GAMES(CINE, Cine::GAME_detectGames);
-
-ADVANCED_DETECTOR_ENGINE_CREATE(CINE, Cine::CineEngine, "CineEngine", NULL);
-
-
 REGISTER_PLUGIN(CINE, "Cinematique evo 1 engine", "Future Wars & Operation Stealth (C) Delphine Software");
 
 namespace Cine {
@@ -579,10 +572,27 @@
 
 };
 
-ADVANCED_DETECTOR_TO_DETECTED_GAME(cineGames);
+bool CineEngine::initGame() {
+	int i = Common::real_ADVANCED_DETECTOR_DETECT_INIT_GAME(
+		(const byte *)gameDescriptions,
+		sizeof(CINEGameDescription),
+		ARRAYSIZE(gameDescriptions),
+		FILE_MD5_BYTES,
+		cineGames
+		);
+	_gameDescription = &gameDescriptions[i];
+	return true;
+}
 
-ADVANCED_DETECTOR_DETECT_INIT_GAME(CineEngine::initGame, gameDescriptions, _gameDescription, Common::ADTrue);
+DetectedGameList GAME_detectGames(const FSList &fslist) {
+	return real_ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
+		fslist,
+		(const byte *)gameDescriptions,
+		sizeof(CINEGameDescription),
+		ARRAYSIZE(gameDescriptions),
+		FILE_MD5_BYTES,
+		cineGames
+	);
+}
 
-ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(GAME_detectGames, gameDescriptions);
-
 } // End of namespace Cine

Modified: scummvm/trunk/engines/kyra/plugin.cpp
===================================================================
--- scummvm/trunk/engines/kyra/plugin.cpp	2006-11-12 03:21:44 UTC (rev 24684)
+++ scummvm/trunk/engines/kyra/plugin.cpp	2006-11-12 03:23:29 UTC (rev 24685)
@@ -203,9 +203,13 @@
 
 } // End of anonymous namespace
 
-ADVANCED_DETECTOR_GAMEID_LIST(KYRA, gameList);
+GameList Engine_KYRA_gameIDList() {
+	return Common::real_ADVANCED_DETECTOR_GAMEID_LIST(gameList);
+}
 
-ADVANCED_DETECTOR_FIND_GAMEID(KYRA, gameList, NULL);
+GameDescriptor Engine_KYRA_findGameID(const char *gameid) {
+	return Common::real_ADVANCED_DETECTOR_FIND_GAMEID(gameid, gameList, 0);
+}
 
 DetectedGameList Engine_KYRA_detectGames(const FSList &fslist) {
 	DetectedGameList detectedGames;
@@ -227,14 +231,12 @@
 	FSList fslist;
 	FilesystemNode dir(ConfMan.get("path"));
 	if (!dir.listDir(fslist, FilesystemNode::kListFilesOnly)) {
-		warning("KyraEngine: invalid game path '%s'", dir.path().c_str());
 		return kInvalidPathError;
 	}
 
 	GameFlags flags;
 	ADList games = detectKyraGames(fslist);
 	if (!setupGameFlags(games, flags)) {
-		warning("KyraEngine: unable to locate game data at path '%s'", dir.path().c_str());
 		return kNoGameDataFoundError;
 	}
 

Modified: scummvm/trunk/engines/saga/game.cpp
===================================================================
--- scummvm/trunk/engines/saga/game.cpp	2006-11-12 03:21:44 UTC (rev 24684)
+++ scummvm/trunk/engines/saga/game.cpp	2006-11-12 03:23:29 UTC (rev 24685)
@@ -48,15 +48,9 @@
 	{0, 0}
 };
 
-ADVANCED_DETECTOR_GAMEID_LIST(SAGA, saga_games);
+ADVANCED_DETECTOR_DEFINE_PLUGIN(SAGA, Saga::SagaEngine, Saga::GAME_detectGames, saga_games, 0);
 
-ADVANCED_DETECTOR_FIND_GAMEID(SAGA, saga_games, NULL);
 
-ADVANCED_DETECTOR_DETECT_GAMES(SAGA, Saga::GAME_detectGames);
-
-ADVANCED_DETECTOR_ENGINE_CREATE(SAGA, Saga::SagaEngine, "SagaEngine", NULL);
-
-
 REGISTER_PLUGIN(SAGA, "SAGA Engine", "Inherit the Earth (C) Wyrmkeep Entertainment");
 
 namespace Saga {
@@ -66,8 +60,6 @@
 
 #include "sagagame.cpp"
 
-ADVANCED_DETECTOR_TO_DETECTED_GAME(saga_games);
-
 bool SagaEngine::postInitGame() {
 	_gameDisplayInfo = *_gameDescription->gameDisplayInfo;
 	_displayClip.right = _gameDisplayInfo.logicalWidth;
@@ -79,8 +71,27 @@
 	return true;
 }
 
-ADVANCED_DETECTOR_DETECT_INIT_GAME(SagaEngine::initGame, gameDescriptions, _gameDescription, postInitGame);
+bool SagaEngine::initGame() {
+	int i = Common::real_ADVANCED_DETECTOR_DETECT_INIT_GAME(
+		(const byte *)gameDescriptions,
+		sizeof(SAGAGameDescription),
+		ARRAYSIZE(gameDescriptions),
+		FILE_MD5_BYTES,
+		saga_games
+		);
+	_gameDescription = &gameDescriptions[i];
+	return postInitGame();
+}
 
-ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(GAME_detectGames, gameDescriptions);
+DetectedGameList GAME_detectGames(const FSList &fslist) {
+	return real_ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
+		fslist,
+		(const byte *)gameDescriptions,
+		sizeof(SAGAGameDescription),
+		ARRAYSIZE(gameDescriptions),
+		FILE_MD5_BYTES,
+		saga_games
+	);
+}
 
 } // End of namespace Saga


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