mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
This change was planned for a long time. This moves all REGISTER calls to a single translation unit, this is required as we currently added a very dirty workaround for not registering duplicates by checking if VFTable pointer was already present in the vector... Registering from single translation unit prevents duplicate instances that gets created if header is included by more cpp files. Reworking this reduced 100kb+ of compiled code. This commit also reworked the way functions/variables/constant gets logged with their addresses; the new code formats them on the fly, and allows for resize at any time. Formatting is no longer required by programmer. TODO: currently there are some compile errors for dedicated and client dll's. These will be resolved very soon as they need to be properly worked out still (server & client only stuff needs to be properly split). Use the 'main' (stable) branch for the time being if you need to compile these dll's.
59 lines
2.5 KiB
C++
59 lines
2.5 KiB
C++
#pragma once
|
|
|
|
//-------------------------------------------------------------------------------------
|
|
// Forward declarations
|
|
//-------------------------------------------------------------------------------------
|
|
class VMatrix;
|
|
|
|
class CViewRender
|
|
{
|
|
public:
|
|
VMatrix* GetWorldMatrixForView(int8_t slot);
|
|
};
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
const Vector3D& MainViewOrigin();
|
|
const QAngle& MainViewAngles();
|
|
|
|
inline CMemory p_CViewRender_GetWorldMatrixForView;
|
|
inline auto CViewRender_GetWorldMatrixForView = p_CViewRender_GetWorldMatrixForView.RCast<VMatrix*(*)(CViewRender*, int8_t)>();
|
|
|
|
inline Vector3D* g_vecRenderOrigin = nullptr;
|
|
inline QAngle* g_vecRenderAngles = nullptr;
|
|
|
|
inline CViewRender* g_pViewRender = nullptr;
|
|
inline CMemory g_pViewRender_VFTable;
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
class V_ViewRender : public IDetour
|
|
{
|
|
virtual void GetAdr(void) const
|
|
{
|
|
LogFunAdr("CViewRender::GetWorldMatrixForView", p_CViewRender_GetWorldMatrixForView.GetPtr());
|
|
LogVarAdr("g_vecRenderOrigin", reinterpret_cast<uintptr_t>(g_vecRenderOrigin));
|
|
LogVarAdr("g_vecRenderAngles", reinterpret_cast<uintptr_t>(g_vecRenderAngles));
|
|
LogVarAdr("g_pViewRender", reinterpret_cast<uintptr_t>(g_pViewRender));
|
|
LogConAdr("CViewRender (VFTable)", g_pViewRender_VFTable.GetPtr());
|
|
}
|
|
virtual void GetFun(void) const
|
|
{
|
|
g_pViewRender_VFTable = g_GameDll.GetVirtualMethodTable(".?AVCViewRender@@");
|
|
|
|
p_CViewRender_GetWorldMatrixForView = g_pViewRender_VFTable.WalkVTable(16).Deref(); // 16th vfunc.
|
|
CViewRender_GetWorldMatrixForView = p_CViewRender_GetWorldMatrixForView.RCast<VMatrix* (*)(CViewRender*, int8_t)>();
|
|
}
|
|
virtual void GetVar(void) const
|
|
{
|
|
CMemory base = g_GameDll.FindPatternSIMD("48 89 74 24 ?? 57 48 83 EC 30 F3 0F 10 05 ?? ?? ?? ?? ?? 8B ??");
|
|
|
|
g_vecRenderOrigin = base.Offset(0x00).FindPatternSelf("F3 0F 10 05").ResolveRelativeAddressSelf(0x4, 0x8).RCast<Vector3D*>();
|
|
g_vecRenderAngles = base.Offset(0x30).FindPatternSelf("F3 0F 10 0D").ResolveRelativeAddressSelf(0x4, 0x8).RCast<QAngle*>();
|
|
|
|
g_pViewRender = g_GameDll.FindPatternSIMD("48 8D 05 ?? ?? ?? ?? C3 CC CC CC CC CC CC CC CC CC CC 48 8B C4").ResolveRelativeAddressSelf(0x3, 0x7).RCast<CViewRender*>(); /*48 8D 05 ?? ?? ?? ?? C3 CC CC CC CC CC CC CC CC CC CC 48 8B C4*/
|
|
}
|
|
virtual void GetCon(void) const { }
|
|
virtual void Attach(void) const { }
|
|
virtual void Detach(void) const { }
|
|
};
|
|
///////////////////////////////////////////////////////////////////////////////
|