Box overlay progress

This commit is contained in:
Kawe Mazidjatari 2022-07-06 11:22:37 +02:00
parent 1b2c0cecd0
commit e45cba48be
2 changed files with 28 additions and 11 deletions

View File

@ -100,6 +100,23 @@ void DestroyOverlay(OverlayBase_t* pOverlay)
LeaveCriticalSection(&*s_OverlayMutex);
}
struct Vector8
{
vec_t x, y, z, w, a, s, d;
};
void DrawBoxTest(OverlayBox_t* pBox) // written in 10 sec, not an actual box..
{
v_RenderLine({ pBox->origin_X -100, pBox->origin_Y -100, pBox->origin_Z -100 }, { pBox->origin_X +100, pBox->origin_Y +100, pBox->origin_Z + pBox->maxs.z +100 }, Color(pBox->r, pBox->g, pBox->b, 255), false);
v_RenderLine({ pBox->origin_X +100, pBox->origin_Y -100, pBox->origin_Z -100 }, { pBox->origin_X +100, pBox->origin_Y +100, pBox->origin_Z + pBox->maxs.z -100 }, Color(pBox->r, pBox->g, pBox->b, 255), false);
v_RenderLine({ pBox->origin_X +100, pBox->origin_Y -100, pBox->origin_Z +100 }, { pBox->origin_X -100, pBox->origin_Y +100, pBox->origin_Z + pBox->maxs.z -100 }, Color(pBox->r, pBox->g, pBox->b, 255), false);
v_RenderLine({ pBox->origin_X -100, pBox->origin_Y -100, pBox->origin_Z +100 }, { pBox->origin_X -100, pBox->origin_Y +100, pBox->origin_Z + pBox->maxs.z +100 }, Color(pBox->r, pBox->g, pBox->b, 255), false);
v_RenderLine({ pBox->origin_X -100, pBox->origin_Y +100, pBox->origin_Z +100 }, { pBox->origin_X -100, pBox->origin_Y -100, pBox->origin_Z + pBox->maxs.z +100 }, Color(pBox->r, pBox->g, pBox->b, 255), false);
v_RenderLine({ pBox->origin_X -100, pBox->origin_Y +100, pBox->origin_Z -100 }, { pBox->origin_X +100, pBox->origin_Y -100, pBox->origin_Z + pBox->maxs.z +100 }, Color(pBox->r, pBox->g, pBox->b, 255), false);
v_RenderLine({ pBox->origin_X +100, pBox->origin_Y +100, pBox->origin_Z -100 }, { pBox->origin_X +100, pBox->origin_Y -100, pBox->origin_Z + pBox->maxs.z -100 }, Color(pBox->r, pBox->g, pBox->b, 255), false);
v_RenderLine({ pBox->origin_X +100, pBox->origin_Y +100, pBox->origin_Z +100 }, { pBox->origin_X -100, pBox->origin_Y -100, pBox->origin_Z + pBox->maxs.z -100 }, Color(pBox->r, pBox->g, pBox->b, 255), false);
}
//------------------------------------------------------------------------------
// Purpose: draws a generic overlay
//------------------------------------------------------------------------------
@ -116,11 +133,15 @@ void DrawOverlay(OverlayBase_t* pOverlay)
{
case OverlayType_t::OVERLAY_BOX:
{
OverlayBox_t* pBox = static_cast<OverlayBox_t*>(pOverlay); // TODO: debug this since it doesn't work but does compute something..
//printf("%p\n", pOverlay);
OverlayBox_t* pBox = static_cast<OverlayBox_t*>(pOverlay); // TODO: debug this since it doesn't work but does compute something..
// for testing, since RenderWireframeBox doesn't seem to work properly
//RenderWireframeSphere({ pBox->origin_X, pBox->origin_Y, pBox->origin_Z }, pBox->maxs.x, 8, 8, Color(pBox->r, pBox->g, pBox->b, 255), false);
//RenderLine({ pBox->origin_X, pBox->origin_Y, pBox->origin_Z }, { pBox->origin_X, pBox->origin_Y, pBox->origin_Z+pBox->maxs.z }, Color(pBox->r, pBox->g, pBox->b, 255), false);
//v_RenderWireframeBox({ pBox->origin_X, pBox->origin_Y, pBox->origin_Z }, pBox->maxs, {0,0,0}, Color(pBox->r, pBox->g, pBox->b, 255), false); // <-- currently broken!
//v_RenderWireframeSphere({ pBox->origin_X, pBox->origin_Y, pBox->origin_Z }, pBox->maxs.x, 8, 8, Color(pBox->r, pBox->g, pBox->b, 255), false);
//v_RenderLine({ pBox->origin_X, pBox->origin_Y, pBox->origin_Z }, { pBox->origin_X, pBox->origin_Y, pBox->origin_Z+pBox->maxs.z }, Color(pBox->r, pBox->g, pBox->b, 255), false);
//DrawBoxTest(pBox);
//if (pBox->a < 255)
//{
@ -245,11 +266,6 @@ void DrawAllOverlays(char pOverlay)
///////////////////////////////////////////////////////////////////////////////
void DebugOverlays_Attach()
{
//#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1)
// p_DrawAllOverlays.Offset(0x189).Patch({ 0x83, 0x3F, 0x02 }); // Default value in memory is 0x2, condition is 0x4. Patch to fullfill condition.
//#elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3)
// p_DrawAllOverlays.Offset(0x188).Patch({ 0x83, 0x3F, 0x02 }); // Default value in memory is 0x2, condition is 0x4. Patch to fullfill condition.
//#endif
DetourAttach((LPVOID*)&v_DrawAllOverlays, &DrawAllOverlays);
}

View File

@ -51,6 +51,7 @@ struct OverlayBase_t
int m_nServerCount {}; // Latch server count, too
OverlayBase_t* m_pNextOverlay {}; // 16
int m_nOverlayTick {}; // 24
int m_nFlags{}; // Maybe
};
struct OverlayLine_t : public OverlayBase_t
@ -106,8 +107,8 @@ void DebugOverlays_Detach();
inline CMemory p_DrawAllOverlays;
inline auto v_DrawAllOverlays = p_DrawAllOverlays.RCast<void (*)(char a1)>();
inline CMemory p_RenderWireframeBox;
inline auto v_RenderWireframeBox = p_RenderWireframeBox.RCast<void* (*)(Vector3 origin, QAngle angles, Vector3 vMins, Vector3 vMaxs, Color color, bool bZBuffer)>();
inline CMemory p_RenderWireframeBox; // one of the vector parameters is probably the angles, vmins might no longer be used.
inline auto v_RenderWireframeBox = p_RenderWireframeBox.RCast<void* (*)(Vector3 origin, Vector3 vMins, Vector3 vMaxs, Color color, bool bZBuffer)>();
inline CMemory p_RenderLine;
inline auto v_RenderLine = p_RenderLine.RCast<void* (*)(Vector3 origin, Vector3 dest, Color color, bool bZBuffer)>();
@ -160,7 +161,7 @@ class VDebugOverlay : public IDetour
v_DrawAllOverlays = p_DrawAllOverlays.RCast<void (*)(char)>(); /*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 */
v_RenderWireframeBox = p_RenderWireframeBox.RCast<void* (*)(Vector3, QAngle, Vector3, Vector3, Color, bool)>(); /*48 89 5C 24 ?? 48 89 6C 24 ?? 44 89 4C 24 ??*/
v_RenderWireframeBox = p_RenderWireframeBox.RCast<void* (*)(Vector3, Vector3, Vector3, Color, bool)>(); /*48 89 5C 24 ?? 48 89 6C 24 ?? 44 89 4C 24 ??*/
v_RenderWireframeSphere = p_RenderWireframeSphere.RCast<void* (*)(Vector3, float, int, int, Color, bool)>(); /*40 56 41 54 41 55 48 81 EC ?? ?? ?? ??*/
v_RenderLine = p_RenderLine.RCast<void* (*)(Vector3, Vector3, Color, bool)>(); /*48 89 74 24 ?? 44 89 44 24 ?? 57 41 56*/
}