[Scummvm-git-logs] scummvm master -> 83fc4f7338bcaaadede8beff55313e50a92914d2
sev-
sev at scummvm.org
Mon Aug 16 19:33:54 UTC 2021
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
436e47292e BASE: Load engine plugins by name. Fixes bug #12342
ed09f11eaa COMMON: Keep only one instance of global debug flags
fef26b3c59 BASE: Capture all global debug channels as early as possible
83fc4f7338 COMMON: Persist global debug channels between engine runs
Commit: 436e47292eead563577ce70e163d909fe1b10add
https://github.com/scummvm/scummvm/commit/436e47292eead563577ce70e163d909fe1b10add
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-08-16T20:32:53+02:00
Commit Message:
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
Changed paths:
base/plugins.cpp
base/plugins.h
engines/advancedDetector.cpp
diff --git a/base/plugins.cpp b/base/plugins.cpp
index c6f9973008..85e46837f7 100644
--- a/base/plugins.cpp
+++ b/base/plugins.cpp
@@ -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;
diff --git a/base/plugins.h b/base/plugins.h
index dced2b3bf0..b454c75f96 100644
--- a/base/plugins.h
+++ b/base/plugins.h
@@ -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() {}
diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp
index 76775832af..78be137b21 100644
--- a/engines/advancedDetector.cpp
+++ b/engines/advancedDetector.cpp
@@ -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);
}
Commit: ed09f11eaa40ca68729fb2a6eb136f813b4261d1
https://github.com/scummvm/scummvm/commit/ed09f11eaa40ca68729fb2a6eb136f813b4261d1
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-08-16T20:43:16+02:00
Commit Message:
COMMON: Keep only one instance of global debug flags
Changed paths:
common/debug.cpp
common/debug.h
diff --git a/common/debug.cpp b/common/debug.cpp
index 132fd949eb..2b76fd52ce 100644
--- a/common/debug.cpp
+++ b/common/debug.cpp
@@ -32,6 +32,11 @@
int gDebugLevel = -1;
bool gDebugChannelsOnly = false;
+const DebugChannelDef gDebugChannels[] = {
+ { kDebugLevelEventRec, "eventrec", "Event recorder debug level" },
+ { kDebugGlobalDetection, "detection", "debug messages for advancedDetector" },
+ DEBUG_CHANNEL_END
+};
namespace Common {
DECLARE_SINGLETON(DebugManager);
diff --git a/common/debug.h b/common/debug.h
index 5ba1bf1c8e..c85f5a0371 100644
--- a/common/debug.h
+++ b/common/debug.h
@@ -166,11 +166,7 @@ enum GlobalDebugLevels {
kDebugLevelEventRec = 1 << 30
};
-static const DebugChannelDef gDebugChannels[] = {
- {kDebugLevelEventRec, "EventRec", "Event recorder debug level"},
- {kDebugGlobalDetection, "Detection", "debug messages for advancedDetector"},
- DEBUG_CHANNEL_END
-};
+extern const DebugChannelDef gDebugChannels[];
/** @} */
Commit: fef26b3c59edd56a5c18de12c1fff24375736b7f
https://github.com/scummvm/scummvm/commit/fef26b3c59edd56a5c18de12c1fff24375736b7f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-08-16T21:28:26+02:00
Commit Message:
BASE: Capture all global debug channels as early as possible
Changed paths:
base/main.cpp
diff --git a/base/main.cpp b/base/main.cpp
index cb466f969f..722a75b5ca 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -441,6 +441,16 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
gDebugChannelsOnly = true;
+ // Now we want to enable global flags if any
+ Common::StringTokenizer tokenizer(specialDebug, " ,");
+ while (!tokenizer.empty()) {
+ Common::String token = tokenizer.nextToken();
+ if (token.equalsIgnoreCase("all"))
+ DebugMan.enableAllDebugChannels();
+ else
+ DebugMan.enableDebugChannel(token);
+ }
+
ConfMan.registerDefault("always_run_fallback_detection_extern", true);
PluginManager::instance().init();
PluginManager::instance().loadAllPlugins(); // load plugins for cached plugin manager
Commit: 83fc4f7338bcaaadede8beff55313e50a92914d2
https://github.com/scummvm/scummvm/commit/83fc4f7338bcaaadede8beff55313e50a92914d2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-08-16T21:33:15+02:00
Commit Message:
COMMON: Persist global debug channels between engine runs
Changed paths:
common/debug-channels.h
common/debug.cpp
diff --git a/common/debug-channels.h b/common/debug-channels.h
index 151c3242b9..b3f1e6ceca 100644
--- a/common/debug-channels.h
+++ b/common/debug-channels.h
@@ -157,6 +157,7 @@ private:
DebugChannelMap _debugChannels;
uint32 _debugChannelsEnabled;
+ uint32 _globalChannelsMask;
friend class Singleton<SingletonBaseType>;
diff --git a/common/debug.cpp b/common/debug.cpp
index 2b76fd52ce..86593f1856 100644
--- a/common/debug.cpp
+++ b/common/debug.cpp
@@ -54,6 +54,12 @@ struct DebugLevelComperator {
DebugManager::DebugManager() :
_debugChannelsEnabled(0) {
addDebugChannels(gDebugChannels);
+
+ // Create global debug channels mask
+ _globalChannelsMask = 0;
+ for (uint i = 0; gDebugChannels[i].channel != 0; ++i) {
+ _globalChannelsMask |= gDebugChannels[i].channel;
+ }
}
bool DebugManager::addDebugChannel(uint32 channel, const String &name, const String &description) {
@@ -83,9 +89,12 @@ void DebugManager::addAllDebugChannels(const DebugChannelDef *channels) {
}
void DebugManager::removeAllDebugChannels() {
+ uint32 globalChannels = _debugChannelsEnabled & _globalChannelsMask;
_debugChannelsEnabled = 0;
_debugChannels.clear();
addDebugChannels(gDebugChannels);
+
+ _debugChannelsEnabled |= globalChannels;
}
bool DebugManager::enableDebugChannel(const String &name) {
More information about the Scummvm-git-logs
mailing list