Add 'CTraceFilterSimple' to SDK

This commit is contained in:
Kawe Mazidjatari 2023-01-21 16:22:16 +01:00
parent 560e06ff20
commit 15429d3f8f
2 changed files with 62 additions and 1 deletions

View File

@ -12,7 +12,6 @@
#ifndef CLIENT_DLL
CPlayer* UTIL_PlayerByIndex(int nIndex)
{
if (nIndex < 1 || nIndex > (*g_pGlobals)->m_nMaxClients || nIndex == FL_EDICT_INVALID)
@ -23,3 +22,14 @@ CPlayer* UTIL_PlayerByIndex(int nIndex)
return pPlayer;
}
#endif // CLIENT_DLL
CTraceFilterSimple::CTraceFilterSimple(const IHandleEntity* pPassEntity, int collisionGroup, ShouldHitFunc_t pExtraShouldHitCheckFn)
{
void** pVTable = reinterpret_cast<void**>(&*this); // Assign vftable pointer to the implementation supplied by the engine.
*pVTable = reinterpret_cast<void*>(g_pTraceFilterSimpleVFTable);
m_collisionGroup = 0;
m_pPassEntity = pPassEntity;
m_traceType = 0;
m_pExtraShouldHitCheckFunction = pExtraShouldHitCheckFn;
}

View File

@ -8,9 +8,60 @@
#ifndef CLIENT_DLL
#include "game/server/player.h"
#endif
#include "public/engine/IEngineTrace.h"
class CTraceFilterSimple;
#ifndef CLIENT_DLL
CPlayer* UTIL_PlayerByIndex(int nIndex);
#endif // CLIENT_DLL
inline CTraceFilterSimple* g_pTraceFilterSimpleVFTable = nullptr;
typedef bool (*ShouldHitFunc_t)(IHandleEntity* pHandleEntity, int contentsMask);
//-----------------------------------------------------------------------------
// traceline methods
//-----------------------------------------------------------------------------
class CTraceFilterSimple : public CTraceFilter
{
public:
// It does have a base, but we'll never network anything below here..
//DECLARE_CLASS_NOBASE(CTraceFilterSimple);
CTraceFilterSimple(const IHandleEntity* pPassEntity, int collisionGroup, ShouldHitFunc_t pExtraShouldHitCheckFn = NULL);
virtual void SetPassEntity(const IHandleEntity* pPassEntity) { m_pPassEntity = pPassEntity; }
virtual void SetCollisionGroup(int iCollisionGroup) { m_collisionGroup = iCollisionGroup; }
const IHandleEntity* GetPassEntity(void) { return m_pPassEntity; }
int GetCollisionGroup(void) const { return m_collisionGroup; }
private:
int m_collisionGroup;
const IHandleEntity* m_pPassEntity;
ShouldHitFunc_t m_pExtraShouldHitCheckFunction;
int m_traceType;
};
///////////////////////////////////////////////////////////////////////////////
class VUtil_Shared : public IDetour
{
virtual void GetAdr(void) const
{
spdlog::debug("| VAR: g_pTraceFilterSimpleVFTable : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_pTraceFilterSimpleVFTable));
spdlog::debug("+----------------------------------------------------------------+\n");
}
virtual void GetFun(void) const { }
virtual void GetVar(void) const { }
virtual void GetCon(void) const
{
g_GameDll.GetVirtualMethodTable(".?AVCTraceFilterSimple@@").RCast<CTraceFilterSimple*>();
}
virtual void Attach(void) const { }
virtual void Detach(void) const { }
};
///////////////////////////////////////////////////////////////////////////////
REGISTER(VUtil_Shared);
#endif // !UTIL_SHARED_H