2022-01-04 12:11:59 +01:00
|
|
|
#pragma once
|
|
|
|
#include "mathlib/vector.h"
|
2022-07-12 12:28:23 +02:00
|
|
|
#include "mathlib/vector4d.h"
|
2023-04-01 20:54:10 +02:00
|
|
|
#include "mathlib/color.h"
|
|
|
|
#include "mathlib/ssemath.h"
|
2022-01-04 12:11:59 +01:00
|
|
|
|
|
|
|
// Something has to be hardcoded..
|
|
|
|
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) || defined (GAMEDLL_S2)
|
|
|
|
|
2022-01-05 02:07:37 +01:00
|
|
|
constexpr auto MATERIALSYSTEM_VCALL_OFF_0 = 0x3F8;
|
|
|
|
constexpr auto CMATQUEUEDRENDERCONTEXT_VCALL_OFS_0 = 0x278;
|
|
|
|
constexpr auto CMATQUEUEDRENDERCONTEXT_VCALL_OFS_1 = 0x280;
|
2022-01-04 12:11:59 +01:00
|
|
|
|
|
|
|
#elif defined (GAMEDLL_S3)
|
|
|
|
|
|
|
|
constexpr auto MATERIALSYSTEM_VCALL_OFF_0 = 0x3F0;
|
|
|
|
constexpr auto CMATQUEUEDRENDERCONTEXT_VCALL_OFS_0 = 0x288;
|
|
|
|
constexpr auto CMATQUEUEDRENDERCONTEXT_VCALL_OFS_1 = 0x290;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
constexpr auto CMATQUEUEDRENDERCONTEXT_VCALL_OFS_2 = 0x8;
|
|
|
|
constexpr auto NDEBUG_PERSIST_TILL_NEXT_SERVER = (0.01023f);
|
|
|
|
|
|
|
|
enum class OverlayType_t
|
|
|
|
{
|
|
|
|
OVERLAY_BOX = 0,
|
|
|
|
OVERLAY_SPHERE,
|
|
|
|
OVERLAY_LINE,
|
|
|
|
OVERLAY_TRIANGLE,
|
2022-10-30 23:38:19 +01:00
|
|
|
OVERLAY_LASER_LINE,
|
2022-01-04 12:11:59 +01:00
|
|
|
OVERLAY_BOX2,
|
|
|
|
OVERLAY_CAPSULE,
|
|
|
|
OVERLAY_UNK0,
|
|
|
|
OVERLAY_UNK1
|
|
|
|
};
|
|
|
|
|
|
|
|
struct OverlayBase_t
|
|
|
|
{
|
2022-03-07 11:32:12 +01:00
|
|
|
OverlayBase_t(void)
|
2022-01-04 12:11:59 +01:00
|
|
|
{
|
|
|
|
m_Type = OverlayType_t::OVERLAY_BOX;
|
|
|
|
m_nCreationTick = -1;
|
|
|
|
m_flEndTime = 0.0f;
|
2022-06-15 01:24:29 +02:00
|
|
|
m_nServerCount = -1;
|
2022-01-04 12:11:59 +01:00
|
|
|
m_pNextOverlay = NULL;
|
2022-06-15 01:24:29 +02:00
|
|
|
m_nOverlayTick = NULL;
|
2022-11-02 14:30:04 +01:00
|
|
|
m_nFlags = NULL;
|
2022-01-04 12:11:59 +01:00
|
|
|
}
|
2022-03-07 11:32:12 +01:00
|
|
|
bool IsDead(void) const;
|
2022-01-04 12:11:59 +01:00
|
|
|
|
2023-01-24 18:43:00 +01:00
|
|
|
OverlayType_t m_Type; // What type of overlay is it?
|
|
|
|
int m_nCreationTick; // Duration -1 means go away after this frame #
|
|
|
|
float m_flEndTime; // When does this box go away
|
|
|
|
int m_nServerCount; // Latch server count, too
|
|
|
|
OverlayBase_t* m_pNextOverlay; // 16
|
|
|
|
int m_nOverlayTick; // 24
|
|
|
|
int m_nFlags; // Maybe
|
2022-01-04 12:11:59 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct OverlayBox_t : public OverlayBase_t
|
|
|
|
{
|
2022-03-07 11:32:12 +01:00
|
|
|
OverlayBox_t(void) { m_Type = OverlayType_t::OVERLAY_BOX; }
|
2022-01-04 12:11:59 +01:00
|
|
|
|
2022-07-11 12:00:08 +02:00
|
|
|
struct Transforms
|
|
|
|
{
|
2022-07-12 12:28:23 +02:00
|
|
|
Transforms()
|
|
|
|
{
|
2023-04-01 20:54:10 +02:00
|
|
|
xmm[0] = LoadZeroSIMD();
|
|
|
|
xmm[1] = LoadZeroSIMD();
|
|
|
|
xmm[2] = LoadZeroSIMD();
|
2022-07-12 12:28:23 +02:00
|
|
|
};
|
|
|
|
union
|
|
|
|
{
|
2023-04-01 20:54:10 +02:00
|
|
|
fltx4 xmm[3];
|
|
|
|
matrix3x4a_t mat;
|
2022-07-12 12:28:23 +02:00
|
|
|
};
|
2022-07-11 12:00:08 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
Transforms transforms;
|
2023-01-24 18:43:00 +01:00
|
|
|
Vector3D mins;
|
|
|
|
Vector3D maxs;
|
|
|
|
int r;
|
|
|
|
int g;
|
|
|
|
int b;
|
|
|
|
int a;
|
|
|
|
bool noDepthTest;
|
2022-01-04 12:11:59 +01:00
|
|
|
};
|
|
|
|
|
2022-03-07 11:32:12 +01:00
|
|
|
struct OverlaySphere_t : public OverlayBase_t
|
|
|
|
{
|
|
|
|
OverlaySphere_t(void) { m_Type = OverlayType_t::OVERLAY_SPHERE; }
|
|
|
|
|
2023-01-24 18:43:00 +01:00
|
|
|
Vector3D vOrigin;
|
|
|
|
float flRadius;
|
|
|
|
int nTheta;
|
|
|
|
int nPhi;
|
|
|
|
int r;
|
|
|
|
int g;
|
|
|
|
int b;
|
|
|
|
int a;
|
2022-03-07 11:32:12 +01:00
|
|
|
};
|
|
|
|
|
2022-10-30 23:38:19 +01:00
|
|
|
struct OverlayLine_t : public OverlayBase_t
|
|
|
|
{
|
|
|
|
OverlayLine_t(void) { m_Type = OverlayType_t::OVERLAY_LINE; }
|
|
|
|
|
2023-01-24 18:43:00 +01:00
|
|
|
Vector3D origin;
|
|
|
|
Vector3D dest;
|
|
|
|
int r;
|
|
|
|
int g;
|
|
|
|
int b;
|
|
|
|
int a;
|
|
|
|
bool noDepthTest;
|
2022-10-30 23:38:19 +01:00
|
|
|
};
|
|
|
|
|
2022-07-07 21:31:00 +02:00
|
|
|
struct OverlayTriangle_t : public OverlayBase_t
|
|
|
|
{
|
|
|
|
OverlayTriangle_t() { m_Type = OverlayType_t::OVERLAY_TRIANGLE; }
|
|
|
|
|
|
|
|
Vector3D p1;
|
|
|
|
Vector3D p2;
|
|
|
|
Vector3D p3;
|
|
|
|
int r;
|
|
|
|
int g;
|
|
|
|
int b;
|
|
|
|
int a;
|
|
|
|
bool noDepthTest;
|
|
|
|
};
|
|
|
|
|
2022-10-30 23:38:19 +01:00
|
|
|
struct OverlayLaserLine_t : public OverlayBase_t
|
2022-07-07 21:31:00 +02:00
|
|
|
{
|
2022-10-30 23:38:19 +01:00
|
|
|
OverlayLaserLine_t() { m_Type = OverlayType_t::OVERLAY_LASER_LINE; }
|
2022-07-07 21:31:00 +02:00
|
|
|
|
|
|
|
Vector3D start;
|
|
|
|
Vector3D end;
|
|
|
|
int r;
|
|
|
|
int g;
|
|
|
|
int b;
|
|
|
|
int a;
|
2022-10-30 23:38:19 +01:00
|
|
|
bool noDepthTest;
|
2022-07-07 21:31:00 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct OverlayCapsule_t : public OverlayBase_t
|
|
|
|
{
|
|
|
|
OverlayCapsule_t() { m_Type = OverlayType_t::OVERLAY_CAPSULE; }
|
|
|
|
|
|
|
|
Vector3D start;
|
|
|
|
Vector3D end;
|
|
|
|
Vector3D radius;
|
|
|
|
Vector3D top;
|
|
|
|
Vector3D bottom;
|
|
|
|
int r;
|
|
|
|
int g;
|
|
|
|
int b;
|
|
|
|
int a;
|
|
|
|
bool m_bWireframe;
|
|
|
|
};
|
|
|
|
|
2022-06-15 01:35:48 +02:00
|
|
|
void DestroyOverlay(OverlayBase_t* pOverlay);
|
2022-01-04 12:11:59 +01:00
|
|
|
void DrawOverlay(OverlayBase_t* pOverlay);
|
|
|
|
|
2022-04-18 03:35:08 +02:00
|
|
|
inline CMemory p_DrawAllOverlays;
|
2022-07-11 12:00:08 +02:00
|
|
|
inline auto v_DrawAllOverlays = p_DrawAllOverlays.RCast<void (*)(bool bDraw)>();
|
2022-01-04 12:11:59 +01:00
|
|
|
|
2022-08-18 02:15:23 +02:00
|
|
|
inline CMemory p_DestroyOverlay;
|
|
|
|
inline auto v_DestroyOverlay = p_DestroyOverlay.RCast<void (*)(OverlayBase_t* pOverlay)>();
|
|
|
|
|
2022-04-18 03:35:08 +02:00
|
|
|
inline CMemory p_RenderLine;
|
2022-07-10 14:30:28 +02:00
|
|
|
inline auto v_RenderLine = p_RenderLine.RCast<void* (*)(const Vector3D& vOrigin, const Vector3D& vDest, Color color, bool bZBuffer)>();
|
|
|
|
|
|
|
|
inline CMemory p_RenderBox;
|
2023-01-23 02:20:21 +01:00
|
|
|
inline auto v_RenderBox = p_RenderBox.RCast<void* (*)(const matrix3x4_t& vTransforms, const Vector3D& vMins, const Vector3D& vMaxs, Color color, bool bZBuffer)>();
|
2022-06-15 01:24:29 +02:00
|
|
|
|
|
|
|
inline CMemory p_RenderWireframeSphere;
|
2022-07-10 14:30:28 +02:00
|
|
|
inline auto v_RenderWireframeSphere = p_RenderWireframeSphere.RCast<void* (*)(const Vector3D& vCenter, float flRadius, int nTheta, int nPhi, Color color, bool bZBuffer)>();
|
2022-01-04 12:11:59 +01:00
|
|
|
|
2022-04-18 03:35:08 +02:00
|
|
|
inline OverlayBase_t** s_pOverlays = nullptr;
|
|
|
|
inline LPCRITICAL_SECTION s_OverlayMutex = nullptr;
|
2022-01-04 12:11:59 +01:00
|
|
|
|
2022-08-18 02:15:23 +02:00
|
|
|
inline int* g_nRenderTickCount = nullptr;
|
|
|
|
inline int* g_nOverlayTickCount = nullptr;
|
2022-01-04 12:11:59 +01:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2022-05-13 14:53:25 +02:00
|
|
|
class VDebugOverlay : public IDetour
|
2022-01-04 12:11:59 +01:00
|
|
|
{
|
2022-04-11 01:44:30 +02:00
|
|
|
virtual void GetAdr(void) const
|
2022-01-04 12:11:59 +01:00
|
|
|
{
|
2023-01-25 02:26:52 +01:00
|
|
|
LogFunAdr("DrawAllOverlays", p_DrawAllOverlays.GetPtr());
|
|
|
|
LogFunAdr("DestroyOverlay", p_DestroyOverlay.GetPtr());
|
|
|
|
LogFunAdr("RenderLine", p_RenderLine.GetPtr());
|
|
|
|
LogFunAdr("RenderBox", p_RenderBox.GetPtr());
|
|
|
|
LogFunAdr("RenderWireframeSphere", p_RenderWireframeSphere.GetPtr());
|
2023-01-31 16:21:51 +01:00
|
|
|
LogVarAdr("s_Overlays", reinterpret_cast<uintptr_t>(s_pOverlays));
|
2023-01-25 02:26:52 +01:00
|
|
|
LogVarAdr("s_OverlayMutex", reinterpret_cast<uintptr_t>(s_OverlayMutex));
|
|
|
|
LogVarAdr("g_nOverlayTickCount", reinterpret_cast<uintptr_t>(g_nOverlayTickCount));
|
|
|
|
LogVarAdr("g_nRenderTickCount", reinterpret_cast<uintptr_t>(g_nRenderTickCount));
|
2022-01-04 12:11:59 +01:00
|
|
|
}
|
2022-04-18 03:35:08 +02:00
|
|
|
virtual void GetFun(void) const
|
|
|
|
{
|
|
|
|
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1)
|
2022-12-01 22:44:55 +01:00
|
|
|
p_DrawAllOverlays = g_GameDll.FindPatternSIMD("40 55 48 83 EC 50 48 8B 05 ?? ?? ?? ??");
|
|
|
|
p_RenderBox = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 44 89 4C 24 ?? 55 41 56");
|
2022-04-18 03:35:08 +02:00
|
|
|
#elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3)
|
2022-12-01 22:44:55 +01:00
|
|
|
p_DrawAllOverlays = g_GameDll.FindPatternSIMD("40 55 48 83 EC 30 48 8B 05 ?? ?? ?? ?? 0F B6 E9");
|
|
|
|
p_RenderBox = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 44 89 4C 24 ??");
|
2022-04-18 03:35:08 +02:00
|
|
|
#endif
|
2022-12-01 22:44:55 +01:00
|
|
|
p_DestroyOverlay = g_GameDll.FindPatternSIMD("40 53 48 83 EC 20 48 8B D9 48 8D 0D ?? ?? ?? ?? FF 15 ?? ?? ?? ?? 48 63 03");
|
|
|
|
p_RenderWireframeSphere = g_GameDll.FindPatternSIMD("40 56 41 54 41 55 48 81 EC ?? ?? ?? ??");
|
|
|
|
p_RenderLine = g_GameDll.FindPatternSIMD("48 89 74 24 ?? 44 89 44 24 ?? 57 41 56");
|
2022-04-18 03:35:08 +02:00
|
|
|
|
2022-07-11 12:00:08 +02:00
|
|
|
v_DrawAllOverlays = p_DrawAllOverlays.RCast<void (*)(bool)>(); /*40 55 48 83 EC 30 48 8B 05 ?? ?? ?? ?? 0F B6 E9*/
|
|
|
|
v_DestroyOverlay = p_DestroyOverlay.RCast<void (*)(OverlayBase_t*)>(); /*40 53 48 83 EC 20 48 8B D9 48 8D 0D ?? ?? ?? ?? FF 15 ?? ?? ?? ?? 48 63 03 */
|
2023-01-23 02:20:21 +01:00
|
|
|
v_RenderBox = p_RenderBox.RCast<void* (*)(const matrix3x4_t&, const Vector3D&, const Vector3D&, Color, bool)>(); /*48 89 5C 24 ?? 48 89 6C 24 ?? 44 89 4C 24 ??*/
|
2022-07-11 12:00:08 +02:00
|
|
|
v_RenderWireframeSphere = p_RenderWireframeSphere.RCast<void* (*)(const Vector3D&, float, int, int, Color, bool)>(); /*40 56 41 54 41 55 48 81 EC ?? ?? ?? ??*/
|
|
|
|
v_RenderLine = p_RenderLine.RCast<void* (*)(const Vector3D&, const Vector3D&, Color, bool)>(); /*48 89 74 24 ?? 44 89 44 24 ?? 57 41 56*/
|
2022-04-18 03:35:08 +02:00
|
|
|
}
|
|
|
|
virtual void GetVar(void) const
|
|
|
|
{
|
|
|
|
s_pOverlays = p_DrawAllOverlays.Offset(0x10).FindPatternSelf("48 8B 3D", CMemory::Direction::DOWN, 150).ResolveRelativeAddressSelf(0x3, 0x7).RCast<OverlayBase_t**>();
|
|
|
|
s_OverlayMutex = p_DrawAllOverlays.Offset(0x10).FindPatternSelf("48 8D 0D", CMemory::Direction::DOWN, 150).ResolveRelativeAddressSelf(0x3, 0x7).RCast<LPCRITICAL_SECTION>();
|
|
|
|
|
|
|
|
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1)
|
2022-08-18 02:15:23 +02:00
|
|
|
g_nRenderTickCount = p_DrawAllOverlays.Offset(0x80).FindPatternSelf("3B 0D", CMemory::Direction::DOWN, 150).ResolveRelativeAddressSelf(0x2, 0x6).RCast<int*>();
|
|
|
|
g_nOverlayTickCount = p_DrawAllOverlays.Offset(0x70).FindPatternSelf("3B 0D", CMemory::Direction::DOWN, 150).ResolveRelativeAddressSelf(0x2, 0x6).RCast<int*>();
|
2022-04-18 03:35:08 +02:00
|
|
|
#elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3)
|
2022-08-18 02:15:23 +02:00
|
|
|
g_nRenderTickCount = p_DrawAllOverlays.Offset(0x50).FindPatternSelf("3B 05", CMemory::Direction::DOWN, 150).ResolveRelativeAddressSelf(0x2, 0x6).RCast<int*>();
|
|
|
|
g_nOverlayTickCount = p_DrawAllOverlays.Offset(0x70).FindPatternSelf("3B 05", CMemory::Direction::DOWN, 150).ResolveRelativeAddressSelf(0x2, 0x6).RCast<int*>();
|
2022-04-18 03:35:08 +02:00
|
|
|
#endif
|
|
|
|
}
|
2022-04-11 01:44:30 +02:00
|
|
|
virtual void GetCon(void) const { }
|
2023-01-25 02:26:52 +01:00
|
|
|
virtual void Attach(void) const;
|
|
|
|
virtual void Detach(void) const;
|
2022-01-04 12:11:59 +01:00
|
|
|
};
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|