Skip to content

Commit

Permalink
Standardized warning messages of terminate_this_script and terminate_… (
Browse files Browse the repository at this point in the history
  • Loading branch information
MiranDMC authored Aug 2, 2024
1 parent 57306e1 commit 6aeb737
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 22 deletions.
8 changes: 4 additions & 4 deletions source/CCustomOpcodeSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -863,11 +863,11 @@ namespace CLEO
CCustomScript *cs = reinterpret_cast<CCustomScript *>(thread);
if (thread->IsMission() || !cs->IsCustom())
{
LOG_WARNING(0, "Incorrect usage of opcode [0A93] in script %s", ((CCustomScript*)thread)->GetInfoStr().c_str());

return OR_CONTINUE;
LOG_WARNING(0, "Incorrect usage of opcode [0A93] in script %s. Use [004E] instead.", ((CCustomScript*)thread)->GetInfoStr().c_str());
return OR_CONTINUE; // legacy behavior
}
GetInstance().ScriptEngine.RemoveCustomScript(cs);

GetInstance().ScriptEngine.RemoveScript(thread);
return OR_INTERRUPT;
}

Expand Down
25 changes: 8 additions & 17 deletions source/CScriptEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,16 +313,6 @@ namespace CLEO

extern "C" void __stdcall opcode_004E(CCustomScript *pScript) // terminate_this_script
{
if (pScript->IsCustom())
{
if (pScript->IsMission())
*MissionLoaded = false;
else
{
TRACE("Incorrect usage of opcode [004E] in script %s.", pScript->GetName().c_str());
}
}

GetInstance().ScriptEngine.RemoveScript(pScript);
}

Expand Down Expand Up @@ -1369,17 +1359,18 @@ namespace CLEO

void CScriptEngine::RemoveScript(CRunningScript* thread)
{
if (!thread->IsCustom())
if (thread->IsMission()) *MissionLoaded = false;

if (thread->IsCustom())
{
RemoveCustomScript((CCustomScript*)thread);
}
else // native script
{
if (thread->IsMission()) *MissionLoaded = false;
RemoveScriptFromQueue(thread, activeThreadQueue);
AddScriptToQueue(thread, inactiveThreadQueue);
StopScript(thread);
}
else
{
RemoveCustomScript((CCustomScript*)thread);
}
}

void CScriptEngine::RemoveCustomScript(CCustomScript *cs)
Expand All @@ -1397,7 +1388,7 @@ namespace CLEO
}
for (auto childThread : cs->childThreads)
{
CScriptEngine::RemoveCustomScript(childThread);
CScriptEngine::RemoveScript(childThread);
}
if (cs == CustomMission)
{
Expand Down
4 changes: 3 additions & 1 deletion source/CScriptEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ namespace CLEO
bool IsValidScriptPtr(const CRunningScript*) const; // leads to any script? (regular or custom)
void AddCustomScript(CCustomScript*);
void RemoveScript(CRunningScript*); // native or custom
void RemoveCustomScript(CCustomScript*);
void RemoveAllCustomScripts();
void UnregisterAllScripts();
void ReregisterAllScripts();
Expand All @@ -151,6 +150,9 @@ namespace CLEO

inline CCustomScript* GetCustomMission() { return CustomMission; }
inline size_t WorkingScriptsCount() { return CustomScripts.size(); }

private:
void RemoveCustomScript(CCustomScript*);
};

extern void(__thiscall * AddScriptToQueue)(CRunningScript *, CRunningScript **queue);
Expand Down

0 comments on commit 6aeb737

Please sign in to comment.