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

sev at users.sourceforge.net sev at users.sourceforge.net
Sat Jan 20 22:27:58 CET 2007


Revision: 25134
          http://scummvm.svn.sourceforge.net/scummvm/?rev=25134&view=rev
Author:   sev
Date:     2007-01-20 13:27:57 -0800 (Sat, 20 Jan 2007)

Log Message:
-----------
First phase of detection-related plugins interface improvements. Now plugins
return StringMap instead of fixed list of parameters. This adds great
flexibility.

Current patch should not alter any functionality, i.e. if there are regressions,
submit a report. Phase 2 will benefit from these changes and will come later.

Modified Paths:
--------------
    scummvm/trunk/backends/plugins/dynamic-plugin.h
    scummvm/trunk/base/commandLine.cpp
    scummvm/trunk/base/game.h
    scummvm/trunk/base/main.cpp
    scummvm/trunk/base/plugins.cpp
    scummvm/trunk/base/plugins.h
    scummvm/trunk/common/advancedDetector.cpp
    scummvm/trunk/common/advancedDetector.h
    scummvm/trunk/engines/agi/detection.cpp
    scummvm/trunk/engines/agos/game.cpp
    scummvm/trunk/engines/cine/detection.cpp
    scummvm/trunk/engines/gob/gob.cpp
    scummvm/trunk/engines/kyra/plugin.cpp
    scummvm/trunk/engines/lure/lure.cpp
    scummvm/trunk/engines/parallaction/detection.cpp
    scummvm/trunk/engines/queen/queen.cpp
    scummvm/trunk/engines/saga/game.cpp
    scummvm/trunk/engines/scumm/plugin.cpp
    scummvm/trunk/engines/sky/sky.cpp
    scummvm/trunk/engines/sword1/sword1.cpp
    scummvm/trunk/engines/sword2/sword2.cpp
    scummvm/trunk/engines/touche/plugin.cpp
    scummvm/trunk/gui/launcher.cpp
    scummvm/trunk/gui/launcher.h

Modified: scummvm/trunk/backends/plugins/dynamic-plugin.h
===================================================================
--- scummvm/trunk/backends/plugins/dynamic-plugin.h	2007-01-20 18:27:22 UTC (rev 25133)
+++ scummvm/trunk/backends/plugins/dynamic-plugin.h	2007-01-20 21:27:57 UTC (rev 25134)
@@ -34,7 +34,7 @@
 typedef const char *(*NameFunc)();
 typedef GameDescriptor (*GameIDQueryFunc)(const char *gameid);
 typedef GameList (*GameIDListFunc)();
-typedef DetectedGameList (*DetectFunc)(const FSList &fslist);
+typedef GameList (*DetectFunc)(const FSList &fslist);
 
 
 class DynamicPlugin : public Plugin {
@@ -68,7 +68,7 @@
 		return (*_qf)(gameid);
 	}
 
-	DetectedGameList detectGames(const FSList &fslist) const {
+	GameList detectGames(const FSList &fslist) const {
 		assert(_df);
 		return (*_df)(fslist);
 	}

Modified: scummvm/trunk/base/commandLine.cpp
===================================================================
--- scummvm/trunk/base/commandLine.cpp	2007-01-20 18:27:22 UTC (rev 25133)
+++ scummvm/trunk/base/commandLine.cpp	2007-01-20 21:27:57 UTC (rev 25134)
@@ -527,7 +527,7 @@
 	for (iter = plugins.begin(); iter != plugins.end(); ++iter) {
 		GameList list = (*iter)->getSupportedGames();
 		for (GameList::iterator v = list.begin(); v != list.end(); ++v) {
-			printf("%-20s %s\n", v->gameid.c_str(), v->description.c_str());
+			printf("%-20s %s\n", v->gameid().c_str(), v->description().c_str());
 		}
 	}
 }
@@ -550,8 +550,8 @@
 			// be taken into account, too.
 			Common::String gameid(name);
 			GameDescriptor g = Base::findGame(gameid);
-			if (g.description.size() > 0)
-				description = g.description;
+			if (g["description"].size() > 0)
+				description = g["description"];
 		}
 
 		printf("%-20s %s\n", name.c_str(), description.c_str());
@@ -589,11 +589,11 @@
 			continue;
 		}
 
-		DetectedGameList candidates(PluginManager::instance().detectGames(files));
+		GameList candidates(PluginManager::instance().detectGames(files));
 		bool gameidDiffers = false;
-		DetectedGameList::iterator x;
+		GameList::iterator x;
 		for (x = candidates.begin(); x != candidates.end(); ++x) {
-			gameidDiffers |= (scumm_stricmp(gameid.c_str(), x->gameid.c_str()) != 0);
+			gameidDiffers |= (scumm_stricmp(gameid.c_str(), x->gameid().c_str()) != 0);
 		}
 		
 		if (candidates.empty()) {
@@ -616,10 +616,10 @@
 		
 		for (x = candidates.begin(); x != candidates.end(); ++x) {
 			printf("    gameid '%s', desc '%s', language '%s', platform '%s'\n",
-					x->gameid.c_str(),
-					x->description.c_str(),
-					Common::getLanguageCode(x->language),
-					Common::getPlatformCode(x->platform));
+				   x->gameid().c_str(),
+				   x->description().c_str(),
+				   Common::getLanguageCode(x->language()),
+				   Common::getPlatformCode(x->platform()));
 		}
 	}
 	int total = domains.size();
@@ -666,7 +666,7 @@
 	// domain (i.e. a target) matching this argument, or alternatively
 	// whether there is a gameid matching that name.
 	if (!command.empty()) {
-		if (ConfMan.hasGameDomain(command) || Base::findGame(command).gameid.size() > 0) {
+		if (ConfMan.hasGameDomain(command) || Base::findGame(command)["gameid"].size() > 0) {
 			ConfMan.setActiveDomain(command);
 		} else {
 			usage("Unrecognized game target '%s'", command.c_str());

Modified: scummvm/trunk/base/game.h
===================================================================
--- scummvm/trunk/base/game.h	2007-01-20 18:27:22 UTC (rev 25133)
+++ scummvm/trunk/base/game.h	2007-01-20 21:27:57 UTC (rev 25134)
@@ -26,32 +26,41 @@
 
 #include "common/str.h"
 #include "common/array.h"
+#include "common/hash-str.h"
 
 struct PlainGameDescriptor {
 	const char *gameid;
 	const char *description;	// TODO: Rename this to "title" or so
 };
 
-struct GameDescriptor {
-	Common::String gameid;
-	Common::String description;	// TODO: Rename this to "title" or so
-	
+class GameDescriptor : public Common::StringMap {
+public:
 	GameDescriptor() {}
-	GameDescriptor(Common::String g, Common::String d) :
-		gameid(g), description(d) {}
 
+	GameDescriptor(const PlainGameDescriptor &pgd) {
+		this->operator []("gameid") = pgd.gameid;
+		this->operator []("description") = pgd.description;
+	}
+
+	GameDescriptor(Common::String g, Common::String d, Common::Language l  = Common::UNK_LANG,
+	             Common::Platform p = Common::kPlatformUnknown) {
+		this->operator []("gameid") = g;
+		this->operator []("description") = d;
+		if (l != Common::UNK_LANG)
+			this->operator []("language") = Common::getLanguageCode(l);
+		if (p != Common::kPlatformUnknown)
+			this->operator []("platform") = Common::getPlatformCode(p);
+	}
+
 	/**
-	 * This template constructor allows to easily convert structs that mimic
-	 * GameDescriptor to a real GameDescriptor instance.
-	 *
-	 * Normally, one would just subclass GameDescriptor to get this effect much easier.
-	 * However, subclassing a struct turns it into a non-POD type. One of the
-	 * consequences is that you can't have inline intialized arrays of that type.
-	 * But we heavily rely on those, hence we can't subclass GameDescriptor...
+	 * Update the description string by appending (LANG/PLATFORM/EXTRA) to it.
 	 */
-	template <class T>
-	GameDescriptor(const T &g) :
-		gameid(g.gameid), description(g.description) {}
+	void updateDesc(const char *extra = 0);
+
+	Common::String &gameid() { return this->operator []("gameid"); }
+	Common::String &description() { return this->operator []("description"); }
+	Common::Language language() { return Common::parseLanguage(this->operator []("language")); }
+	Common::Platform platform() { return Common::parsePlatform(this->operator []("platform")); }
 };
 
 /** List of games. */
@@ -61,7 +70,7 @@
 	GameList(const GameList &list) : Common::Array<GameDescriptor>(list) {}
 	GameList(const PlainGameDescriptor *g) {
 		while (g->gameid) {
-			push_back(*g);
+			push_back(GameDescriptor(g->gameid, g->description));
 			g++;
 		}
 	}

Modified: scummvm/trunk/base/main.cpp
===================================================================
--- scummvm/trunk/base/main.cpp	2007-01-20 18:27:22 UTC (rev 25133)
+++ scummvm/trunk/base/main.cpp	2007-01-20 21:27:57 UTC (rev 25134)
@@ -69,7 +69,7 @@
 	PluginList::const_iterator iter = plugins.begin();
 	for (iter = plugins.begin(); iter != plugins.end(); ++iter) {
 		result = (*iter)->findGame(gameName.c_str());
-		if (!result.gameid.empty()) {
+		if (!result.gameid().empty()) {
 			if (plugin)
 				*plugin = *iter;
 			break;
@@ -126,7 +126,7 @@
 	}
 
 	// FIXME: Do we really need this one? 
-	printf("Trying to start game '%s'\n", game.description.c_str());
+	printf("Trying to start game '%s'\n", game.description().c_str());
 
 	return plugin;
 }
@@ -191,7 +191,7 @@
 	// Set the window caption to the game name
 	Common::String caption(ConfMan.get("description"));
 
-	Common::String desc = Base::findGame(ConfMan.get("gameid")).description;
+	Common::String desc = Base::findGame(ConfMan.get("gameid")).description();
 	if (caption.empty() && !desc.empty())
 		caption = desc;
 	if (caption.empty())

Modified: scummvm/trunk/base/plugins.cpp
===================================================================
--- scummvm/trunk/base/plugins.cpp	2007-01-20 18:27:22 UTC (rev 25133)
+++ scummvm/trunk/base/plugins.cpp	2007-01-20 21:27:57 UTC (rev 25134)
@@ -25,30 +25,33 @@
 #include "common/util.h"
 
 
-void DetectedGame::updateDesc(const char *extra) {
+void GameDescriptor::updateDesc(const char *extra) {
 	// TODO: The format used here (LANG/PLATFORM/EXTRA) is not set in stone.
 	// We may want to change the order (PLATFORM/EXTRA/LANG, anybody?), or
 	// the seperator (instead of '/' use ', ' or ' ').
-	const bool hasCustomLanguage = (language != Common::UNK_LANG);
-	const bool hasCustomPlatform = (platform != Common::kPlatformUnknown);
+	const bool hasCustomLanguage = (this->contains("language") && (this->language() != Common::UNK_LANG));
+	const bool hasCustomPlatform = (this->contains("platform") && (this->platform() != Common::kPlatformUnknown));
 	const bool hasExtraDesc = (extra && extra[0]);
 
 	// Adapt the description string if custom platform/language is set.
 	if (hasCustomLanguage || hasCustomPlatform || hasExtraDesc) {
-		description += " (";
+		Common::String descr = this->description();
+
+		descr += " (";
 		if (hasCustomLanguage)
-			description += Common::getLanguageDescription(language);
+			descr += Common::getLanguageDescription(this->language());
 		if (hasCustomPlatform) {
 			if (hasCustomLanguage)
-				description += "/";
-			description += Common::getPlatformDescription(platform);
+				descr += "/";
+			descr += Common::getPlatformDescription(this->platform());
 		}
 		if (hasExtraDesc) {
 			if (hasCustomPlatform || hasCustomLanguage)
-				description += "/";
-			description += extra;
+				descr += "/";
+			descr += extra;
 		}
-		description += ")";
+		descr += ")";
+		this->operator []("description") = descr;
 	}
 }
 
@@ -86,7 +89,7 @@
 		return (*_plugin->_qf)(gameid);
 	}
 
-	DetectedGameList detectGames(const FSList &fslist) const {
+	GameList detectGames(const FSList &fslist) const {
 		assert(_plugin->_df);
 		return (*_plugin->_df)(fslist);
 	}
@@ -247,8 +250,8 @@
 	}
 }
 
-DetectedGameList PluginManager::detectGames(const FSList &fslist) const {
-	DetectedGameList candidates;
+GameList PluginManager::detectGames(const FSList &fslist) const {
+	GameList candidates;
 
 	// Iterate over all known games and for each check if it might be
 	// the game in the presented directory.

Modified: scummvm/trunk/base/plugins.h
===================================================================
--- scummvm/trunk/base/plugins.h	2007-01-20 18:27:22 UTC (rev 25133)
+++ scummvm/trunk/base/plugins.h	2007-01-20 21:27:57 UTC (rev 25134)
@@ -36,35 +36,6 @@
 class OSystem;
 
 /**
- * A detected game. Carries the GameDescriptor, but also (optionally)
- * information about the language and platform of the detected game.
- */
-struct DetectedGame : public GameDescriptor {
-	Common::Language language;
-	Common::Platform platform;
-	DetectedGame(const char *g = 0, const char *d = 0,
-	             Common::Language l = Common::UNK_LANG,
-	             Common::Platform p = Common::kPlatformUnknown)
-		: GameDescriptor(g, d), language(l), platform(p) {}
-
-	template <class T>
-	DetectedGame(const T &game,
-	             Common::Language l = Common::UNK_LANG,
-	             Common::Platform p = Common::kPlatformUnknown)
-		: GameDescriptor(game.gameid, game.description), language(l), platform(p) {}
-	
-	/**
-	 * Update the description string by appending (LANG/PLATFORM/EXTRA) to it.
-	 */
-	void updateDesc(const char *extra = 0);
-};
-
-
-/** List of detected games. */
-typedef Common::Array<DetectedGame> DetectedGameList;
-
-
-/**
  * Error codes which mayb be reported by plugins under various circumstances.
  * @todo Turn this into a global 'ErrorCode' enum used by all of ScummVM ?
  */
@@ -96,7 +67,7 @@
 
 	virtual GameList getSupportedGames() const = 0;
 	virtual GameDescriptor findGame(const char *gameid) const = 0;
-	virtual DetectedGameList detectGames(const FSList &fslist) const = 0;
+	virtual GameList detectGames(const FSList &fslist) const = 0;
 
 	virtual PluginError createInstance(OSystem *syst, Engine **engine) const = 0;
 };
@@ -146,7 +117,7 @@
 		PLUGIN_EXPORT GameList PLUGIN_gameIDList() { return Engine_##ID##_gameIDList(); } \
 		PLUGIN_EXPORT GameDescriptor PLUGIN_findGameID(const char *gameid) { return Engine_##ID##_findGameID(gameid); } \
 		PLUGIN_EXPORT PluginError PLUGIN_createEngine(OSystem *syst, Engine **engine) { return Engine_##ID##_create(syst, engine); } \
-		PLUGIN_EXPORT DetectedGameList PLUGIN_detectGames(const FSList &fslist) { return Engine_##ID##_detectGames(fslist); } \
+		PLUGIN_EXPORT GameList PLUGIN_detectGames(const FSList &fslist) { return Engine_##ID##_detectGames(fslist); } \
 	} \
 	void dummyFuncToAllowTrailingSemicolon()
 #endif
@@ -161,7 +132,7 @@
 public:
 	typedef GameDescriptor (*GameIDQueryFunc)(const char *gameid);
 	typedef PluginError (*EngineFactory)(OSystem *syst, Engine **engine);
-	typedef DetectedGameList (*DetectFunc)(const FSList &fslist);
+	typedef GameList (*DetectFunc)(const FSList &fslist);
 
 protected:
 	const char *_name;
@@ -225,7 +196,7 @@
 
 	const PluginList &getPlugins()	{ return _plugins; }
 
-	DetectedGameList detectGames(const FSList &fslist) const;
+	GameList detectGames(const FSList &fslist) const;
 };
 
 #endif

Modified: scummvm/trunk/common/advancedDetector.cpp
===================================================================
--- scummvm/trunk/common/advancedDetector.cpp	2007-01-20 18:27:22 UTC (rev 25133)
+++ scummvm/trunk/common/advancedDetector.cpp	2007-01-20 21:27:57 UTC (rev 25134)
@@ -34,7 +34,7 @@
 namespace Common {
 
 PluginError ADVANCED_DETECTOR_ENGINE_CREATE(
-	DetectedGameList (*detectFunc)(const FSList &fslist),
+	GameList (*detectFunc)(const FSList &fslist),
 	const Common::ADObsoleteGameID *obsoleteList
 	) {
 	const char *gameid = ConfMan.get("gameid").c_str();
@@ -61,10 +61,10 @@
 		return kInvalidPathError;
 	}
 
-	DetectedGameList detectedGames = detectFunc(fslist);
+	GameList detectedGames = detectFunc(fslist);
 
 	for (uint i = 0; i < detectedGames.size(); i++) {
-		if (detectedGames[i].gameid == gameid) {
+		if (detectedGames[i].gameid() == gameid) {
 			return kNoError;
 		}
 	}
@@ -89,18 +89,18 @@
 		const Common::ADObsoleteGameID *o = obsoleteList;
 		while (o->from) {
 			if (0 == scumm_stricmp(gameid, o->from)) {
-				gs.gameid = gameid;
-				gs.description = "Obsolete game ID";
+				gs["gameid"] = gameid;
+				gs["description"] = "Obsolete game ID";
 				return gs;
 			}
 			o++;
 		}
 	} else
-		return *g;
+		return GameDescriptor(g->gameid, g->description);
 	return gs;
 }
 
-static DetectedGame toDetectedGame(const ADGameDescription &g, const PlainGameDescriptor *sg) {
+static GameDescriptor toGameDescriptor(const ADGameDescription &g, const PlainGameDescriptor *sg) {
 	const char *title = 0;
 
 	while (sg->gameid) {
@@ -109,19 +109,19 @@
 		sg++;
 	}
 
-	DetectedGame dg(g.gameid, title, g.language, g.platform);
-	dg.updateDesc(g.extra);
-	return dg;
+	GameDescriptor gd(g.gameid, title, g.language, g.platform);
+	gd.updateDesc(g.extra);
+	return gd;
 }
 
-DetectedGameList ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
+GameList ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
 	const FSList &fslist,
 	const byte *descs,
 	const int descItemSize,
 	const int md5Bytes,
 	const PlainGameDescriptor *list
 	) {
-	DetectedGameList detectedGames;
+	GameList detectedGames;
 	Common::AdvancedDetector ad;
 	Common::ADList matches;
 	Common::ADGameDescList descList;
@@ -137,7 +137,7 @@
 	matches = ad.detectGame(&fslist, md5Bytes, Common::UNK_LANG, Common::kPlatformUnknown);
 
 	for (uint i = 0; i < matches.size(); i++)
-		detectedGames.push_back(toDetectedGame(*(const ADGameDescription *)(descs + matches[i] * descItemSize), list));
+		detectedGames.push_back(toGameDescriptor(*(const ADGameDescription *)(descs + matches[i] * descItemSize), list));
 
 	return detectedGames;
 }
@@ -150,7 +150,7 @@
 	) {
 	int gameNumber = -1;
 
-	DetectedGameList detectedGames;
+	GameList detectedGames;
 	Common::AdvancedDetector ad;
 	Common::ADList matches;
 	Common::ADGameDescList descList;
@@ -184,7 +184,7 @@
 		error("TODO invalid gameNumber %d (max. expected value: %d)", gameNumber, descList.size());
 	}
 
-	debug(2, "Running %s", toDetectedGame(*(const ADGameDescription *)(descs + gameNumber * descItemSize), list).description.c_str());
+	debug(2, "Running %s", toGameDescriptor(*(const ADGameDescription *)(descs + gameNumber * descItemSize), list).description().c_str());
 
 	return gameNumber;
 }

Modified: scummvm/trunk/common/advancedDetector.h
===================================================================
--- scummvm/trunk/common/advancedDetector.h	2007-01-20 18:27:22 UTC (rev 25133)
+++ scummvm/trunk/common/advancedDetector.h	2007-01-20 21:27:57 UTC (rev 25134)
@@ -102,7 +102,7 @@
 
 // FIXME/TODO: Rename this function to something more sensible.
 // Possibly move it inside class AdvancedDetector ?
-DetectedGameList ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
+GameList ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
 	const FSList &fslist,
 	const byte *descs,
 	const int descItemSize,
@@ -123,7 +123,7 @@
 // FIXME/TODO: Rename this function to something more sensible.
 // Possibly move it inside class AdvancedDetector ?
 PluginError ADVANCED_DETECTOR_ENGINE_CREATE(
-	DetectedGameList (*detectFunc)(const FSList &fslist),
+	GameList (*detectFunc)(const FSList &fslist),
 	const Common::ADObsoleteGameID *obsoleteList
 	);
 
@@ -135,7 +135,7 @@
 	GameDescriptor Engine_##engine##_findGameID(const char *gameid) { \
 		return Common::ADVANCED_DETECTOR_FIND_GAMEID(gameid,list,obsoleteList); \
 	} \
-	DetectedGameList Engine_##engine##_detectGames(const FSList &fslist) { \
+	GameList Engine_##engine##_detectGames(const FSList &fslist) { \
 		return detectFunc(fslist);						\
 	} \
 	PluginError Engine_##engine##_create(OSystem *syst, Engine **engine) { \

Modified: scummvm/trunk/engines/agi/detection.cpp
===================================================================
--- scummvm/trunk/engines/agi/detection.cpp	2007-01-20 18:27:22 UTC (rev 25133)
+++ scummvm/trunk/engines/agi/detection.cpp	2007-01-20 21:27:57 UTC (rev 25134)
@@ -31,7 +31,7 @@
 
 
 namespace Agi {
-static DetectedGameList GAME_detectGames(const FSList &fslist);
+static GameList GAME_detectGames(const FSList &fslist);
 }
 
 static const PlainGameDescriptor agiGames[] = {
@@ -958,7 +958,7 @@
 	return true;
 }
 
-DetectedGameList GAME_detectGames(const FSList &fslist) {
+GameList GAME_detectGames(const FSList &fslist) {
 	return Common::ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
 		fslist,
 		(const byte *)gameDescriptions,

Modified: scummvm/trunk/engines/agos/game.cpp
===================================================================
--- scummvm/trunk/engines/agos/game.cpp	2007-01-20 18:27:22 UTC (rev 25133)
+++ scummvm/trunk/engines/agos/game.cpp	2007-01-20 21:27:57 UTC (rev 25134)
@@ -32,7 +32,7 @@
 #include "agos/agos.h"
 
 namespace AGOS {
-static DetectedGameList GAME_detectGames(const FSList &fslist);
+static GameList GAME_detectGames(const FSList &fslist);
 }
 
 /**
@@ -88,7 +88,7 @@
 	return true;
 }
 
-DetectedGameList GAME_detectGames(const FSList &fslist) {
+GameList GAME_detectGames(const FSList &fslist) {
 	return Common::ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
 		fslist,
 		(const byte *)gameDescriptions,

Modified: scummvm/trunk/engines/cine/detection.cpp
===================================================================
--- scummvm/trunk/engines/cine/detection.cpp	2007-01-20 18:27:22 UTC (rev 25133)
+++ scummvm/trunk/engines/cine/detection.cpp	2007-01-20 21:27:57 UTC (rev 25134)
@@ -32,7 +32,7 @@
 #include "cine/cine.h"
 
 namespace Cine {
-static DetectedGameList GAME_detectGames(const FSList &fslist);
+static GameList GAME_detectGames(const FSList &fslist);
 }
 
 static const PlainGameDescriptor cineGames[] = {
@@ -433,7 +433,7 @@
 	return true;
 }
 
-DetectedGameList GAME_detectGames(const FSList &fslist) {
+GameList GAME_detectGames(const FSList &fslist) {
 	return Common::ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
 		fslist,
 		(const byte *)gameDescriptions,

Modified: scummvm/trunk/engines/gob/gob.cpp
===================================================================
--- scummvm/trunk/engines/gob/gob.cpp	2007-01-20 18:27:22 UTC (rev 25133)
+++ scummvm/trunk/engines/gob/gob.cpp	2007-01-20 21:27:57 UTC (rev 25134)
@@ -813,11 +813,11 @@
 			break;
 		g++;
 	}
-	return *g;
+	return GameDescriptor(g->gameid, g->description);
 }
 
-DetectedGameList Engine_GOB_detectGames(const FSList &fslist) {
-	DetectedGameList detectedGames;
+GameList Engine_GOB_detectGames(const FSList &fslist) {
+	GameList detectedGames;
 	const GameSettings *g;
 	FSList::const_iterator file;
 
@@ -843,7 +843,7 @@
 		}
 		for (g = gob_games; g->gameid; g++) {
 			if (strcmp(g->md5sum, (char *)md5str) == 0) {
-				detectedGames.push_back(DetectedGame(g->gameid, g->description));
+				detectedGames.push_back(GameDescriptor(g->gameid, g->description));
 			}
 		}
 		if (detectedGames.empty()) {

Modified: scummvm/trunk/engines/kyra/plugin.cpp
===================================================================
--- scummvm/trunk/engines/kyra/plugin.cpp	2007-01-20 18:27:22 UTC (rev 25133)
+++ scummvm/trunk/engines/kyra/plugin.cpp	2007-01-20 21:27:57 UTC (rev 25134)
@@ -140,7 +140,7 @@
 	return Common::ADVANCED_DETECTOR_FIND_GAMEID(gameid, gameList, 0);
 }
 
-DetectedGameList Engine_KYRA_detectGames(const FSList &fslist) {
+GameList Engine_KYRA_detectGames(const FSList &fslist) {
 	return Common::ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
 		fslist,
 		(const byte *)adGameDescs,

Modified: scummvm/trunk/engines/lure/lure.cpp
===================================================================
--- scummvm/trunk/engines/lure/lure.cpp	2007-01-20 18:27:22 UTC (rev 25133)
+++ scummvm/trunk/engines/lure/lure.cpp	2007-01-20 21:27:57 UTC (rev 25134)
@@ -103,11 +103,11 @@
 			break;
 		g++;
 	}
-	return *g;
+	return GameDescriptor(g->gameid, g->description);
 }
 
-DetectedGameList Engine_LURE_detectGames(const FSList &fslist) {
-	DetectedGameList detectedGames;
+GameList Engine_LURE_detectGames(const FSList &fslist) {
+	GameList detectedGames;
 	const GameSettings *g;
 	FSList::const_iterator file;
 
@@ -137,7 +137,7 @@
 		}
 		for (g = lure_games; g->gameid; g++) {
 			if (strcmp(g->md5sum, (char *)md5str) == 0) {
-				DetectedGame dg(*g, g->language);
+				GameDescriptor dg(g->gameid, g->description, g->language);
 				dg.updateDesc((g->features & GF_FLOPPY) ? "Floppy" : 0);
 				detectedGames.push_back(dg);
 			}

Modified: scummvm/trunk/engines/parallaction/detection.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/detection.cpp	2007-01-20 18:27:22 UTC (rev 25133)
+++ scummvm/trunk/engines/parallaction/detection.cpp	2007-01-20 21:27:57 UTC (rev 25134)
@@ -30,7 +30,7 @@
 #include "parallaction/parallaction.h"
 
 namespace Parallaction {
-static DetectedGameList GAME_detectGames(const FSList &fslist);
+static GameList GAME_detectGames(const FSList &fslist);
 }
 
 static const PlainGameDescriptor parallactionGames[] = {
@@ -84,7 +84,7 @@
 	return true;
 }
 
-DetectedGameList GAME_detectGames(const FSList &fslist) {
+GameList GAME_detectGames(const FSList &fslist) {
 	return Common::ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
 		fslist,
 		(const byte *)gameDescriptions,

Modified: scummvm/trunk/engines/queen/queen.cpp
===================================================================
--- scummvm/trunk/engines/queen/queen.cpp	2007-01-20 18:27:22 UTC (rev 25133)
+++ scummvm/trunk/engines/queen/queen.cpp	2007-01-20 21:27:57 UTC (rev 25134)
@@ -65,8 +65,8 @@
 	return GameDescriptor();
 }
 
-DetectedGameList Engine_QUEEN_detectGames(const FSList &fslist) {
-	DetectedGameList detectedGames;
+GameList Engine_QUEEN_detectGames(const FSList &fslist) {
+	GameList detectedGames;
 
 	// Iterate over all files in the given directory
 	for (FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
@@ -80,7 +80,7 @@
 			}
 			Queen::DetectedGameVersion version;
 			if (Queen::Resource::detectVersion(&version, &dataFile)) {
-				DetectedGame dg(queenGameDescriptor, version.language, Common::kPlatformPC);
+				GameDescriptor dg(queenGameDescriptor.gameid, queenGameDescriptor.description, version.language, Common::kPlatformPC);
 				if (version.features & Queen::GF_DEMO) {
 					dg.updateDesc("Demo");
 				} else if (version.features & Queen::GF_INTERVIEW) {

Modified: scummvm/trunk/engines/saga/game.cpp
===================================================================
--- scummvm/trunk/engines/saga/game.cpp	2007-01-20 18:27:22 UTC (rev 25133)
+++ scummvm/trunk/engines/saga/game.cpp	2007-01-20 21:27:57 UTC (rev 25134)
@@ -39,7 +39,7 @@
 
 
 namespace Saga {
-static DetectedGameList GAME_detectGames(const FSList &fslist);
+static GameList GAME_detectGames(const FSList &fslist);
 }
 
 static const PlainGameDescriptor saga_games[] = {
@@ -73,7 +73,7 @@
 	return _resource->createContexts();
 }
 
-DetectedGameList GAME_detectGames(const FSList &fslist) {
+GameList GAME_detectGames(const FSList &fslist) {
 	return Common::ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
 		fslist,
 		(const byte *)gameDescriptions,

Modified: scummvm/trunk/engines/scumm/plugin.cpp
===================================================================
--- scummvm/trunk/engines/scumm/plugin.cpp	2007-01-20 18:27:22 UTC (rev 25133)
+++ scummvm/trunk/engines/scumm/plugin.cpp	2007-01-20 21:27:57 UTC (rev 25134)
@@ -1360,8 +1360,8 @@
 	const ObsoleteGameID *o = obsoleteGameIDsTable;
 	while (o->from) {
 		if (0 == scumm_stricmp(gameid, o->from)) {
-			gs.gameid = gameid;
-			gs.description = "Obsolete game ID";
+			gs["gameid"] = gameid;
+			gs["description"] = "Obsolete game ID";
 			return gs;
 		}
 		o++;
@@ -1370,15 +1370,15 @@
 }
 
 
-DetectedGameList Engine_SCUMM_detectGames(const FSList &fslist) {
-	DetectedGameList detectedGames;
+GameList Engine_SCUMM_detectGames(const FSList &fslist) {
+	GameList detectedGames;
 	Common::List<DetectorResult> results;
 
 	detectGames(fslist, results, 0);
 	
 	
 	for (Common::List<DetectorResult>::iterator x = results.begin(); x != results.end(); ++x) {
-		DetectedGame dg(x->game.gameid, findDescriptionFromGameID(x->game.gameid),
+		GameDescriptor dg(x->game.gameid, findDescriptionFromGameID(x->game.gameid),
 				x->language, x->game.platform);
 		dg.updateDesc(x->extra);	// Append additional information, if set, to the description.
 		detectedGames.push_back(dg);

Modified: scummvm/trunk/engines/sky/sky.cpp
===================================================================
--- scummvm/trunk/engines/sky/sky.cpp	2007-01-20 18:27:22 UTC (rev 25133)
+++ scummvm/trunk/engines/sky/sky.cpp	2007-01-20 21:27:57 UTC (rev 25134)
@@ -110,8 +110,8 @@
 	{ 0, 0, 0, 0 }
 };
 
-DetectedGameList Engine_SKY_detectGames(const FSList &fslist) {
-	DetectedGameList detectedGames;
+GameList Engine_SKY_detectGames(const FSList &fslist) {
+	GameList detectedGames;
 	bool hasSkyDsk = false;
 	bool hasSkyDnr = false;
 	int dinnerTableEntries = -1;
@@ -144,7 +144,7 @@
 		// Match found, add to list of candidates, then abort inner loop.
 		// The game detector uses US English by default. We want British
 		// English to match the recorded voices better.
-		DetectedGame dg(skySetting, Common::UNK_LANG, Common::kPlatformUnknown);
+		GameDescriptor dg(skySetting.gameid, skySetting.description, Common::UNK_LANG, Common::kPlatformUnknown);
 		const SkyVersion *sv = skyVersions;
 		while (sv->dinnerTableEntries) {
 			if (dinnerTableEntries == sv->dinnerTableEntries &&

Modified: scummvm/trunk/engines/sword1/sword1.cpp
===================================================================
--- scummvm/trunk/engines/sword1/sword1.cpp	2007-01-20 18:27:22 UTC (rev 25133)
+++ scummvm/trunk/engines/sword1/sword1.cpp	2007-01-20 21:27:57 UTC (rev 25134)
@@ -118,9 +118,9 @@
 	}
 }
 
-DetectedGameList Engine_SWORD1_detectGames(const FSList &fslist) {
+GameList Engine_SWORD1_detectGames(const FSList &fslist) {
 	int i, j;
-	DetectedGameList detectedGames;
+	GameList detectedGames;
 	bool filesFound[NUM_FILES_TO_CHECK];
 	for (i = 0; i < NUM_FILES_TO_CHECK; i++)
 		filesFound[i] = false;

Modified: scummvm/trunk/engines/sword2/sword2.cpp
===================================================================
--- scummvm/trunk/engines/sword2/sword2.cpp	2007-01-20 18:27:22 UTC (rev 25133)
+++ scummvm/trunk/engines/sword2/sword2.cpp	2007-01-20 21:27:57 UTC (rev 25134)
@@ -65,7 +65,7 @@
 	const Sword2::GameSettings *g = Sword2::sword2_settings;
 	GameList games;
 	while (g->gameid) {
-		games.push_back(*g);
+		games.push_back(GameDescriptor(g->gameid, g->description));
 		g++;
 	}
 	return games;
@@ -78,11 +78,11 @@
 			break;
 		g++;
 	}
-	return *g;
+	return GameDescriptor(g->gameid, g->description);
 }
 
-DetectedGameList Engine_SWORD2_detectGames(const FSList &fslist) {
-	DetectedGameList detectedGames;
+GameList Engine_SWORD2_detectGames(const FSList &fslist) {
+	GameList detectedGames;
 	const Sword2::GameSettings *g;
 
 	// TODO: It would be nice if we had code here which distinguishes
@@ -97,7 +97,7 @@
 
 				if (0 == scumm_stricmp(g->detectname, fileName)) {
 					// Match found, add to list of candidates, then abort inner loop.
-					detectedGames.push_back(*g);
+					detectedGames.push_back(GameDescriptor(g->gameid, g->description));
 					break;
 				}
 			}
@@ -118,10 +118,10 @@
 
 	// Invoke the detector
 	Common::String gameid = ConfMan.get("gameid");
-	DetectedGameList detectedGames = Engine_SWORD2_detectGames(fslist);
+	GameList detectedGames = Engine_SWORD2_detectGames(fslist);
 
 	for (uint i = 0; i < detectedGames.size(); i++) {
-		if (detectedGames[i].gameid == gameid) {
+		if (detectedGames[i].gameid() == gameid) {
 			*engine = new Sword2::Sword2Engine(syst);
 			return kNoError;
 		}

Modified: scummvm/trunk/engines/touche/plugin.cpp
===================================================================
--- scummvm/trunk/engines/touche/plugin.cpp	2007-01-20 18:27:22 UTC (rev 25133)
+++ scummvm/trunk/engines/touche/plugin.cpp	2007-01-20 21:27:57 UTC (rev 25134)
@@ -123,7 +123,7 @@
 	return GameDescriptor();
 }
 
-DetectedGameList Engine_TOUCHE_detectGames(const FSList &fslist) {
+GameList Engine_TOUCHE_detectGames(const FSList &fslist) {
 	bool foundFile = false;
 	FSList::const_iterator file;
 	for (file = fslist.begin(); file != fslist.end(); ++file) {
@@ -140,7 +140,7 @@
 			break;
 		}
 	}
-	DetectedGameList detectedGames;
+	GameList detectedGames;
 	if (foundFile) {
 		// Currently, the detection code is based on a MD5 checksum. If all known versions
 		// have a different file size for TOUCHE.DAT, we may consider using this to do the
@@ -150,7 +150,7 @@
 			for (int i = 0; i < ARRAYSIZE(toucheGameVersionsTable); ++i) {
 				const GameVersion *gv = &toucheGameVersionsTable[i];
 				if (md5digest.equalsIgnoreCase(gv->md5digest)) {
-					DetectedGame dg(toucheGameDescriptor.gameid, gv->description, gv->language, gv->platform);
+					GameDescriptor dg(toucheGameDescriptor.gameid, gv->description, gv->language, gv->platform);
 					detectedGames.push_back(dg);
 					break;
 				}
@@ -172,12 +172,12 @@
 	if (!dir.listDir(fslist, FilesystemNode::kListFilesOnly)) {
 		return kInvalidPathError;
 	}
-	DetectedGameList game = Engine_TOUCHE_detectGames(fslist);
+	GameList game = Engine_TOUCHE_detectGames(fslist);
 	if (game.size() != 1) {
 		return kNoGameDataFoundError;
 	}
 	assert(engine);
-	*engine = new Touche::ToucheEngine(system, game[0].language);
+	*engine = new Touche::ToucheEngine(system, game[0].language());
 	return kNoError;
 }
 

Modified: scummvm/trunk/gui/launcher.cpp
===================================================================
--- scummvm/trunk/gui/launcher.cpp	2007-01-20 18:27:22 UTC (rev 25133)
+++ scummvm/trunk/gui/launcher.cpp	2007-01-20 21:27:57 UTC (rev 25134)
@@ -573,8 +573,8 @@
 			gameid = iter->_key;
 		if (description.empty()) {
 			GameDescriptor g = Base::findGame(gameid);
-			if (!g.description.empty())
-				description = g.description;
+			if (g.contains("description"))
+				description = g.description();
 		}
 
 		if (!gameid.empty() && !description.empty()) {
@@ -606,14 +606,14 @@
 	}
 
 	// Run the detector on the dir
-	DetectedGameList candidates(PluginManager::instance().detectGames(files));
+	GameList candidates(PluginManager::instance().detectGames(files));
 	
 	if (candidates.size() >= 1) {
 		// At least one match was found. For now we just take the first one...
 		// a more sophisticated solution would do something more clever here,
 		// e.g. ask the user which one to pick (make sure to display the 
 		// path, too).
-		DetectedGame result = candidates[0];
+		GameDescriptor result = candidates[0];
 		addGameToConf(dir, result, true);
 	}
 	
@@ -661,7 +661,7 @@
 
 		// ...so let's determine a list of candidates, games that
 		// could be contained in the specified directory.
-		DetectedGameList candidates(PluginManager::instance().detectGames(files));
+		GameList candidates(PluginManager::instance().detectGames(files));
 
 		int idx;
 		if (candidates.empty()) {
@@ -676,32 +676,32 @@
 			// Display the candidates to the user and let her/him pick one
 			StringList list;
 			for (idx = 0; idx < (int)candidates.size(); idx++)
-				list.push_back(candidates[idx].description);
+				list.push_back(candidates[idx].description());
 
 			ChooserDialog dialog("Pick the game:");
 			dialog.setList(list);
 			idx = dialog.runModal();
 		}
 		if (0 <= idx && idx < (int)candidates.size()) {
-			DetectedGame result = candidates[idx];
+			GameDescriptor result = candidates[idx];
 			addGameToConf(dir, result, false);
 		}
 	}
 }
 
 
-void LauncherDialog::addGameToConf(FilesystemNode dir, DetectedGame result, bool suppressEditDialog) {
+void LauncherDialog::addGameToConf(FilesystemNode dir, GameDescriptor result, bool suppressEditDialog) {
 	// The auto detector or the user made a choice.
 	// Pick a domain name which does not yet exist (after all, we
 	// are *adding* a game to the config, not replacing).
-	String domain(result.gameid);
+	String domain(result.gameid());
 	if (ConfMan.hasGameDomain(domain)) {
 		int suffixN = 1;
 		char suffix[16];
 
 		while (ConfMan.hasGameDomain(domain)) {
 			snprintf(suffix, 16, "-%d", suffixN);
-			domain = result.gameid + suffix;
+			domain = result.gameid() + suffix;
 			suffixN++;
 		}
 	}
@@ -718,23 +718,23 @@
 	// game target, we can change this (currently, you can only query
 	// for the generic gameid description; it's not possible to obtain
 	// a description which contains extended information like language, etc.).
-	ConfMan.set("description", result.description, domain);
+	ConfMan.set("description", result.description(), domain);
 
-	ConfMan.set("gameid", result.gameid, domain);
+	ConfMan.set("gameid", result.gameid(), domain);
 	ConfMan.set("path", dir.path(), domain);
 
 	// Set language if specified
-	if (result.language != Common::UNK_LANG)
-		ConfMan.set("language", Common::getLanguageCode(result.language), domain);
+	if (result.language() != Common::UNK_LANG)
+		ConfMan.set("language", Common::getLanguageCode(result.language()), domain);
 
 	// Set platform if specified
-	if (result.platform != Common::kPlatformUnknown)
-		ConfMan.set("platform", Common::getPlatformCode(result.platform), domain);
+	if (result.platform() != Common::kPlatformUnknown)
+		ConfMan.set("platform", Common::getPlatformCode(result.platform()), domain);
 
 	// Display edit dialog for the new entry
 	bool saveit = true;
 	if (!suppressEditDialog) {
-		EditGameDialog editDialog(domain, result.description);
+		EditGameDialog editDialog(domain, result.description());
 		saveit = (editDialog.runModal() > 0);
 	}
 	if (saveit) {
@@ -781,7 +781,7 @@
 	String gameId(ConfMan.get("gameid", _domains[item]));
 	if (gameId.empty())
 		gameId = _domains[item];
-	EditGameDialog editDialog(_domains[item], Base::findGame(gameId).description);
+	EditGameDialog editDialog(_domains[item], Base::findGame(gameId).description());
 	if (editDialog.runModal() > 0) {
 		// User pressed OK, so make changes permanent
 

Modified: scummvm/trunk/gui/launcher.h
===================================================================
--- scummvm/trunk/gui/launcher.h	2007-01-20 18:27:22 UTC (rev 25133)
+++ scummvm/trunk/gui/launcher.h	2007-01-20 21:27:57 UTC (rev 25134)
@@ -68,7 +68,7 @@
 
 	void selectGame(const String &name);
 	
-	void addGameToConf(FilesystemNode dir, DetectedGame result, bool suppressEditDialog);
+	void addGameToConf(FilesystemNode dir, GameDescriptor result, bool suppressEditDialog);
 	void addGameRecursive(FilesystemNode dir);
 };
 


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