[Scummvm-cvs-logs] CVS: scummvm/base plugins.h,1.14,1.15 plugins.cpp,1.24,1.25 gameDetector.h,1.22,1.23 gameDetector.cpp,1.57,1.58

Max Horn fingolfin at users.sourceforge.net
Sun Dec 21 07:30:05 CET 2003


Update of /cvsroot/scummvm/scummvm/base
In directory sc8-pr-cvs1:/tmp/cvs-serv13605/base

Modified Files:
	plugins.h plugins.cpp gameDetector.h gameDetector.cpp 
Log Message:
Make it possible for game detection functions to detect language/platform (not yet done by any detector, but will come with the MD5 detection code)

Index: plugins.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/base/plugins.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- plugins.h	16 Dec 2003 02:10:15 -0000	1.14
+++ plugins.h	21 Dec 2003 15:29:52 -0000	1.15
@@ -25,6 +25,7 @@
 
 #include "common/list.h"
 #include "common/singleton.h"
+#include "common/util.h"
 
 class Engine;
 class FSList;
@@ -32,10 +33,28 @@
 class OSystem;
 struct GameSettings;
 
-/** List of GameSettings- */
+/** List of games. */
 typedef Common::List<GameSettings> GameList;
 
 /**
+ * A detected game. Carries the GameSettings, but also (optionally)
+ * information about the language and platform of the detected game.
+ */
+struct DetectedGame : GameSettings {
+	Common::Language language;
+	Common::Platform platform;
+	DetectedGame() : language(Common::UNK_LANG), platform(Common::kPlatformUnknown) {}
+	DetectedGame(const GameSettings &game,
+	             Common::Language l = Common::UNK_LANG,
+	             Common::Platform p = Common::kPlatformUnknown)
+		: GameSettings(game), language(l), platform(p) {}
+};
+
+/** List of detected games. */
+typedef Common::List<DetectedGame> DetectedGameList;
+
+
+/**
  * Abstract base class for the plugin system.
  * Subclasses for this can be used to wrap both static and dynamic
  * plugins.
@@ -52,7 +71,7 @@
 	
 	virtual GameList getSupportedGames() const = 0;
 	virtual GameSettings findGame(const char *gameName) const;
-	virtual GameList detectGames(const FSList &fslist) const = 0;
+	virtual DetectedGameList detectGames(const FSList &fslist) const = 0;
 
 	virtual Engine *createInstance(GameDetector *detector, OSystem *syst) const = 0;
 };
@@ -75,7 +94,7 @@
 		const char *PLUGIN_name() { return name; } \
 		GameList PLUGIN_getSupportedGames() { return gameListFactory(); } \
 		Engine *PLUGIN_createEngine(GameDetector *detector, OSystem *syst) { return engineFactory(detector, syst); } \
-		GameList PLUGIN_detectGames(const FSList &fslist) { return detectGames(fslist); } \
+		DetectedGameList PLUGIN_detectGames(const FSList &fslist) { return detectGames(fslist); } \
 	}
 #endif
 
@@ -106,6 +125,8 @@
 	void unloadPlugins();
 	
 	const PluginList &getPlugins()	{ return _plugins; }
+
+	DetectedGameList detectGames(const FSList &fslist) const;
 };
 
 
@@ -114,7 +135,7 @@
 #define DECLARE_PLUGIN(name) \
 	extern GameList Engine_##name##_gameList(); \
 	extern Engine *Engine_##name##_create(GameDetector *detector, OSystem *syst); \
-	extern GameList Engine_##name##_detectGames(const FSList &fslist);
+	extern DetectedGameList Engine_##name##_detectGames(const FSList &fslist);
 
 // Factory functions => no need to include the specific classes
 // in this header. This serves two purposes:

Index: plugins.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/base/plugins.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- plugins.cpp	16 Dec 2003 02:10:15 -0000	1.24
+++ plugins.cpp	21 Dec 2003 15:29:52 -0000	1.25
@@ -32,7 +32,7 @@
 
 typedef const char *(*NameFunc)();
 typedef GameList (*TargetListFunc)();
-typedef GameList (*DetectFunc)(const FSList &fslist);
+typedef DetectedGameList (*DetectFunc)(const FSList &fslist);
 
 
 #ifdef DYNAMIC_MODULES
@@ -81,7 +81,7 @@
 	}
 
 	GameList getSupportedGames() const { return _games; }
-	GameList detectGames(const FSList &fslist) const {
+	DetectedGameList detectGames(const FSList &fslist) const {
 		return (*_df)(fslist);
 	}
 };
@@ -113,7 +113,7 @@
 	}
 
 	GameList getSupportedGames() const { return _games; }
-	GameList detectGames(const FSList &fslist) const {
+	DetectedGameList detectGames(const FSList &fslist) const {
 		assert(_df);
 		return (*_df)(fslist);
 	}
@@ -274,4 +274,17 @@
 		delete plugin;
 		return false;
 	}
+}
+
+DetectedGameList PluginManager::detectGames(const FSList &fslist) const {
+	DetectedGameList candidates;
+
+	// Iterate over all known games and for each check if it might be
+	// the game in the presented directory.
+	PluginList::ConstIterator iter;
+	for (iter = _plugins.begin(); iter != _plugins.end(); ++iter) {
+		candidates.push_back((*iter)->detectGames(fslist));
+	}
+	
+	return candidates;
 }

Index: gameDetector.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/base/gameDetector.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- gameDetector.h	13 Dec 2003 00:20:00 -0000	1.22
+++ gameDetector.h	21 Dec 2003 15:29:52 -0000	1.23
@@ -34,6 +34,8 @@
 
 /** Global (shared) game feature flags. */
 enum {
+//	GF_HAS_SPEECH = 1 << 29,
+//	GF_HAS_SUBTITLES = 1 << 30,
 	GF_DEFAULT_TO_1X_SCALER = 1 << 31
 };
 

Index: gameDetector.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/base/gameDetector.cpp,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- gameDetector.cpp	15 Dec 2003 15:10:33 -0000	1.57
+++ gameDetector.cpp	21 Dec 2003 15:29:52 -0000	1.58
@@ -158,7 +158,7 @@
 	ConfMan.registerDefault("platform", Common::kPlatformPC);
 	ConfMan.registerDefault("language", "en");
 //	ConfMan.registerDefault("nosubtitles", false);
-	ConfMan.registerDefault("subtitles", false);
+	ConfMan.registerDefault("subtitles", true);
 	ConfMan.registerDefault("boot_param", 0);
 	ConfMan.registerDefault("save_slot", -1);
 





More information about the Scummvm-git-logs mailing list