Color log game logic errors

This commit is contained in:
Kawe Mazidjatari 2022-05-20 01:07:42 +02:00
parent f14b3e5dfa
commit 8c76283ba1
3 changed files with 33 additions and 4 deletions

View File

@ -10,6 +10,7 @@
#include "squirrel/sqstdaux.h"
bool g_bSQAuxError = false;
bool g_bSQAuxBadIndex = false;
SQInteger sqstd_aux_printerror(HSQUIRRELVM v)
{
g_bSQAuxError = true;
@ -18,12 +19,21 @@ SQInteger sqstd_aux_printerror(HSQUIRRELVM v)
return results;
}
SQInteger sqstd_aux_badindex(HSQUIRRELVM v, __m128i* a2, __m128i* a3)
{
g_bSQAuxBadIndex = true;
SQInteger results = v_sqstd_aux_badindex(v, a2, a3);
return results;
}
void SQAUX_Attach()
{
DetourAttach((LPVOID*)&v_sqstd_aux_printerror, &sqstd_aux_printerror);
DetourAttach((LPVOID*)&v_sqstd_aux_badindex, &sqstd_aux_badindex);
}
void SQAUX_Detach()
{
DetourDetach((LPVOID*)&v_sqstd_aux_printerror, &sqstd_aux_printerror);
DetourDetach((LPVOID*)&v_sqstd_aux_badindex, &sqstd_aux_badindex);
}

View File

@ -1,11 +1,12 @@
#pragma once
extern bool g_bSQAuxError;
extern bool g_bSQAuxBadIndex;
inline CMemory p_sqstd_aux_printerror;
inline auto v_sqstd_aux_printerror = p_sqstd_aux_printerror.RCast<SQInteger(*)(HSQUIRRELVM v)>();
inline CMemory p_sqstd_aux_badindex;
inline auto v_sqstd_aux_badindex = p_sqstd_aux_badindex.RCast<SQInteger(*)(HSQUIRRELVM v, __m128i* a2, __m128i* a3)>();
void SQAUX_Attach();
void SQAUX_Detach();
@ -15,6 +16,7 @@ class VSqStdAux : public IDetour
virtual void GetAdr(void) const
{
spdlog::debug("| FUN: sqstd_aux_printerror : {:#18x} |\n", p_sqstd_aux_printerror.GetPtr());
spdlog::debug("| FUN: sqstd_aux_badindex : {:#18x} |\n", p_sqstd_aux_badindex.GetPtr());
spdlog::debug("+----------------------------------------------------------------+\n");
}
virtual void GetFun(void) const
@ -26,6 +28,8 @@ class VSqStdAux : public IDetour
p_sqstd_aux_printerror = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x40\x53\x56\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x81\xEC\x00\x00\x00\x00\xFF\x05\x00\x00\x00\x00"), "xxxxxxxxxxxxxxx????xx????");
v_sqstd_aux_printerror = p_sqstd_aux_printerror.RCast<SQInteger(*)(HSQUIRRELVM)>(); /*40 53 56 57 41 54 41 55 41 56 41 57 48 81 EC ?? ?? ?? ?? FF 05 ?? ?? ?? ??*/
#endif
p_sqstd_aux_badindex = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x48\x8B\xC4\x55\x48\x8B\xEC\x48\x83\xEC\x70\x41\x0F\x10\x00"), "xxxxxxxxxxxxxxx");
v_sqstd_aux_badindex = p_sqstd_aux_badindex.RCast<SQInteger(*)(HSQUIRRELVM, __m128i*, __m128i*)>(); /*48 8B C4 55 48 8B EC 48 83 EC 70 41 0F 10 00*/
}
virtual void GetVar(void) const { }
virtual void GetCon(void) const { }

View File

@ -99,11 +99,26 @@ SQRESULT SQVM_PrintFunc(HSQUIRRELVM v, SQChar* fmt, ...)
bError = true;
vmStrAnsi = SQVM_ERROR_ANSI_LOG_T[static_cast<SQInteger>(context)].c_str();
}
else {
else
{
vmStrAnsi = SQVM_WARNING_ANSI_LOG_T[static_cast<SQInteger>(context)].c_str();
}
}
else {
else if (g_bSQAuxBadIndex)
{
if (strstr(buf, "There was a problem processing game logic."))
{
bError = true;
g_bSQAuxBadIndex = false;
vmStrAnsi = SQVM_ERROR_ANSI_LOG_T[static_cast<SQInteger>(context)].c_str();
}
else
{
vmStrAnsi = SQVM_ANSI_LOG_T[static_cast<SQInteger>(context)].c_str();
}
}
else
{
vmStrAnsi = SQVM_ANSI_LOG_T[static_cast<SQInteger>(context)].c_str();
}
vmStrAnsi.append(buf);