mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Add 'UTIL_GetEntityScriptInfo' to SDK
Retrieves information for an entity, formats it as <className> <scriptName> [<edict>] or <className> [<edict>].
This commit is contained in:
parent
4c40114106
commit
177cf2ca55
@ -10,12 +10,17 @@
|
||||
#include "game/server/gameinterface.h"
|
||||
#endif // !CLIENT_DLL
|
||||
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: returns the player instance by edict
|
||||
//-----------------------------------------------------------------------------
|
||||
CPlayer* UTIL_PlayerByIndex(int nIndex)
|
||||
{
|
||||
if (nIndex < 1 || nIndex > (*g_pGlobals)->m_nMaxClients || nIndex == FL_EDICT_INVALID)
|
||||
if (nIndex < 1 || nIndex >(*g_pGlobals)->m_nMaxClients || nIndex == FL_EDICT_INVALID)
|
||||
{
|
||||
assert(0);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// !TODO: Improve this!!!
|
||||
CPlayer* pPlayer = reinterpret_cast<CPlayer*>((*g_pGlobals)->m_pEdicts[nIndex + 0x7808]);
|
||||
@ -23,6 +28,16 @@ CPlayer* UTIL_PlayerByIndex(int nIndex)
|
||||
}
|
||||
#endif // CLIENT_DLL
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: returns the class name, script name, and edict of the entity
|
||||
// returns "<<null>>" on NULL entity
|
||||
//-----------------------------------------------------------------------------
|
||||
const char* UTIL_GetEntityScriptInfo(CBaseEntity* pEnt)
|
||||
{
|
||||
assert(pEnt != nullptr);
|
||||
return v_UTIL_GetEntityScriptInfo(pEnt);
|
||||
}
|
||||
|
||||
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.
|
||||
|
@ -15,6 +15,10 @@ class CTraceFilterSimple;
|
||||
#ifndef CLIENT_DLL
|
||||
CPlayer* UTIL_PlayerByIndex(int nIndex);
|
||||
#endif // CLIENT_DLL
|
||||
const char* UTIL_GetEntityScriptInfo(CBaseEntity* pEnt);
|
||||
|
||||
inline CMemory p_UTIL_GetEntityScriptInfo;
|
||||
inline auto v_UTIL_GetEntityScriptInfo = p_UTIL_GetEntityScriptInfo.RCast<const char*(*)(CBaseEntity* pEnt)>();
|
||||
|
||||
inline CTraceFilterSimple* g_pTraceFilterSimpleVFTable = nullptr;
|
||||
typedef bool (*ShouldHitFunc_t)(IHandleEntity* pHandleEntity, int contentsMask);
|
||||
@ -49,9 +53,14 @@ class VUtil_Shared : public IDetour
|
||||
virtual void GetAdr(void) const
|
||||
{
|
||||
LogConAdr("CTraceFilterSimple::`vftable'", reinterpret_cast<uintptr_t>(g_pTraceFilterSimpleVFTable));
|
||||
LogFunAdr("UTIL_GetEntityScriptInfo", p_UTIL_GetEntityScriptInfo.GetPtr());
|
||||
}
|
||||
virtual void GetFun(void) const { }
|
||||
virtual void GetVar(void) const { }
|
||||
virtual void GetVar(void) const
|
||||
{
|
||||
p_UTIL_GetEntityScriptInfo = g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? 4C 8B 5E ??").FollowNearCallSelf();
|
||||
v_UTIL_GetEntityScriptInfo = p_UTIL_GetEntityScriptInfo.RCast<const char* (*)(CBaseEntity* pEnt)>();
|
||||
}
|
||||
virtual void GetCon(void) const
|
||||
{
|
||||
g_pTraceFilterSimpleVFTable = g_GameDll.GetVirtualMethodTable(".?AVCTraceFilterSimple@@").RCast<CTraceFilterSimple*>();
|
||||
|
Loading…
x
Reference in New Issue
Block a user