Skip to content

Commit

Permalink
Fixes (#23)
Browse files Browse the repository at this point in the history
* Compilation warnings fixes

* fixed global debug mode state not initialized in spawned scripts
  • Loading branch information
MiranDMC authored Nov 2, 2023
1 parent c4fa849 commit f606c18
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
11 changes: 4 additions & 7 deletions source/CCustomOpcodeSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -764,9 +764,6 @@ namespace CLEO

std::pair<char*, DWORD> GetStringParamWriteBuffer(CRunningScript* thread)
{
char* targetBuff;
DWORD targetSize;

lastErrorMsg.clear();

auto paramType = CLEO_GetOperandType(thread);
Expand Down Expand Up @@ -1278,7 +1275,7 @@ namespace CLEO
cs->LogicalOp = eLogicalOperation::NONE;
cs->NotFlag = false;

cs->SetScmFunction(thisScmFunctionId = allocationPlace);
cs->SetScmFunction(thisScmFunctionId = (unsigned short)allocationPlace);
}

void Return(CRunningScript *thread)
Expand Down Expand Up @@ -1348,13 +1345,13 @@ namespace CLEO
switch (size)
{
default:
GetInstance().CodeInjector.MemoryWrite<BYTE>(Address, value, vp, size);
GetInstance().CodeInjector.MemoryWrite(Address, (BYTE)value, vp, size);
break;
case 2:
GetInstance().CodeInjector.MemoryWrite<WORD>(Address, value, vp);
GetInstance().CodeInjector.MemoryWrite(Address, (WORD)value, vp);
break;
case 4:
GetInstance().CodeInjector.MemoryWrite<DWORD>(Address, value, vp);
GetInstance().CodeInjector.MemoryWrite(Address, (DWORD)value, vp);
break;
}
return OR_CONTINUE;
Expand Down
34 changes: 20 additions & 14 deletions source/CScriptEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1002,25 +1002,31 @@ namespace CLEO

TRACE("Searching for CLEO scripts");

CCustomScript* cs = nullptr;
FilesWalk(scriptsDir.c_str(), cs_ext, [&](const char* fullPath, const char* filename) {
cs = LoadScript(fullPath);
});

FilesWalk(scriptsDir.c_str(), cs4_ext, [&](const char* fullPath, const char* filename) {
cs = LoadScript(fullPath);
if (cs) cs->SetCompatibility(CLEO_VER_4);
FilesWalk(scriptsDir.c_str(), cs_ext, [&](const char* fullPath, const char* filename)
{
if(auto cs = LoadScript(fullPath))
{
cs->SetDebugMode(NativeScriptsDebugMode); // inherit from global state
}
});

FilesWalk(scriptsDir.c_str(), cs3_ext, [&](const char* fullPath, const char* filename) {
cs = LoadScript(fullPath);
if (cs) cs->SetCompatibility(CLEO_VER_3);
FilesWalk(scriptsDir.c_str(), cs4_ext, [&](const char* fullPath, const char* filename)
{
if (auto cs = LoadScript(fullPath))
{
cs->SetCompatibility(CLEO_VER_4);
cs->SetDebugMode(NativeScriptsDebugMode); // inherit from global state
}
});

if (cs != nullptr)
FilesWalk(scriptsDir.c_str(), cs3_ext, [&](const char* fullPath, const char* filename)
{
cs->SetDebugMode(NativeScriptsDebugMode); // inherit from global state
}
if (auto cs = LoadScript(fullPath))
{
cs->SetCompatibility(CLEO_VER_3);
cs->SetDebugMode(NativeScriptsDebugMode); // inherit from global state
}
});

for (void* func : GetInstance().GetCallbacks(eCallbackId::ScriptsLoaded))
{
Expand Down

0 comments on commit f606c18

Please sign in to comment.