Kawe Mazidjatari 144d5f62e1 IDetour: code refactor
Utilize the new IDetour::DetourSetup() code, IDetour::Attach and IDetour::Detach have been removed in favor of this (significantly reduces chance of user error). Since the template check happens in the idetour header, it is much more aggressive on type mismatches, such as a difference in parameter types, between the function and detour, will now raise a compile time error. As a result, some type mismatches have been fixed in this commit as well.
2024-04-05 16:41:09 +02:00

37 lines
994 B
C++

//=============================================================================//
//
// Purpose:
//
//=============================================================================//
#include "core/stdafx.h"
#include "tier0/tslist.h"
#include "vscript/languages/squirrel_re/include/sqvm.h"
#include "vscript/languages/squirrel_re/include/sqstdaux.h"
bool g_bSQAuxError = false;
bool g_bSQAuxBadLogic = false;
HSQUIRRELVM g_pErrorVM = nullptr;
SQInteger sqstd_aux_printerror(HSQUIRRELVM v)
{
g_bSQAuxError = true;
SQInteger results = v_sqstd_aux_printerror(v);
g_bSQAuxError = false;
return results;
}
SQInteger sqstd_aux_badlogic(HSQUIRRELVM v, __m128i* a2, __m128i* a3)
{
g_pErrorVM = v;
SQInteger results = v_sqstd_aux_badlogic(v, a2, a3);
return results;
}
void VSquirrelAUX::Detour(const bool bAttach) const
{
DetourSetup(&v_sqstd_aux_printerror, &sqstd_aux_printerror, bAttach);
DetourSetup(&v_sqstd_aux_badlogic, &sqstd_aux_badlogic, bAttach);
}