[Scummvm-cvs-logs] SF.net SVN: scummvm: [27423] scummvm/trunk/base/main.cpp

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Fri Jun 15 19:31:57 CEST 2007


Revision: 27423
          http://scummvm.svn.sourceforge.net/scummvm/?rev=27423&view=rev
Author:   fingolfin
Date:     2007-06-15 10:29:49 -0700 (Fri, 15 Jun 2007)

Log Message:
-----------
BASE code: renamed detectMain to detectPlugin and updated some comments for clarity; added some TODO/FIXME comments; added a dialog that's shown if the user tries to start a game for which no plugin feels responsible

Modified Paths:
--------------
    scummvm/trunk/base/main.cpp

Modified: scummvm/trunk/base/main.cpp
===================================================================
--- scummvm/trunk/base/main.cpp	2007-06-15 17:13:13 UTC (rev 27422)
+++ scummvm/trunk/base/main.cpp	2007-06-15 17:29:49 UTC (rev 27423)
@@ -82,7 +82,7 @@
 	return (dlg.runModal() != -1);
 }
 
-static const Plugin *detectMain() {
+static const Plugin *detectPlugin() {
 	const Plugin *plugin = 0;
 
 	// Make sure the gameid is set in the config manager, and that it is lowercase.
@@ -109,6 +109,7 @@
 	return plugin;
 }
 
+// TODO: specify the possible return values here
 static int runGame(const Plugin *plugin, OSystem &system, const Common::String &edebuglevels) {
 	Common::String gameDataPath(ConfMan.get("path"));
 	if (gameDataPath.empty()) {
@@ -121,8 +122,11 @@
 		ConfMan.set("path", gameDataPath, Common::ConfigManager::kTransientDomain);
 	}
 
-	// We add it here, so MD5-based detection will be able to
-	// read mixed case files
+	// We add the game "path" to the file search path via File::addDefaultDirectory(),
+	// so that MD5-based detection will be able to properly find files with mixed case 
+	// filenames.
+	// FIXME/TODO: Fingolfin still doesn't like this; if those MD5-based detectors used
+	// FSNodes instead of File::open, they wouldn't have to do this.
 	Common::String path;
 	if (ConfMan.hasKey("path")) {
 		path = ConfMan.get("path");
@@ -201,12 +205,15 @@
 
 	int result;
 
-	// Init the engine (this might change the screen parameters
+	// Init the engine (this might change the screen parameters)
+	// TODO: We should specify what return values
 	result = engine->init();
 
 	// Run the game engine if the initialization was successful.
 	if (result == 0) {
 		result = engine->go();
+	} else {
+		// TODO: Set an error flag, notify user about the problem
 	}
 
 	// We clear all debug levels again even though the engine should do it
@@ -218,7 +225,7 @@
 	// Reset the file/directory mappings
 	Common::File::resetDefaultDirectories();
 
-	return result;
+	return 0;
 }
 
 
@@ -294,14 +301,18 @@
 	// work as well as it should. In theory everything should be destroyed
 	// cleanly, so this is now enabled to encourage people to fix bits :)
 	while (0 != ConfMan.getActiveDomain()) {
-		// Verify the given game name is a valid supported game
-		const Plugin *plugin = detectMain();
+		// Try to find a plugin which feels responsible for the specified game.
+		const Plugin *plugin = detectPlugin();
 		if (plugin) {
 			// Unload all plugins not needed for this game,
 			// to save memory
 			PluginManager::instance().unloadPluginsExcept(plugin);
 
+			// Try to run the game
 			int result = runGame(plugin, system, specialDebug);
+			// TODO: We should keep running if starting the selected game failed
+			// (so instead of just quitting, show a nice error dialog to the
+			// user and let him pick another game).
 			if (result == 0)
 				break;
 
@@ -314,6 +325,9 @@
 
 			// PluginManager::instance().unloadPlugins();
 			PluginManager::instance().loadPlugins();
+		} else {
+			GUI::MessageDialog alert("Could not find any engine capable of running the selected game!");
+			alert.runModal();
 		}
 
 		launcherDialog(system);


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