2021-12-25 22:36:38 +01:00
# pragma once
2022-07-15 19:22:02 +02:00
# ifndef DEDICATED // We should think about not including this file at all in dedicated tbh.
2022-08-09 17:18:07 +02:00
# include "public/client_class.h"
# include "public/icliententitylist.h"
2022-07-24 13:40:37 +02:00
# endif // !DEDICATED
2021-12-25 22:36:38 +01:00
enum class ClientFrameStage_t : int
{
FRAME_UNDEFINED = - 1 , // (haven't run any frames yet)
FRAME_START ,
// A network packet is being recieved
FRAME_NET_UPDATE_START ,
// Data has been received and we're going to start calling PostDataUpdate
FRAME_NET_UPDATE_POSTDATAUPDATE_START ,
// Data has been received and we've called PostDataUpdate on all data recipients
FRAME_NET_UPDATE_POSTDATAUPDATE_END ,
// We've received all packets, we can now do interpolation, prediction, etc..
FRAME_NET_UPDATE_END ,
// We're about to start rendering the scene
FRAME_RENDER_START ,
// We've finished rendering the scene.
FRAME_RENDER_END ,
FRAME_NET_FULL_FRAME_UPDATE_ON_REMOVE
} ;
class CHLClient
{
public :
2022-04-13 01:25:33 +02:00
static void FrameStageNotify ( CHLClient * pHLClient , ClientFrameStage_t curStage ) ;
2022-07-15 19:22:02 +02:00
# ifndef DEDICATED
2022-05-02 23:53:26 +02:00
ClientClass * GetAllClasses ( ) ;
2022-07-15 19:22:02 +02:00
# endif
2022-01-17 03:35:40 +01:00
void * /* CUserCmd* */ GetUserCmd ( int sequenceNumber ) // @0x1405BB020 in R5pc_r5launch_N1094_CL456479_2019_10_30_05_20_PM
{
2022-08-09 02:35:00 +02:00
const int index = 28 ;
2022-01-23 18:26:48 +01:00
return CallVFunc < void * > ( index , this , sequenceNumber ) ; /*48 83 EC 28 48 8B 05 ? ? ? ? 48 8D 0D ? ? ? ? 44 8B C2*/
2022-01-17 03:35:40 +01:00
}
2021-12-25 22:36:38 +01:00
} ;
2022-04-09 02:18:57 +02:00
/* ==== CHLCLIENT ======================================================================================================================================================= */
2022-05-04 21:10:46 +02:00
# ifndef DEDICATED
2022-04-18 03:35:08 +02:00
inline CMemory p_CHLClient_PostInit ;
inline auto CHLClient_PostInit = p_CHLClient_PostInit . RCast < void * ( * ) ( void ) > ( ) ;
2022-05-04 21:10:46 +02:00
# endif // !DEDICATED
2022-04-18 03:35:08 +02:00
inline CMemory p_CHLClient_LevelShutdown ;
inline auto CHLClient_LevelShutdown = p_CHLClient_LevelShutdown . RCast < void * ( * ) ( CHLClient * thisptr ) > ( ) ;
2022-02-19 16:42:40 +01:00
2022-04-18 03:35:08 +02:00
inline CMemory p_CHLClient_HudProcessInput ;
inline auto CHLClient_HudProcessInput = p_CHLClient_HudProcessInput . RCast < void ( * ) ( CHLClient * thisptr , bool bActive ) > ( ) ;
2022-05-04 21:10:46 +02:00
# ifndef DEDICATED
inline CMemory p_CHLClient_FrameStageNotify ;
inline auto CHLClient_FrameStageNotify = p_CHLClient_FrameStageNotify . RCast < void ( * ) ( CHLClient * thisptr , ClientFrameStage_t frameStage ) > ( ) ;
2022-01-04 11:53:54 +01:00
2022-05-02 23:53:26 +02:00
inline CMemory p_CHLClient_GetAllClasses ;
inline auto CHLClient_GetAllClasses = p_CHLClient_GetAllClasses . RCast < ClientClass * ( * ) ( ) > ( ) ;
2022-05-04 21:10:46 +02:00
# endif // !DEDICATED
2022-04-14 19:18:59 +02:00
2022-04-18 03:35:08 +02:00
inline CHLClient * gHLClient = nullptr ;
inline CHLClient * g_pHLClient = nullptr ;
2022-07-24 13:40:37 +02:00
# ifndef DEDICATED
inline IClientEntityList * g_pClientEntityList = nullptr ;
# endif // !DEDICATED
2021-12-25 22:36:38 +01:00
///////////////////////////////////////////////////////////////////////////////
void CHLClient_Attach ( ) ;
void CHLClient_Detach ( ) ;
///////////////////////////////////////////////////////////////////////////////
2022-05-13 14:53:25 +02:00
class VDll_Engine_Int : public IDetour
2021-12-25 22:36:38 +01:00
{
2022-04-11 01:44:30 +02:00
virtual void GetAdr ( void ) const
2021-12-25 22:36:38 +01:00
{
2022-04-14 19:18:59 +02:00
# ifndef DEDICATED
2022-05-13 14:53:25 +02:00
spdlog : : debug ( " | FUN: CHLClient::PostInit : {:#18x} | \n " , p_CHLClient_PostInit . GetPtr ( ) ) ;
2022-05-04 21:10:46 +02:00
# endif // !DEDICATED
2022-05-13 14:53:25 +02:00
spdlog : : debug ( " | FUN: CHLClient::LevelShutdown : {:#18x} | \n " , p_CHLClient_LevelShutdown . GetPtr ( ) ) ;
spdlog : : debug ( " | FUN: CHLClient::HudProcessInput : {:#18x} | \n " , p_CHLClient_HudProcessInput . GetPtr ( ) ) ;
2022-05-04 21:10:46 +02:00
# ifndef DEDICATED
2022-05-13 14:53:25 +02:00
spdlog : : debug ( " | FUN: CHLClient::FrameStageNotify : {:#18x} | \n " , p_CHLClient_FrameStageNotify . GetPtr ( ) ) ;
spdlog : : debug ( " | FUN: CHLClient::GetAllClasses : {:#18x} | \n " , p_CHLClient_GetAllClasses . GetPtr ( ) ) ;
2022-04-14 19:18:59 +02:00
# endif // !DEDICATED
2022-05-13 14:53:25 +02:00
spdlog : : debug ( " | VAR: gHLClient : {:#18x} | \n " , reinterpret_cast < uintptr_t > ( gHLClient ) ) ;
spdlog : : debug ( " | VAR: g_pHLClient : {:#18x} | \n " , reinterpret_cast < uintptr_t > ( g_pHLClient ) ) ;
spdlog : : debug ( " +----------------------------------------------------------------+ \n " ) ;
2021-12-25 22:36:38 +01:00
}
2022-04-18 03:35:08 +02:00
virtual void GetFun ( void ) const
{
# if defined (GAMEDLL_S0) || defined (GAMEDLL_S1)
2022-08-09 03:02:00 +02:00
p_CHLClient_LevelShutdown = g_GameDll . FindPatternSIMD ( reinterpret_cast < rsig_t > ( " \x40 \x53 \x56 \x41 \x54 \x41 \x56 \x48 \x83 \xEC \x28 \x48 \x8B \xF1 " ) , " xxxxxxxxxxxxxx " ) ;
2022-05-04 21:10:46 +02:00
# ifndef DEDICATED
2022-08-09 03:02:00 +02:00
p_CHLClient_PostInit = g_GameDll . FindPatternSIMD ( reinterpret_cast < rsig_t > ( " \x48 \x83 \x3D \x00 \x00 \x00 \x00 \x00 \x48 \x8D \x05 \x00 \x00 \x00 \x00 \x48 \x89 \x05 \x00 \x00 \x00 \x00 \x48 \x8D \x05 \x00 \x00 \x00 \x00 \x48 \x89 \x05 \x00 \x00 \x00 \x00 \x48 \x8D \x05 \x00 \x00 \x00 \x00 \x48 \x89 \x05 \x00 \x00 \x00 \x00 \x48 \x8D \x05 \x00 \x00 \x00 \x00 \x48 \x89 \x05 \x00 \x00 \x00 \x00 \x48 \x8D \x05 \x00 \x00 \x00 \x00 \x48 \x89 \x05 \x00 \x00 \x00 \x00 \x48 \x8D \x05 \x00 \x00 \x00 \x00 \x48 \x89 \x05 \x00 \x00 \x00 \x00 \x48 \x8D \x05 \x00 \x00 \x00 \x00 \x48 \x89 \x05 \x00 \x00 \x00 \x00 \x48 \x8D \x05 \x00 \x00 \x00 \x00 \x48 \x89 \x05 \x00 \x00 \x00 \x00 \x48 \x8D \x05 \x00 \x00 \x00 \x00 " ) , " xxx?????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx???? " ) ;
p_CHLClient_FrameStageNotify = g_GameDll . FindPatternSIMD ( reinterpret_cast < rsig_t > ( " \x48 \x83 \xEC \x38 \x89 \x15 \x00 \x00 \x00 \x00 " ) , " xxxxxx???? " ) ;
p_CHLClient_GetAllClasses = g_GameDll . FindPatternSIMD ( reinterpret_cast < rsig_t > ( " \x48 \x8B \x05 \x00 \x00 \x00 \x00 \xC3 \xCC \xCC \xCC \xCC \xCC \xCC \xCC \xCC \x48 \x89 \x74 \x24 \x00 " ) , " xxx????xxxxxxxxxxxxx? " ) ;
2022-05-04 21:10:46 +02:00
# endif // !DEDICATED
2022-04-18 03:35:08 +02:00
# elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3)
2022-08-09 03:02:00 +02:00
p_CHLClient_LevelShutdown = g_GameDll . FindPatternSIMD ( reinterpret_cast < rsig_t > ( " \x48 \x89 \x5C \x24 \x00 \x48 \x89 \x6C \x24 \x00 \x48 \x89 \x74 \x24 \x00 \x57 \x48 \x83 \xEC \x20 \x48 \x8B \xF9 \x48 \x8D \x0D \x00 \x00 \x00 \x00 " ) , " xxxx?xxxx?xxxx?xxxxxxxxxxx???? " ) ;
2022-05-04 21:10:46 +02:00
# ifndef DEDICATED
2022-08-09 03:02:00 +02:00
p_CHLClient_PostInit = g_GameDll . FindPatternSIMD ( reinterpret_cast < rsig_t > ( " \x48 \x83 \xEC \x28 \x48 \x83 \x3D \x00 \x00 \x00 \x00 \x00 \x48 \x8D \x05 \x00 \x00 \x00 \x00 " ) , " xxxxxxx?????xxx???? " ) ;
p_CHLClient_FrameStageNotify = g_GameDll . FindPatternSIMD ( reinterpret_cast < rsig_t > ( " \x48 \x83 \xEC \x28 \x89 \x15 \x00 \x00 \x00 \x00 " ) , " xxxxxx???? " ) ;
p_CHLClient_GetAllClasses = g_GameDll . FindPatternSIMD ( reinterpret_cast < rsig_t > ( " \x48 \x8B \x05 \x00 \x00 \x00 \x00 \xC3 \xCC \xCC \xCC \xCC \xCC \xCC \xCC \xCC \x48 \x8B \x05 \x00 \x00 \x00 \x00 \x48 \x8D \x0D \x00 \x00 \x00 \x00 " ) , " xxx????xxxxxxxxxxxx????xxx???? " ) ;
2022-05-04 21:10:46 +02:00
# endif // !DEDICATED
2022-04-18 03:35:08 +02:00
# endif
2022-08-09 03:02:00 +02:00
p_CHLClient_HudProcessInput = g_GameDll . FindPatternSIMD ( reinterpret_cast < rsig_t > ( " \x48 \x83 \xEC \x28 \x0F \xB6 \x0D \x00 \x00 \x00 \x00 \x88 \x15 \x00 \x00 \x00 \x00 " ) , " xxxxxxx????xx???? " ) ;
2022-05-04 21:10:46 +02:00
# ifndef DEDICATED
2022-05-02 23:53:26 +02:00
CHLClient_LevelShutdown = p_CHLClient_LevelShutdown . RCast < void * ( * ) ( CHLClient * ) > ( ) ; /*48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 48 8B F9 48 8D 0D ?? ?? ?? ??*/
2022-05-04 21:10:46 +02:00
CHLClient_PostInit = p_CHLClient_PostInit . RCast < void * ( * ) ( void ) > ( ) ; /*48 83 EC 28 48 83 3D ?? ?? ?? ?? ?? 48 8D 05 ?? ?? ?? ??*/
2022-04-18 03:35:08 +02:00
CHLClient_FrameStageNotify = p_CHLClient_FrameStageNotify . RCast < void ( * ) ( CHLClient * , ClientFrameStage_t ) > ( ) ; /*48 83 EC 28 89 15 ?? ?? ?? ??*/
CHLClient_HudProcessInput = p_CHLClient_HudProcessInput . RCast < void ( * ) ( CHLClient * , bool ) > ( ) ; /*48 83 EC 28 0F B6 0D ?? ?? ?? ?? 88 15 ?? ?? ?? ??*/
2022-05-02 23:53:26 +02:00
CHLClient_GetAllClasses = p_CHLClient_GetAllClasses . RCast < ClientClass * ( * ) ( ) > ( ) ; /*48 8B 05 ? ? ? ? C3 CC CC CC CC CC CC CC CC 48 8B 05 ? ? ? ? 48 8D 0D ? ? ? ?*/
2022-05-04 21:10:46 +02:00
# endif // !DEDICATED
2022-04-18 03:35:08 +02:00
}
virtual void GetVar ( void ) const
{
2022-08-09 03:02:00 +02:00
gHLClient = g_GameDll . FindPatternSIMD ( reinterpret_cast < rsig_t >
2022-04-18 03:35:08 +02:00
( " \x48 \x8D \x05 \x00 \x00 \x00 \x00 \xC3 \xCC \xCC \xCC \xCC \xCC \xCC \xCC \xCC \x48 \x89 \x5C \x24 \x00 \x57 \x48 \x83 \xEC \x30 \x48 \x8B \xF9 " ) ,
" xxx????xxxxxxxxxxxxx?xxxxxxxx " ) . ResolveRelativeAddressSelf ( 0x3 , 0x7 ) . RCast < CHLClient * > ( ) ;
2022-08-09 03:02:00 +02:00
g_pHLClient = g_GameDll . FindPatternSIMD ( reinterpret_cast < rsig_t >
2022-04-18 03:35:08 +02:00
( " \x41 \x55 \x48 \x83 \xEC \x00 \x4C \x63 \x91 \x00 \x00 \x00 \x00 " ) ,
" xxxxx?xxx???? " ) . FindPatternSelf ( " 4C 8B " , CMemory : : Direction : : DOWN , 512 , 2 ) . ResolveRelativeAddressSelf ( 0x3 , 0x7 ) . RCast < CHLClient * > ( ) ;
}
2022-04-11 01:44:30 +02:00
virtual void GetCon ( void ) const { }
virtual void Attach ( void ) const { }
virtual void Detach ( void ) const { }
2021-12-25 22:36:38 +01:00
} ;
///////////////////////////////////////////////////////////////////////////////
2022-05-13 14:53:25 +02:00
REGISTER ( VDll_Engine_Int ) ;