diff --git a/cleo_plugins/DebugUtils/DebugUtils.cpp b/cleo_plugins/DebugUtils/DebugUtils.cpp index 23a5c29e..c4e35717 100644 --- a/cleo_plugins/DebugUtils/DebugUtils.cpp +++ b/cleo_plugins/DebugUtils/DebugUtils.cpp @@ -51,7 +51,7 @@ class DebugUtils } auto config = GetConfigFilename(); - configLimitCommand = GetPrivateProfileInt("Limits", "Command", 100000, config.c_str()); + configLimitCommand = GetPrivateProfileInt("Limits", "Command", 200000, config.c_str()); // register opcodes CLEO_RegisterOpcode(0x00C3, Opcode_DebugOn); @@ -183,7 +183,7 @@ class DebugUtils static bool WINAPI OnScriptProcess(CScriptThread* thread) { - currScript.Reset(); + currScript.Begin(thread); for (size_t i = 0; i < pausedScripts.size(); i++) { @@ -198,8 +198,9 @@ class DebugUtils static OpcodeResult WINAPI OnScriptOpcodeProcess(CRunningScript* thread, DWORD opcode) { - currScript.commandCounter++; - if (currScript.commandCounter > configLimitCommand && !IsLegacyScript(thread)) + currScript.ProcessCommand(thread); + + if (configLimitCommand > 0 && currScript.commandCounter > configLimitCommand && !IsLegacyScript(thread)) { SHOW_ERROR("Over %d,%03d commands executed in a single frame by script %s \nTo prevent the game from freezing, CLEO suspended this script.\n\nTo ignore this error, increase 'command' property in %s.ini file and restart the game.", configLimitCommand / 1000, configLimitCommand % 1000, ScriptInfoStr(thread).c_str(), TARGET_NAME); return thread->Suspend(); diff --git a/cleo_plugins/DebugUtils/SA.DebugUtils.ini b/cleo_plugins/DebugUtils/SA.DebugUtils.ini index d3a7753d..7659c9d0 100644 --- a/cleo_plugins/DebugUtils/SA.DebugUtils.ini +++ b/cleo_plugins/DebugUtils/SA.DebugUtils.ini @@ -2,6 +2,7 @@ ; Opcodes 0662, 0663, 0664: 0 - off, 1 - enabled LegacyDebugOpcodes = 0 + [ScreenLog] ; Level: 0 - off, 1 - errors and warnings, 2 - debug messages, 3 - all Level = 2 @@ -23,6 +24,6 @@ ColorError = "FF30EEFF" ColorDebug = "FFEE30FF" ColorSystem = "DDDDDDFF" -; limits between 'wait' commands in script after which it is considered hanging + [Limits] -command = 100000 +Command = 200000 ; maximum instructions per script per frame. Set to 0 to disable the limit diff --git a/cleo_plugins/DebugUtils/ScriptLog.h b/cleo_plugins/DebugUtils/ScriptLog.h index 1b0f1ea8..e531aa51 100644 --- a/cleo_plugins/DebugUtils/ScriptLog.h +++ b/cleo_plugins/DebugUtils/ScriptLog.h @@ -3,11 +3,20 @@ struct ScriptLog { + CRunningScript* thread = nullptr; size_t commandCounter = 0; - void Reset() + void Begin(CRunningScript* thread) { + this->thread = thread; commandCounter = 0; } + + void ProcessCommand(CRunningScript* thread) + { + if (this->thread != thread) Begin(thread); + + commandCounter++; + } };