diff --git a/r5dev/squirrel/sqstdaux.cpp b/r5dev/squirrel/sqstdaux.cpp index 4434cf31..520b2d6c 100644 --- a/r5dev/squirrel/sqstdaux.cpp +++ b/r5dev/squirrel/sqstdaux.cpp @@ -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); } \ No newline at end of file diff --git a/r5dev/squirrel/sqstdaux.h b/r5dev/squirrel/sqstdaux.h index be73f7d9..978fa679 100644 --- a/r5dev/squirrel/sqstdaux.h +++ b/r5dev/squirrel/sqstdaux.h @@ -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(); +inline CMemory p_sqstd_aux_badindex; +inline auto v_sqstd_aux_badindex = p_sqstd_aux_badindex.RCast(); 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("\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(); /*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("\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(); /*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 { } diff --git a/r5dev/squirrel/sqvm.cpp b/r5dev/squirrel/sqvm.cpp index acdfbcfd..81cb5c0a 100644 --- a/r5dev/squirrel/sqvm.cpp +++ b/r5dev/squirrel/sqvm.cpp @@ -99,11 +99,26 @@ SQRESULT SQVM_PrintFunc(HSQUIRRELVM v, SQChar* fmt, ...) bError = true; vmStrAnsi = SQVM_ERROR_ANSI_LOG_T[static_cast(context)].c_str(); } - else { + else + { vmStrAnsi = SQVM_WARNING_ANSI_LOG_T[static_cast(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(context)].c_str(); + } + else + { + vmStrAnsi = SQVM_ANSI_LOG_T[static_cast(context)].c_str(); + } + } + else + { vmStrAnsi = SQVM_ANSI_LOG_T[static_cast(context)].c_str(); } vmStrAnsi.append(buf);