mirror of
https://github.com/libretro/scummvm.git
synced 2025-04-02 14:51:40 +00:00
BASE: Load engine plugins by name. Fixes bug #12342
This is a degradation from the split of detection plugins. All the caching code which was present was left with detection plugins which now make no sense: we always load all detection plugins as a whole. This commit moves the caching logic over to the Engine plugins. This opens a question now whether we should move all to UNCACHED_PLUGINS
This commit is contained in:
parent
95ec5b6f70
commit
436e47292e
@ -289,30 +289,15 @@ void PluginManager::addPluginProvider(PluginProvider *pp) {
|
||||
_providers.push_back(pp);
|
||||
}
|
||||
|
||||
Plugin *PluginManager::getEngineFromMetaEngine(const Plugin *plugin) {
|
||||
const Plugin *PluginManager::getEngineFromMetaEngine(const Plugin *plugin) {
|
||||
assert(plugin->getType() == PLUGIN_TYPE_ENGINE_DETECTION);
|
||||
|
||||
Plugin *enginePlugin = nullptr;
|
||||
bool found = false;
|
||||
const Plugin *enginePlugin = nullptr;
|
||||
|
||||
// Use the engineID from MetaEngine for comparasion.
|
||||
// Use the engineID from MetaEngine for comparison.
|
||||
Common::String metaEnginePluginName = plugin->getEngineId();
|
||||
PluginMan.loadFirstPlugin();
|
||||
do {
|
||||
PluginList pl = PluginMan.getPlugins(PLUGIN_TYPE_ENGINE);
|
||||
// Iterate over all engine plugins.
|
||||
for (PluginList::const_iterator itr = pl.begin(); itr != pl.end(); itr++) {
|
||||
// The getName() provides a name which is similiar to getEngineId.
|
||||
// Because engines are engines themselves, this function is simply named getName.
|
||||
Common::String enginePluginName((*itr)->getName());
|
||||
|
||||
if (metaEnginePluginName.equalsIgnoreCase(enginePluginName)) {
|
||||
enginePlugin = (*itr);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (!found && PluginMan.loadNextPlugin());
|
||||
enginePlugin = PluginMan.findEnginePlugin(metaEnginePluginName);
|
||||
|
||||
if (enginePlugin) {
|
||||
debug(9, "MetaEngine: %s \t matched to \t Engine: %s", plugin->getName(), enginePlugin->getFileName());
|
||||
@ -323,10 +308,10 @@ Plugin *PluginManager::getEngineFromMetaEngine(const Plugin *plugin) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Plugin *PluginManager::getMetaEngineFromEngine(const Plugin *plugin) {
|
||||
const Plugin *PluginManager::getMetaEngineFromEngine(const Plugin *plugin) {
|
||||
assert(plugin->getType() == PLUGIN_TYPE_ENGINE);
|
||||
|
||||
Plugin *metaEngine = nullptr;
|
||||
const Plugin *metaEngine = nullptr;
|
||||
|
||||
PluginList pl = PluginMan.getPlugins(PLUGIN_TYPE_ENGINE_DETECTION);
|
||||
|
||||
@ -810,7 +795,7 @@ Common::String EngineManager::createTargetForGame(const DetectedGame &game) {
|
||||
return domain;
|
||||
}
|
||||
|
||||
const Plugin *EngineManager::findLoadedPlugin(const Common::String &engineId) const {
|
||||
const Plugin *EngineManager::findPlugin(const Common::String &engineId) const {
|
||||
const PluginList &plugins = getPlugins();
|
||||
|
||||
for (PluginList::const_iterator iter = plugins.begin(); iter != plugins.end(); iter++)
|
||||
@ -820,7 +805,17 @@ const Plugin *EngineManager::findLoadedPlugin(const Common::String &engineId) co
|
||||
return 0;
|
||||
}
|
||||
|
||||
const Plugin *EngineManager::findPlugin(const Common::String &engineId) const {
|
||||
const Plugin *PluginManager::findLoadedPlugin(const Common::String &engineId) {
|
||||
const PluginList &plugins = getPlugins(PLUGIN_TYPE_ENGINE);
|
||||
|
||||
for (PluginList::const_iterator iter = plugins.begin(); iter != plugins.end(); iter++)
|
||||
if (engineId == (*iter)->get<MetaEngine>().getName())
|
||||
return *iter;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const Plugin *PluginManager::findEnginePlugin(const Common::String &engineId) {
|
||||
// First look for the game using the plugins in memory. This is critical
|
||||
// for calls coming from inside games
|
||||
const Plugin *plugin = findLoadedPlugin(engineId);
|
||||
@ -829,7 +824,7 @@ const Plugin *EngineManager::findPlugin(const Common::String &engineId) const {
|
||||
|
||||
// Now look for the plugin using the engine ID. This is much faster than scanning plugin
|
||||
// by plugin
|
||||
if (PluginMan.loadPluginFromEngineId(engineId)) {
|
||||
if (loadPluginFromEngineId(engineId)) {
|
||||
plugin = findLoadedPlugin(engineId);
|
||||
if (plugin)
|
||||
return plugin;
|
||||
|
@ -305,6 +305,8 @@ protected:
|
||||
|
||||
bool tryLoadPlugin(Plugin *plugin);
|
||||
void addToPluginsInMemList(Plugin *plugin);
|
||||
const Plugin *findEnginePlugin(const Common::String &engineId);
|
||||
const Plugin *findLoadedPlugin(const Common::String &engineId);
|
||||
|
||||
static PluginManager *_instance;
|
||||
PluginManager();
|
||||
@ -323,11 +325,11 @@ public:
|
||||
* It uses the Engine plugin's getName method, which is an identifier,
|
||||
* and then tries to matches it with each plugin present in memory.
|
||||
*
|
||||
* @param A plugin of type ENGINE.
|
||||
* @param plugin A plugin of type ENGINE.
|
||||
*
|
||||
* @return A plugin of type METAENGINE.
|
||||
*/
|
||||
Plugin *getMetaEngineFromEngine(const Plugin *plugin);
|
||||
const Plugin *getMetaEngineFromEngine(const Plugin *plugin);
|
||||
|
||||
/**
|
||||
* A method which takes in a plugin of type METAENGINE,
|
||||
@ -339,7 +341,7 @@ public:
|
||||
*
|
||||
* @return A plugin of type ENGINE.
|
||||
*/
|
||||
Plugin *getEngineFromMetaEngine(const Plugin *plugin);
|
||||
const Plugin *getEngineFromMetaEngine(const Plugin *plugin);
|
||||
|
||||
// Functions used by the uncached PluginManager
|
||||
virtual void init() {}
|
||||
|
@ -771,7 +771,7 @@ void AdvancedMetaEngineDetection::initSubSystems(const ADGameDescription *gameDe
|
||||
Common::Error AdvancedMetaEngine::createInstance(OSystem *syst, Engine **engine) const {
|
||||
PluginList pl = PluginMan.getPlugins(PLUGIN_TYPE_ENGINE);
|
||||
if (pl.size() == 1) {
|
||||
Plugin *metaEnginePlugin = PluginMan.getMetaEngineFromEngine(pl[0]);
|
||||
const Plugin *metaEnginePlugin = PluginMan.getMetaEngineFromEngine(pl[0]);
|
||||
if (metaEnginePlugin) {
|
||||
return metaEnginePlugin->get<AdvancedMetaEngineDetection>().createInstance(syst, engine);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user