Merge pull request #20 from r-ex/master

script print VM prefixes (external console only)
This commit is contained in:
Amos 2021-08-03 10:31:28 -07:00 committed by GitHub
commit 8cd970b6bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,15 +7,25 @@ namespace Hooks
SQVM_LoadScriptFn originalSQVM_LoadScript = nullptr;
}
std::string prefixes[3] = { "Script(S)", "Script(C)", "Script(U)" };
void* Hooks::SQVM_Print(void* sqvm, char* fmt, ...)
{
int vmIdx = *(int*)((std::uintptr_t)sqvm + 0x18);
char buf[1024];
va_list args;
va_start(args, fmt);
// external console
printf("%s:", prefixes[vmIdx].c_str());
vprintf(fmt, args);
// imgui console
vsnprintf(buf, IM_ARRAYSIZE(buf), fmt, args);
buf[IM_ARRAYSIZE(buf) - 1] = 0;
va_end(args);
Items.push_back(Strdup(buf));
return NULL;
}