Skip to content

Commit

Permalink
Read/Write string param showing warnings also when ran with SDK methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
MiranDMC committed Oct 29, 2023
1 parent dad53b7 commit e384a72
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions source/CCustomOpcodeSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3160,12 +3160,18 @@ extern "C"

LPSTR WINAPI CLEO_ReadStringPointerOpcodeParam(CLEO::CRunningScript* thread, char *buf, int size)
{
return ReadStringParam(thread, buf, size);
auto result = ReadStringParam(thread, buf, size);

if (result == nullptr)
LOG_WARNING("%s in script %s", lastErrorMsg.c_str(), ((CCustomScript*)thread)->GetInfoStr().c_str());

return result;
}

void WINAPI CLEO_WriteStringOpcodeParam(CLEO::CRunningScript* thread, const char* str)
{
WriteStringParam(thread, str);
if(!WriteStringParam(thread, str))
LOG_WARNING("%s in script %s", lastErrorMsg.c_str(), ((CCustomScript*)thread)->GetInfoStr().c_str());
}

char* WINAPI CLEO_ReadParamsFormatted(CLEO::CRunningScript* thread, const char* format, char* buf, int bufSize)
Expand All @@ -3174,17 +3180,10 @@ extern "C"
if (!buf) { buf = internal_buf; bufSize = sizeof(internal_buf); }
if (!bufSize) bufSize = MAX_STR_LEN;

if(format != nullptr && strlen(format) > 0)
{
if(ReadFormattedString(thread, buf, bufSize, format) == -1) // error?
{
LOG_WARNING("%s in script %s", lastErrorMsg.c_str(), ((CCustomScript*)thread)->GetInfoStr().c_str());
}
}
else
if(ReadFormattedString(thread, buf, bufSize, format) == -1) // error?
{
SkipUnusedVarArgs(thread);
if(bufSize > 0) buf[0] = '\0';
LOG_WARNING("%s in script %s", lastErrorMsg.c_str(), ((CCustomScript*)thread)->GetInfoStr().c_str());
return nullptr; // error
}

return buf;
Expand Down

0 comments on commit e384a72

Please sign in to comment.