From dad44b45d31319625cf1f0bf884c856bee4205d5 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 5 May 2006 00:26:03 +0000 Subject: Removed Base::setTarget, and some minor cleanup & tweaks svn-id: r22356 --- base/game.h | 3 --- base/main.cpp | 43 +++++++++++++++++-------------------------- base/options.cpp | 2 +- 3 files changed, 18 insertions(+), 30 deletions(-) (limited to 'base') diff --git a/base/game.h b/base/game.h index 066781bdf6..cdafb2f2ca 100644 --- a/base/game.h +++ b/base/game.h @@ -61,9 +61,6 @@ namespace Base { // TODO: Find a better place for this function. GameDescriptor findGame(const Common::String &gameName, const Plugin **plugin = NULL); -// TODO: Find a better place for this function. -void setTarget(const Common::String &name); - } // End of namespace Base diff --git a/base/main.cpp b/base/main.cpp index cdf7a5ca87..01c2031fcc 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -84,18 +84,6 @@ GameDescriptor findGame(const Common::String &gameName, const Plugin **plugin) { return result; } -// TODO: Find a better place for this function. -void setTarget(const Common::String &target) { - ConfMan.setActiveDomain(target); - - // Make sure the gameid is set in the config manager, and that it is lowercase. - Common::String gameid(target); - if (ConfMan.hasKey("gameid")) - gameid = ConfMan.get("gameid"); - gameid.toLowercase(); - ConfMan.set("gameid", gameid); -} - } // End of namespace Base @@ -157,14 +145,18 @@ static bool launcherDialog(OSystem &system) { static const Plugin *detectMain() { const Plugin *plugin = 0; - - if (ConfMan.getActiveDomainName().empty()) { - warning("No game was specified..."); - return 0; - } - printf("Looking for %s\n", ConfMan.get("gameid").c_str()); - GameDescriptor game = Base::findGame(ConfMan.get("gameid"), &plugin); + // Make sure the gameid is set in the config manager, and that it is lowercase. + Common::String gameid(ConfMan.getActiveDomainName()); + assert(!gameid.empty()); + if (ConfMan.hasKey("gameid")) + gameid = ConfMan.get("gameid"); + gameid.toLowercase(); + ConfMan.set("gameid", gameid); + + // Query the plugins and find one that will handle the specified gameid + printf("Looking for %s\n", gameid.c_str()); + GameDescriptor game = Base::findGame(gameid, &plugin); if (plugin == 0) { printf("Failed game detection\n"); @@ -177,7 +169,6 @@ static const Plugin *detectMain() { Common::String gameDataPath(ConfMan.get("path")); if (gameDataPath.empty()) { warning("No path was provided. Assuming the data files are in the current directory"); - gameDataPath = "./"; } else if (gameDataPath.lastChar() != '/' #if defined(__MORPHOS__) || defined(__amigaos4__) && gameDataPath.lastChar() != ':' @@ -275,7 +266,6 @@ static int runGame(const Plugin *plugin, OSystem &system, const Common::String & extern "C" int scummvm_main(int argc, char *argv[]) { Common::String specialDebug; Common::String command; - bool running = true; // Verify that the backend has been initialized (i.e. g_system has been set). assert(g_system); @@ -348,8 +338,8 @@ extern "C" int scummvm_main(int argc, char *argv[]) { setupDummyPalette(system); // Unless a game was specified, show the launcher dialog - if (ConfMan.getActiveDomainName().empty()) { - running = launcherDialog(system); + if (0 == ConfMan.getActiveDomain()) { + launcherDialog(system); // Discard any command line options. Those that affect the graphics // mode etc. already have should have been handled by the backend at @@ -361,7 +351,7 @@ extern "C" int scummvm_main(int argc, char *argv[]) { // FIXME: We're now looping the launcher. This, of course, doesn't // 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 (running) { + while (0 != ConfMan.getActiveDomain()) { // Verify the given game name is a valid supported game const Plugin *plugin = detectMain(); if (plugin) { @@ -377,13 +367,14 @@ extern "C" int scummvm_main(int argc, char *argv[]) { // wanted to apply them to *all* games ever launched. ConfMan.getDomain(Common::ConfigManager::kTransientDomain)->clear(); - // TODO: Unset the active config domain + // Clear the active config domain + ConfMan.setActiveDomain(""); // PluginManager::instance().unloadPlugins(); PluginManager::instance().loadPlugins(); } - running = launcherDialog(system); + launcherDialog(system); } // Deinit the timer diff --git a/base/options.cpp b/base/options.cpp index ce6a3e3510..e01621af0a 100644 --- a/base/options.cpp +++ b/base/options.cpp @@ -665,7 +665,7 @@ bool processSettings(Common::String &command, Common::StringMap &settings) { // whether there is a gameid matching that name. if (!command.empty()) { if (ConfMan.hasGameDomain(command) || Base::findGame(command).gameid.size() > 0) { - Base::setTarget(command); + ConfMan.setActiveDomain(command); } else { usage("Unrecognized game target '%s'", command.c_str()); } -- cgit v1.2.3