[Scummvm-cvs-logs] SF.net SVN: scummvm:[51607] scummvm/branches/gsoc2010-plugins/base

toneman1138 at users.sourceforge.net toneman1138 at users.sourceforge.net
Mon Aug 2 10:43:48 CEST 2010


Revision: 51607
          http://scummvm.svn.sourceforge.net/scummvm/?rev=51607&view=rev
Author:   toneman1138
Date:     2010-08-02 08:43:47 +0000 (Mon, 02 Aug 2010)

Log Message:
-----------
changed plugins so games can be added in the launcher with only one plugin loaded into memory at a time (first refinement)

Modified Paths:
--------------
    scummvm/branches/gsoc2010-plugins/base/plugins.cpp
    scummvm/branches/gsoc2010-plugins/base/plugins.h

Modified: scummvm/branches/gsoc2010-plugins/base/plugins.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/base/plugins.cpp	2010-08-02 08:36:33 UTC (rev 51606)
+++ scummvm/branches/gsoc2010-plugins/base/plugins.cpp	2010-08-02 08:43:47 UTC (rev 51607)
@@ -306,7 +306,8 @@
 	_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 @@
 			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,16 +428,23 @@
 
 GameList EngineManager::detectGames(const Common::FSList &fslist) const {
 	GameList candidates;
+	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
 
-	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));
-	}
-
 	return candidates;
 }
 

Modified: scummvm/branches/gsoc2010-plugins/base/plugins.h
===================================================================
--- scummvm/branches/gsoc2010-plugins/base/plugins.h	2010-08-02 08:36:33 UTC (rev 51606)
+++ scummvm/branches/gsoc2010-plugins/base/plugins.h	2010-08-02 08:43:47 UTC (rev 51607)
@@ -276,7 +276,9 @@
 	PluginList _plugins[PLUGIN_TYPE_MAX];
 	ProviderList _providers;
 	PluginList::iterator _allPlugs;
+	PluginList::iterator _allPlugsEnd;
 	
+	
 	bool tryLoadPlugin(Plugin *plugin);
 	
 	friend class Common::Singleton<SingletonBaseType>;


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