Skip to content

Commit

Permalink
Restored original return type in CLEO_GetOperandType export. (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
MiranDMC authored Mar 6, 2024
1 parent edbed65 commit a309ebf
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions cleo_plugins/DebugUtils/DebugUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,13 @@ class DebugUtils
std::string name = "";

// bool param - blocking
auto paramType = CLEO_GetOperandType(thread);
auto paramType = thread->PeekDataType();
if(paramType == DT_BYTE)
{
blocking = CLEO_GetIntOpcodeParam(thread) != 0;
}

paramType = CLEO_GetOperandType(thread);
paramType = thread->PeekDataType();
if (paramType == eDataType::DT_END)
{
thread->IncPtr(); // consume arguments terminator
Expand Down
6 changes: 3 additions & 3 deletions cleo_plugins/FileSystemOperations/FileSystemOperations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class FileSystemOperations
{
const char* path;

auto paramType = CLEO_GetOperandType(thread);
auto paramType = thread->PeekDataType();
if (IsImmInteger(paramType) || IsVariable(paramType))
{
// numbered predefined paths
Expand Down Expand Up @@ -117,7 +117,7 @@ class FileSystemOperations
OPCODE_READ_PARAM_FILEPATH(filename);

char mode[16];
auto paramType = CLEO_GetOperandType(thread);
auto paramType = thread->PeekDataType();
if (IsImmInteger(paramType) || IsVariable(paramType))
{
// integer param (for backward compatibility with CLEO 3)
Expand Down Expand Up @@ -361,7 +361,7 @@ class FileSystemOperations

size_t paramCount = 0;
SCRIPT_VAR* outputParams[35];
while (CLEO_GetOperandType(thread) != eDataType::DT_END)
while (thread->PeekDataType() != eDataType::DT_END)
{
// TODO: if target param is string variable it should be handled correctly
outputParams[paramCount++] = CLEO_GetPointerToScriptVariable(thread);
Expand Down
2 changes: 1 addition & 1 deletion cleo_sdk/CLEO.h
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ void WINAPI CLEO_SetScriptWorkDir(CRunningScript* thread, const char* path);
void WINAPI CLEO_SetThreadCondResult(CRunningScript* thread, BOOL result);
void WINAPI CLEO_ThreadJumpAtLabelPtr(CRunningScript* thread, int labelPtr);

eDataType WINAPI CLEO_GetOperandType(const CRunningScript* thread); // peek parameter data type
int WINAPI CLEO_GetOperandType(const CRunningScript* thread); // peek parameter data type. Returns int for legacy reason, should be eDataType.
DWORD WINAPI CLEO_GetVarArgCount(CRunningScript* thread); // peek remaining var-args count

extern SCRIPT_VAR* opcodeParams;
Expand Down
26 changes: 13 additions & 13 deletions source/CCustomOpcodeSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ namespace CLEO
StringParamBufferInfo result;
CCustomOpcodeSystem::lastErrorMsg.clear();

auto paramType = CLEO_GetOperandType(thread);
auto paramType = thread->PeekDataType();
if (IsImmInteger(paramType) || IsVariable(paramType))
{
// address to output buffer
Expand Down Expand Up @@ -570,7 +570,7 @@ namespace CLEO
char *buffiter = bufa;

//get width
if (CLEO_GetOperandType(thread) == DT_END) goto _ReadFormattedString_ArgMissing;
if (thread->PeekDataType() == DT_END) goto _ReadFormattedString_ArgMissing;
GetScriptParams(thread, 1);
_itoa(opcodeParams[0].dwParam, buffiter, 10);
while (*buffiter)
Expand All @@ -592,7 +592,7 @@ namespace CLEO
if (*iter == '*')
{
char *buffiter = bufa;
if (CLEO_GetOperandType(thread) == DT_END) goto _ReadFormattedString_ArgMissing;
if (thread->PeekDataType() == DT_END) goto _ReadFormattedString_ArgMissing;
GetScriptParams(thread, 1);
_itoa(opcodeParams[0].dwParam, buffiter, 10);
while (*buffiter)
Expand All @@ -610,7 +610,7 @@ namespace CLEO
{
case 's':
{
if (CLEO_GetOperandType(thread) == DT_END) goto _ReadFormattedString_ArgMissing;
if (thread->PeekDataType() == DT_END) goto _ReadFormattedString_ArgMissing;

const char* str = ReadStringParam(thread, bufa, sizeof(bufa));
if(str == nullptr) // read error
Expand All @@ -630,7 +630,7 @@ namespace CLEO

case 'c':
if (written++ >= len) goto _ReadFormattedString_OutOfMemory;
if (CLEO_GetOperandType(thread) == DT_END) goto _ReadFormattedString_ArgMissing;
if (thread->PeekDataType() == DT_END) goto _ReadFormattedString_ArgMissing;
GetScriptParams(thread, 1);
*outIter++ = (char)opcodeParams[0].nParam;
iter++;
Expand All @@ -643,7 +643,7 @@ namespace CLEO
char *bufaiter = bufa;
if (*iter == 'p' || *iter == 'P')
{
if (CLEO_GetOperandType(thread) == DT_END) goto _ReadFormattedString_ArgMissing;
if (thread->PeekDataType() == DT_END) goto _ReadFormattedString_ArgMissing;
GetScriptParams(thread, 1);
sprintf(bufaiter, "%08X", opcodeParams[0].dwParam);
}
Expand All @@ -656,13 +656,13 @@ namespace CLEO
*iter == 'f' || *iter == 'F' ||
*iter == 'g' || *iter == 'G')
{
if (CLEO_GetOperandType(thread) == DT_END) goto _ReadFormattedString_ArgMissing;
if (thread->PeekDataType() == DT_END) goto _ReadFormattedString_ArgMissing;
GetScriptParams(thread, 1);
sprintf(bufaiter, fmtbufa, opcodeParams[0].fParam);
}
else
{
if (CLEO_GetOperandType(thread) == DT_END) goto _ReadFormattedString_ArgMissing;
if (thread->PeekDataType() == DT_END) goto _ReadFormattedString_ArgMissing;
GetScriptParams(thread, 1);
sprintf(bufaiter, fmtbufa, opcodeParams[0].pParam);
}
Expand Down Expand Up @@ -691,7 +691,7 @@ namespace CLEO
}

// still more var-args available
if (CLEO_GetOperandType(thread) != DT_END)
if (thread->PeekDataType() != DT_END)
{
CCustomOpcodeSystem::lastErrorMsg = "More params than slots in formatted string";
LOG_WARNING(thread, "%s in script %s", CCustomOpcodeSystem::lastErrorMsg.c_str(), ((CCustomScript*)thread)->GetInfoStr().c_str());
Expand Down Expand Up @@ -825,7 +825,7 @@ namespace CLEO

void SkipUnusedVarArgs(CRunningScript *thread)
{
while (CLEO_GetOperandType(thread) != DT_END)
while (thread->PeekDataType() != DT_END)
CLEO_SkipOpcodeParams(thread, 1);

thread->IncPtr(); // skip terminator
Expand All @@ -836,7 +836,7 @@ namespace CLEO
const auto ip = thread->GetBytePointer();

DWORD count = 0;
while (CLEO_GetOperandType(thread) != DT_END)
while (thread->PeekDataType() != DT_END)
{
CLEO_SkipOpcodeParams(thread, 1);
count++;
Expand Down Expand Up @@ -2031,9 +2031,9 @@ extern "C"
ThreadJump(thread, labelPtr);
}

eDataType WINAPI CLEO_GetOperandType(const CLEO::CRunningScript* thread)
int WINAPI CLEO_GetOperandType(const CLEO::CRunningScript* thread)
{
return (eDataType )*thread->GetBytePointer();
return (int)thread->PeekDataType();
}

void WINAPI CLEO_RetrieveOpcodeParams(CLEO::CRunningScript *thread, int count)
Expand Down

0 comments on commit a309ebf

Please sign in to comment.