BASE: move setting debug flags to debug manager, set debug flags before call detectGames

This commit is contained in:
ysj1173886760 2021-05-12 20:23:47 +08:00 committed by Eugene Sandulenko
parent 9609406205
commit a6542f242e
2 changed files with 10 additions and 15 deletions

View File

@ -151,18 +151,6 @@ void saveLastLaunchedTarget(const Common::String &target) {
}
}
void debugFlagsRegister(const DebugChannelOptions &options) {
for (uint i = 0; i < options.size(); i++)
DebugMan.addDebugChannel(options[i].channel, options[i].name, options[i].description);
}
void debugFlagClear() {
// first we clear all the debug channels
// then we add the global debug flags
DebugMan.clearAllDebugChannels();
DebugMan.addDebugChannel(kDebugGlobalTest, "test", "test global debug flag");
}
// TODO: specify the possible return values here
static Common::Error runGame(const Plugin *plugin, const Plugin *enginePlugin, OSystem &system, const Common::String &edebuglevels) {
assert(plugin);
@ -204,9 +192,9 @@ static Common::Error runGame(const Plugin *plugin, const Plugin *enginePlugin, O
}
// clear the flag and add the global ones
debugFlagClear();
DebugMan.debugFlagsClear();
// before we instantiate the engine, we register debug channels for it
debugFlagsRegister(metaEngineDetection.getDebugChannelOptions());
DebugMan.debugFlagsRegister(metaEngineDetection.getDebugChannelOptions());
// Create the game's MetaEngine.
MetaEngine &metaEngine = enginePlugin->get<MetaEngine>();
@ -527,7 +515,7 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
MusicManager::instance();
Common::DebugManager::instance();
// set the global debug flags as soon as we instantiate the debug mannager
debugFlagClear();
DebugMan.debugFlagsClear();
// Init the event manager. As the virtual keyboard is loaded here, it must
// take place after the backend is initiated and the screen has been setup

View File

@ -24,6 +24,7 @@
#include "common/func.h"
#include "common/debug.h"
#include "common/debug-channels.h"
#include "common/config-manager.h"
#ifdef DYNAMIC_MODULES
@ -732,6 +733,9 @@ DetectionResults EngineManager::detectGames(const Common::FSList &fslist) const
// the game in the presented directory.
for (iter = plugins.begin(); iter != plugins.end(); ++iter) {
const MetaEngineDetection &metaEngine = (*iter)->get<MetaEngineDetection>();
// set the debug flags
DebugMan.debugFlagsClear();
DebugMan.debugFlagsRegister(metaEngine.getDebugChannelOptions());
DetectedGames engineCandidates = metaEngine.detectGames(fslist);
for (uint i = 0; i < engineCandidates.size(); i++) {
@ -927,6 +931,9 @@ void EngineManager::upgradeTargetForEngineId(const Common::String &target) const
// Take the first detection entry
const MetaEngineDetection &metaEngine = plugin->get<MetaEngineDetection>();
// set debug flags before call detectGames
DebugMan.debugFlagsClear();
DebugMan.debugFlagsRegister(metaEngine.getDebugChannelOptions());
DetectedGames candidates = metaEngine.detectGames(files);
if (candidates.empty()) {
warning("No games supported by the engine '%s' were found in path '%s' when upgrading target '%s'",