From 034df40755d0ec038a38ef3e784736208fa2d373 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Thu, 16 Jun 2022 18:04:43 +0200 Subject: [PATCH] CClient::GetClient improvements --- r5dev/engine/client/client.cpp | 4 +++- r5dev/engine/client/client.h | 8 ++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/r5dev/engine/client/client.cpp b/r5dev/engine/client/client.cpp index cc216819..b186f8d3 100644 --- a/r5dev/engine/client/client.cpp +++ b/r5dev/engine/client/client.cpp @@ -6,6 +6,7 @@ // //===============================================================================// // client.cpp: implementation of the CClient class. +// /////////////////////////////////////////////////////////////////////////////////// #include "core/stdafx.h" #include "engine/client/client.h" @@ -15,7 +16,8 @@ //--------------------------------------------------------------------------------- CClient* CClient::GetClient(int nIndex) const { - return (CClient*)(std::uintptr_t)(g_pClientBuffer.GetPtr() + (nIndex * sizeof(CClient))); + return reinterpret_cast( + (reinterpret_cast(g_pClient) + (nIndex * sizeof(CClient)))); } //--------------------------------------------------------------------------------- diff --git a/r5dev/engine/client/client.h b/r5dev/engine/client/client.h index ca1f3752..0d3a599d 100644 --- a/r5dev/engine/client/client.h +++ b/r5dev/engine/client/client.h @@ -92,9 +92,6 @@ inline auto v_CClient_Connect = p_CClient_Connect.RCast(); -inline CMemory g_pClientBuffer; -extern CClient* g_pClient; - /////////////////////////////////////////////////////////////////////////////// void CBaseClient_Attach(); void CBaseClient_Detach(); @@ -119,9 +116,8 @@ class VClient : public IDetour } virtual void GetVar(void) const { - g_pClientBuffer = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x3B\x15\x00\x00\x00\x00\x7D\x33"), "xx????xx") - .FindPatternSelf("48 8D 0D", CMemory::Direction::DOWN, 150).ResolveRelativeAddressSelf(0x3, 0x7); - g_pClient = g_pClientBuffer.RCast(); + g_pClient = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x3B\x15\x00\x00\x00\x00\x7D\x33"), "xx????xx") + .FindPatternSelf("48 8D 0D", CMemory::Direction::DOWN, 150).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); } virtual void GetCon(void) const { } virtual void Attach(void) const { }