From 44d7414215f5754f36be423aaf2c54236638d82f Mon Sep 17 00:00:00 2001 From: Tony Puccinelli Date: Mon, 2 Aug 2010 08:43:47 +0000 Subject: changed plugins so games can be added in the launcher with only one plugin loaded into memory at a time (first refinement) svn-id: r51607 --- base/plugins.cpp | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'base/plugins.cpp') diff --git a/base/plugins.cpp b/base/plugins.cpp index e0ab85babb..c20fdd8a3e 100644 --- a/base/plugins.cpp +++ b/base/plugins.cpp @@ -306,7 +306,8 @@ void PluginManager::addPluginProvider(PluginProvider *pp) { _providers.push_back(pp); } -bool PluginManager::loadFirstPlugin() { +bool PluginManager::loadFirstPlugin() { //TODO: only deal with engine plugins here, and have a separate "loadNonEnginePlugins" function. + unloadPluginsExcept(PLUGIN_TYPE_ENGINE, NULL); PluginList plugs; for (ProviderList::iterator pp = _providers.begin(); pp != _providers.end(); @@ -316,14 +317,17 @@ bool PluginManager::loadFirstPlugin() { plugs.push_back(*p); } } + _allPlugsEnd = plugs.end(); _allPlugs = plugs.begin(); - return tryLoadPlugin(*_allPlugs); //TODO: return false if no plugins! + if (plugs.empty()) return false; //return false if there are no plugins to load. + return tryLoadPlugin(*_allPlugs); } bool PluginManager::loadNextPlugin() { unloadPluginsExcept(PLUGIN_TYPE_ENGINE, NULL); ++_allPlugs; - return tryLoadPlugin(*_allPlugs); //TODO: return false if got to the end of list of plugins. + if (_allPlugs == _allPlugsEnd) return false; //return false if already reached the end of list of plugins. + return tryLoadPlugin(*_allPlugs); } void PluginManager::loadPlugins() { @@ -424,15 +428,22 @@ GameDescriptor EngineManager::findGame(const Common::String &gameName, const Eng GameList EngineManager::detectGames(const Common::FSList &fslist) const { GameList candidates; - - const EnginePlugin::List &plugins = getPlugins(); - - // Iterate over all known games and for each check if it might be - // the game in the presented directory. - EnginePlugin::List::const_iterator iter; - for (iter = plugins.begin(); iter != plugins.end(); ++iter) { - candidates.push_back((**iter)->detectGames(fslist)); - } + EnginePlugin::List plugins; +#ifdef NEW_PLUGIN_DESIGN_FIRST_REFINEMENT + PluginManager::instance().loadFirstPlugin(); + do { +#endif + printf("SUCCESS!!!\n"); + plugins = getPlugins(); + // Iterate over all known games and for each check if it might be + // the game in the presented directory. + EnginePlugin::List::const_iterator iter; + for (iter = plugins.begin(); iter != plugins.end(); ++iter) { + candidates.push_back((**iter)->detectGames(fslist)); + } +#ifdef NEW_PLUGIN_DESIGN_FIRST_REFINEMENT + } while (PluginManager::instance().loadNextPlugin()); +#endif return candidates; } -- cgit v1.2.3