r5sdk/r5dev/engine/enginetrace.h
Kawe Mazidjatari edc52ad669 IDetour: remove extraneous pointer assignments
Originally, we store the search results in a CMemory instance which we then assign to the actual function pointer. CMemory is just a pointer class; we can assign the results directly to the actual function pointer. This commit reduces a lot of code verbosity, and also reduced roughly 2KiB worth of static pointers in the resulting executable. This commit also officially deprecates the support for any GameDLL's below S3 (Season 3), since it makes more sense to port the assets from earlier/later games back to the version this SDK supports.
2024-04-05 17:19:32 +02:00

49 lines
1.6 KiB
C++

#pragma once
#include "public/engine/IEngineTrace.h"
#include "public/cmodel.h"
#include "public/trace.h"
#include "mathlib/mathlib.h"
class CEngineTrace : public IEngineTrace
{};
/* ==== CENGINETRACE ======================================================================================================================================================= */
#ifndef CLIENT_DLL
class CEngineTraceServer : public CEngineTrace
{};
inline CEngineTraceServer* g_pEngineTraceServer = nullptr;
inline CEngineTraceServer* g_pEngineTraceServerVFTable = nullptr;
#endif // CLIENT_DLL
#ifndef DEDICATED
class CEngineTraceClient : public CEngineTrace
{};
inline CEngineTraceClient* g_pEngineTraceClient = nullptr;
#endif // DEDICATED
///////////////////////////////////////////////////////////////////////////////
class VEngineTrace : public IDetour
{
virtual void GetAdr(void) const
{
#ifndef CLIENT_DLL
LogVarAdr("g_pEngineTraceServer", g_pEngineTraceServer);
#endif // CLIENT_DLL
#ifndef DEDICATED
LogVarAdr("g_pEngineTraceClient", g_pEngineTraceClient);
#endif // DEDICATED
}
virtual void GetFun(void) const { }
virtual void GetVar(void) const { }
virtual void GetCon(void) const
{
#ifndef CLIENT_DLL
g_pEngineTraceServerVFTable = g_GameDll.GetVirtualMethodTable(".?AVCEngineTraceServer@@").RCast<CEngineTraceServer*>();
g_pEngineTraceServer = reinterpret_cast<CEngineTraceServer*>(&g_pEngineTraceServerVFTable); // Must be done for virtual calls.
#endif // CLIENT_DLL
}
virtual void Detour(const bool bAttach) const { }
};
///////////////////////////////////////////////////////////////////////////////