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

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sat Apr 15 09:38:03 CEST 2006


Revision: 21913
Author:   fingolfin
Date:     2006-04-15 09:37:48 -0700 (Sat, 15 Apr 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=21913&view=rev

Log Message:
-----------
Removed GameDetector::createMixer(), GameDetector::createEngine(), GameDetector::_plugin

Modified Paths:
--------------
    scummvm/trunk/base/engine.cpp
    scummvm/trunk/base/gameDetector.cpp
    scummvm/trunk/base/gameDetector.h
    scummvm/trunk/base/main.cpp
Modified: scummvm/trunk/base/engine.cpp
===================================================================
--- scummvm/trunk/base/engine.cpp	2006-04-15 14:25:41 UTC (rev 21912)
+++ scummvm/trunk/base/engine.cpp	2006-04-15 16:37:48 UTC (rev 21913)
@@ -39,7 +39,7 @@
 Engine::Engine(OSystem *syst)
 	: _system(syst), _gameDataPath(ConfMan.get("path")) {
 	g_engine = this;
-	_mixer = GameDetector::createMixer();
+	_mixer = new Audio::Mixer();
 
 	_timer = Common::g_timer;
 

Modified: scummvm/trunk/base/gameDetector.cpp
===================================================================
--- scummvm/trunk/base/gameDetector.cpp	2006-04-15 14:25:41 UTC (rev 21912)
+++ scummvm/trunk/base/gameDetector.cpp	2006-04-15 16:37:48 UTC (rev 21913)
@@ -248,8 +248,6 @@
 	ConfMan.registerDefault("savepath", savePath); // this should be enough...
 #endif
 #endif // #ifdef DEFAULT_SAVE_PATH
-
-	_plugin = 0;
 }
 
 GameDescriptor GameDetector::findGame(const String &gameName, const Plugin **plugin) {
@@ -257,6 +255,9 @@
 	const PluginList &plugins = PluginManager::instance().getPlugins();
 	GameDescriptor result;
 
+	if (plugin)
+		plugin = 0;
+
 	PluginList::const_iterator iter = plugins.begin();
 	for (iter = plugins.begin(); iter != plugins.end(); ++iter) {
 		result = (*iter)->findGame(gameName.c_str());
@@ -590,19 +591,21 @@
 	//ConfMan.set("gameid", _gameid, Common::ConfigManager::kTransientDomain);
 }
 
-bool GameDetector::detectMain() {
+const Plugin *GameDetector::detectMain() {
+	const Plugin *plugin = 0;
+	
 	if (_targetName.empty()) {
 		warning("No game was specified...");
-		return false;
+		return 0;
 	}
 
 	printf("Looking for %s\n", _gameid.c_str());
-	GameDescriptor game = findGame(_gameid, &_plugin);
+	GameDescriptor game = findGame(_gameid, &plugin);
 
-	if (game.gameid.size() == 0) {
+	if (plugin == 0) {
 		printf("Failed game detection\n");
 		warning("%s is an invalid target. Use the --list-targets option to list targets", _targetName.c_str());
-		return false;
+		return 0;
 	}
 
 	printf("Trying to start game '%s'\n", game.description.c_str());
@@ -620,14 +623,5 @@
 		ConfMan.set("path", gameDataPath, Common::ConfigManager::kTransientDomain);
 	}
 
-	return true;
+	return plugin;
 }
-
-Engine *GameDetector::createEngine(OSystem *sys) {
-	assert(_plugin);
-	return _plugin->createInstance(this, sys);
-}
-
-Audio::Mixer *GameDetector::createMixer() {
-	return new Audio::Mixer();
-}

Modified: scummvm/trunk/base/gameDetector.h
===================================================================
--- scummvm/trunk/base/gameDetector.h	2006-04-15 14:25:41 UTC (rev 21912)
+++ scummvm/trunk/base/gameDetector.h	2006-04-15 16:37:48 UTC (rev 21913)
@@ -27,13 +27,9 @@
 #include "common/str.h"
 #include "common/config-manager.h"
 
-class Engine;
 class GameDetector;
 class OSystem;
 class Plugin;
-namespace Audio {
-	class Mixer;
-}
 
 struct PlainGameDescriptor {
 	const char *gameid;
@@ -71,18 +67,12 @@
 
 	static Common::String parseCommandLine(Common::StringMap &settings, int argc, char **argv);
 	void processSettings(Common::String &target, Common::StringMap &settings);
-	bool detectMain();
+	const Plugin *detectMain();
 
 	String _targetName;
 	String _gameid;
 
-	const Plugin *_plugin;	// TODO: This should be protected
-
 public:
-	Engine *createEngine(OSystem *system);
-
-	static Audio::Mixer *createMixer();
-
 	static GameDescriptor findGame(const String &gameName, const Plugin **plugin = NULL);
 
 //protected:

Modified: scummvm/trunk/base/main.cpp
===================================================================
--- scummvm/trunk/base/main.cpp	2006-04-15 14:25:41 UTC (rev 21912)
+++ scummvm/trunk/base/main.cpp	2006-04-15 16:37:48 UTC (rev 21913)
@@ -157,7 +157,7 @@
 	return (dlg.runModal() != -1);
 }
 
-static int runGame(GameDetector &detector, OSystem &system, const Common::String &edebuglevels) {
+static int runGame(const Plugin *plugin, GameDetector &detector, OSystem &system, const Common::String &edebuglevels) {
 	// We add it here, so MD5-based detection will be able to
 	// read mixed case files
 	if (ConfMan.hasKey("path"))
@@ -166,7 +166,7 @@
 		Common::File::addDefaultDirectory(".");
 
 	// Create the game engine
-	Engine *engine = detector.createEngine(&system);
+	Engine *engine = plugin->createInstance(&detector, &system);
 	if (!engine) {
 		// TODO: Show an error dialog or so?
 		//GUI::MessageDialog alert("ScummVM could not find any game in the specified directory!");
@@ -329,12 +329,13 @@
 	// cleanly, so this is now enabled to encourage people to fix bits :)
 	while (running) {
 		// Verify the given game name is a valid supported game
-		if (detector.detectMain()) {
+		const Plugin *plugin = detector.detectMain();
+		if (plugin) {
 			// Unload all plugins not needed for this game,
 			// to save memory
-			PluginManager::instance().unloadPluginsExcept(detector._plugin);
+			PluginManager::instance().unloadPluginsExcept(plugin);
 
-			int result = runGame(detector, system, specialDebug);
+			int result = runGame(plugin, detector, system, specialDebug);
 			if (result == 0)
 				break;
 


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