Skip to content

Commit

Permalink
custom implementation for terminate_all_scripts_with_this_name
Browse files Browse the repository at this point in the history
  • Loading branch information
x87 committed Feb 7, 2025
1 parent 1811b2d commit 69c9089
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
20 changes: 20 additions & 0 deletions cleo_plugins/MemoryOperations/MemoryOperations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class MemoryOperations
}

//register opcodes
CLEO_RegisterOpcode(0x0459, opcode_0459); // terminate_all_scripts_with_this_name

CLEO_RegisterOpcode(0x0A8C, opcode_0A8C); // write_memory
CLEO_RegisterOpcode(0x0A8D, opcode_0A8D); // read_memory

Expand Down Expand Up @@ -218,6 +220,24 @@ class MemoryOperations
return OR_CONTINUE;
}

//0459=1,terminate_all_scripts_with_this_name %1s%
static OpcodeResult __stdcall opcode_0459(CLEO::CRunningScript* thread)
{
OPCODE_READ_PARAM_STRING(threadName);

while (true)
{
// we only want to terminate game scripts, not custom ones
auto found = CLEO_GetScriptByName(threadName, true, false, 0);
if (found == nullptr)
break;

CLEO_TerminateScript(found);
}

return OR_CONTINUE;
}

//0A8C=4,write_memory %1d% size %2d% value %3d% virtual_protect %4d%
static OpcodeResult __stdcall opcode_0A8C(CLEO::CRunningScript* thread)
{
Expand Down
5 changes: 5 additions & 0 deletions source/CScriptEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,11 @@ namespace CLEO
{
for (auto script = *activeThreadQueue; script; script = script->GetNext())
{
if (script->IsCustom())
{
// skip custom scripts in the queue, they are handled separately
continue;
}
if (_strnicmp(threadName, script->Name, sizeof(script->Name)) == 0)
{
if (resultIndex == 0) return script;
Expand Down

0 comments on commit 69c9089

Please sign in to comment.