From 2c9968fe80c4ba78f895c9bac757dd6b1604ccce Mon Sep 17 00:00:00 2001 From: Jordi Vilalta Prat Date: Mon, 12 May 2008 00:26:29 +0000 Subject: - Added an engine plugin manager and moved engine specific functionality into it - base/plugins.* reorganization svn-id: r32045 --- base/main.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'base/main.cpp') diff --git a/base/main.cpp b/base/main.cpp index 9129fcc7e1..80f77f89ab 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -77,8 +77,8 @@ static bool launcherDialog(OSystem &system) { return (dlg.runModal() != -1); } -static const Plugin *detectPlugin() { - const Plugin *plugin = 0; +static const EnginePlugin *detectPlugin() { + const EnginePlugin *plugin = 0; // Make sure the gameid is set in the config manager, and that it is lowercase. Common::String gameid(ConfMan.getActiveDomainName()); @@ -90,7 +90,7 @@ static const Plugin *detectPlugin() { // 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); + GameDescriptor game = EngineMan.findGame(gameid, &plugin); if (plugin == 0) { printf("Failed game detection\n"); @@ -105,7 +105,7 @@ static const Plugin *detectPlugin() { } // TODO: specify the possible return values here -static int runGame(const Plugin *plugin, OSystem &system, const Common::String &edebuglevels) { +static int runGame(const EnginePlugin *plugin, OSystem &system, const Common::String &edebuglevels) { Common::String gameDataPath(ConfMan.get("path")); if (gameDataPath.empty()) { } else if (gameDataPath.lastChar() != '/' @@ -168,7 +168,7 @@ static int runGame(const Plugin *plugin, OSystem &system, const Common::String & // 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 = EngineMan.findGame(ConfMan.get("gameid")).description(); if (caption.empty() && !desc.empty()) caption = desc; if (caption.empty()) @@ -298,7 +298,7 @@ extern "C" int scummvm_main(int argc, char *argv[]) { // cleanly, so this is now enabled to encourage people to fix bits :) while (0 != ConfMan.getActiveDomain()) { // Try to find a plugin which feels responsible for the specified game. - const Plugin *plugin = detectPlugin(); + const EnginePlugin *plugin = detectPlugin(); if (plugin) { // Unload all plugins not needed for this game, // to save memory -- cgit v1.2.3 From 9ba353b9d8f6c4336ca4b6001fe5f22b85a8fb81 Mon Sep 17 00:00:00 2001 From: Jordi Vilalta Prat Date: Mon, 12 May 2008 01:26:43 +0000 Subject: Keep separated arrays for each type of plugin svn-id: r32046 --- base/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'base/main.cpp') diff --git a/base/main.cpp b/base/main.cpp index 80f77f89ab..8b697e120d 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -302,7 +302,7 @@ extern "C" int scummvm_main(int argc, char *argv[]) { if (plugin) { // Unload all plugins not needed for this game, // to save memory - PluginManager::instance().unloadPluginsExcept(plugin); + PluginManager::instance().unloadPluginsExcept(PLUGIN_TYPE_ENGINE, plugin); // Try to run the game int result = runGame(plugin, system, specialDebug); @@ -329,7 +329,7 @@ extern "C" int scummvm_main(int argc, char *argv[]) { launcherDialog(system); } - PluginManager::instance().unloadPluginsExcept(NULL); + PluginManager::instance().unloadPlugins(); PluginManager::destroy(); Common::ConfigManager::destroy(); GUI::NewGui::destroy(); -- cgit v1.2.3 From fe58f0ee4b9d91f4ed349bafb16d2a8d6fb59faa Mon Sep 17 00:00:00 2001 From: Jordi Vilalta Prat Date: Tue, 13 May 2008 09:30:23 +0000 Subject: - Added operator-> to Plugin subclasses so they don't have to reimplement the PluginObject subclass interfaces (thanks to Fingolfin for suggesting it) - Added the PluginSubclass template to help creating Plugin subclasses svn-id: r32082 --- base/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'base/main.cpp') diff --git a/base/main.cpp b/base/main.cpp index 8b697e120d..c36c506d7f 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -32,6 +32,7 @@ */ #include "engines/engine.h" +#include "engines/metaengine.h" #include "base/commandLine.h" #include "base/plugins.h" #include "base/version.h" @@ -138,7 +139,7 @@ static int runGame(const EnginePlugin *plugin, OSystem &system, const Common::St // Create the game engine Engine *engine = 0; - PluginError err = plugin->createInstance(&system, &engine); + PluginError err = (*plugin)->createInstance(&system, &engine); if (!engine || err != kNoError) { // TODO: Show an error dialog or so? // TODO: Also take 'err' into consideration... -- cgit v1.2.3