From e8ed75d884726763fd03eddad34663ff98918e3b Mon Sep 17 00:00:00 2001 From: Marcus Comstedt Date: Mon, 20 Sep 2021 23:12:49 +0200 Subject: [PATCH] PLUGINS: In uncached mode, try plugin which matches engine name first Trying all engine plugins in alphabetical order is a time consuming process, so start by trying the plugin which has the same name as the engine id first, if it exists, as it will usually be the right one. In the rare case that it would be the wrong one there is no problem; the code will simply fall through to the old scanning and then record the correct plugin in the engine_plugin_files domain where it will be found the next time the plugin is needed. --- base/plugins.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/base/plugins.cpp b/base/plugins.cpp index 14870561a6f..b0675c6e5a0 100644 --- a/base/plugins.cpp +++ b/base/plugins.cpp @@ -409,6 +409,20 @@ bool PluginManagerUncached::loadPluginFromEngineId(const Common::String &engineI } } } + // Check for a plugin with the same name as the engine before starting + // to scan all plugins + Common::String tentativeEnginePluginFilename = engineId; +#ifdef PLUGIN_SUFFIX + tentativeEnginePluginFilename += PLUGIN_SUFFIX; +#endif + for (PluginList::iterator p = _allEnginePlugins.begin(); p != _allEnginePlugins.end(); ++p) { + Common::String filename = (*p)->getFileName(); + if (filename.hasSuffixIgnoreCase(tentativeEnginePluginFilename)) { + if (loadPluginByFileName(filename)) { + return true; + } + } + } return false; }