Implement CBaseClientState structure

This commit is contained in:
Kawe Mazidjatari 2022-05-15 00:29:25 +02:00
parent 9546f7a2ff
commit 107a516f9e
15 changed files with 442 additions and 2 deletions

View File

@ -1,17 +1,174 @@
#pragma once
#include "tier1/NetAdr2.h"
#include "tier1/mempool.h"
#include "common/protocol.h"
#include "public/include/inetmsghandler.h"
#include "engine/datablock.h"
#include "engine/net_chan.h"
#include "engine/debugoverlay.h"
#include "engine/clockdriftmgr.h"
#include "engine/framesnapshot.h"
#include "engine/packed_entity.h"
inline bool* cl_m_bPaused = nullptr;
inline int* cl_host_tickcount = nullptr;
struct __declspec(align(8)) CClientSnapshotManager
{
void* __vftable /*VFT*/;
void* m_Frames;
CUtlMemoryPool m_ClientFramePool;
};
struct IServerMessageHandler : INetMessageHandler
{};
struct CS_INetChannelHandler : INetChannelHandler
{};
///////////////////////////////////////////////////////////////////////////////
class CBaseClientState
class CBaseClientState : CS_INetChannelHandler, IConnectionlessPacketHandler, IServerMessageHandler, CClientSnapshotManager
{
public:
bool IsPaused();
float GetClientTime();
int GetClientTickCount() const; // Get the client tick count.
void SetClientTickCount(int tick); // Set the client tick count.
int m_Socket;
int _padding_maybe;
CNetChan* m_NetChannel;
double m_flConnectTime;
_DWORD m_nRetryNumber;
_DWORD m_nChallengeRetryLimit;
_BYTE encrypted_connection_MAYBE;
_BYTE gap79[3];
v_netadr_t addr;
bool m_bUnk_used_during_auth;
char m_bSendChallengeRequest;
_BYTE m_bDoNetParamsReconnect_MAYBE;
_BYTE field_97;
SIGNONSTATE m_nSignonState;
_BYTE gap9C[4];
double m_flNextCmdTime;
int m_nServerCount;
int field_AC;
float m_flClockDriftUnknown_TIME;
CClockDriftMgr m_ClockDriftMgr;
_BYTE field_148;
_BYTE field_149;
int m_nDeltaTick;
int m_nStringTableAckTick;
int m_nProcesseedDeltaTick;
int m_nProcessedStringTableAckTick;
bool m_bPendingTicksAvailable;
__declspec(align(4)) _BYTE m_bPaused;
char field_161;
char field_162;
_DWORD dword164;
int m_nViewEntity_MAYBE_ClientSlot_Plus_One;
int m_nPlayerSlot;
char m_szLevelFileName[64];
char m_szLevelBaseName[64];
char field_1F0[64];
char field_230[64];
_BYTE m_szServerAddresString[128];
char buffer[16];
int m_bInMpLobbyMenu;
int m_nTeam;
_DWORD m_nMaxClients;
_BYTE m_bSignonChallengeReceived;
_DWORD challenge;
v_netadr_t challengeAddr;
_BYTE byte33C;
_QWORD m_pServerClasses;
int m_nServerClasses;
int m_nServerClassBits;
__int64 m_StringTableContainer;
char m_PersistenceData[98304];
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1)
char pads0[8];
#endif
_BYTE m_bPersistenceBaselineRecvd;
__unaligned __declspec(align(4)) _QWORD m_nPersistenceBaselineEntries;
char field_18364;
char field_18365;
char buffer_0x400[1024];
NetDataBlockReceiver blockReceiver;
char client_requested_disconnect;
char error_message[512];
_BYTE gap18CA1[3];
_DWORD last_usercmd_time_from_server_maybe;
CFrameSnapshot* prev_frame_maybe;
_QWORD qword18CB0;
CFrameSnapshot* current_frame_maybe;
_BYTE gap18CC0[8];
char IsClockCorrectionEnabled_MAYBE;
char m_b_unknown;
bool m_bLocalPredictionInitialized_MAYBE;
int field_18CCC;
int dword18CD0;
int field_18CD4;
float GetFrameTime;
int outgoing_command;
int current_movement_sequence_number;
char gap18CE4[4];
__int64 qword18CE8;
int field_18CF0;
int hit_prespawn;
int field_18CF8;
int dword18CFC;
float m_flClockDriftUnknown_rounded;
char something_with_prediction;
char field_18D05;
char gap18D06[2];
int dword18D08;
char gap18D0C[13];
char do_local_prediction_update;
char gap18D1A[2];
int dword18D1C;
__int64 qword18D20;
int dword18D28;
int dword18D2C;
float field_18D30;
float m_flUnk1;
float m_flUnk2;
int dword18D3C;
int dword18D40;
char gap18D44[4];
__int64 qword18D48;
__int64 qword18D50;
__int64 qword18D58;
int dword18D60;
char gap18D64[4];
__int64 qword18D68;
char gap18D70[8];
char buffer_47128[47128];
char entitlements_bitfield[16];
__int64 maybe_some_ll_stuff;
__int64 qword245A8;
__int64 qword245B0;
__int64 qword245B8;
__int64 qword245C0;
__int64 qword245C8;
__int64 qword245D0;
__int64 qword245D8;
__int64 qword245E0;
__int64 qword245E8;
__int64 qword245F0;
int dword245F8;
char gap245FC[1024];
__unaligned __declspec(align(1)) __int64 qword249FC;
char gap24A04[4];
__int64 m_pModelPrecacheTable;
__int64 qword24A10;
__int64 m_pInstanceBaselineTable;
__int64 m_pLightStyleTable;
__int64 m_pUserInfoTable;
__int64 m_pServerStartupTable;
PackedEntity m_pEntityBaselines_maybe[4096];
char byte34A38;
char field_34A39[7];
};
extern CBaseClientState* g_pBaseClientState;

View File

@ -0,0 +1,34 @@
//===== Copyright (c) 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose:
//
// $Workfile: $
// $Date: $
//
//------------------------------------------------------------------------------
// $Log: $
//
// $NoKeywords: $
//=============================================================================//
#include "core/stdafx.h"
#include "engine/clockdriftmgr.h"
void CClockDriftMgr::Clear()
{
m_nClientTick = 0;
m_nServerTick = 0;
m_iCurClockOffset = 0;
memset(m_ClockOffsets, 0, sizeof(m_ClockOffsets));
}
float CClockDriftMgr::GetCurrentClockDifference() const
{
// Note: this could be optimized a little by updating it each time we add
// a sample (subtract the old value from the total and add the new one in).
float total = 0;
for (int i = 0; i < NUM_CLOCKDRIFT_SAMPLES; i++)
total += m_ClockOffsets[i];
return total / NUM_CLOCKDRIFT_SAMPLES;
}

View File

@ -0,0 +1,28 @@
#ifndef CLOCKDRIFTMGR_H
#define CLOCKDRIFTMGR_H
struct __declspec(align(4)) CClockDriftMgr
{
void Clear();
float GetCurrentClockDifference() const;
enum
{
// This controls how much it smoothes out the samples from the server.
NUM_CLOCKDRIFT_SAMPLES = 24
};
float field_0[4];
int field_10;
float m_ClockOffsets[NUM_CLOCKDRIFT_SAMPLES];
int m_iCurClockOffset;
float field_78;
float field_7C;
float m_flClientTickTime;
int m_nClientTick;
float m_flServerTickTime;
int m_nServerTick;
int tickcount_MAYBE;
};
#endif // CLOCKDRIFTMGR_H

23
r5dev/engine/datablock.h Normal file
View File

@ -0,0 +1,23 @@
#ifndef DATABLOCK_H
#define DATABLOCK_H
struct __declspec(align(8)) NetDataBlockReceiver
{
void* __vftable /*VFT*/;
void* client; /*CClientState*/
char m_bStartedRecv;
char m_bCompletedRecv;
_BYTE byte12;
__int16 transfer_id;
__int16 counter;
_BYTE m_bInitialized;
int transfer_size;
int total_blocks;
_DWORD blocks_ackd;
double start_time;
bool block_status[768];
char* m_pBigBuffer;
};
#endif // DATABLOCK_H

View File

@ -0,0 +1,42 @@
#if !defined( FRAMESNAPSHOT_H )
#define FRAMESNAPSHOT_H
struct TickUpdate
{
int m_nTickUnused;
int m_nTick;
float m_flHostFrameTime;
float m_flHostFrameTimeStdDeviation;
bool m_bStruggling;
char m_nUnkStat_maybe_load;
int command_number;
};
struct __declspec(align(1)) CFrameSnapshot
{
char field_0;
_DWORD last_entity;
_DWORD snap_dword8;
_DWORD snap_dwordC;
_BYTE snap_byte10;
_BYTE gap11[3];
_DWORD snap_dword14;
_DWORD snap_dword18;
_BYTE snap_byte1C;
_BYTE gap1D[3];
_DWORD snap_dword20;
_BYTE snap_byte24;
_BYTE snap_byte25;
_BYTE snap_byte26;
__unaligned __declspec(align(1)) _WORD word27;
_BYTE gap29[3];
TickUpdate snap_tick_update;
_BYTE gap44[4];
_QWORD qword48;
_QWORD qword50;
char buffer_0x20000[131072];
char buffer_0x800[2048];
char transmit_entity[4096];
};
#endif // FRAMESNAPSHOT_H

View File

@ -0,0 +1,10 @@
#if !defined( PACKED_ENTITY_H )
#define PACKED_ENTITY_H
struct PackedEntity
{
_DWORD field_0;
_QWORD field_8;
};
#endif // PACKED_ENTITY_H

View File

@ -8,7 +8,12 @@
struct INetChannelHandler
{
void* iNetMessageHandlerVTable /*VFT*/;
void* __vftable /*VFT*/;
};
struct INetMessageHandler
{
void* __vftable /*VFT*/;
};
typedef struct netpacket_s netpacket_t;

View File

@ -0,0 +1,21 @@
//===== Copyright (c) 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose:
//
// $Workfile: $
// $Date: $
//
//------------------------------------------------------------------------------
// $Log: $
//
// $NoKeywords: $
//=============================================================================//
#if !defined( INETMSGHANDLER_H )
#define INETMSGHANDLER_H
struct IConnectionlessPacketHandler
{
void* __vftable /*VFT*/;
};
#endif // INETMSGHANDLER_H

36
r5dev/tier1/mempool.h Normal file
View File

@ -0,0 +1,36 @@
//===== Copyright (c) 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose:
//
// $Workfile: $
// $Date: $
//
//------------------------------------------------------------------------------
// $Log: $
//
// $NoKeywords: $
//=============================================================================//
#ifndef MEMPOOL_H
#define MEMPOOL_H
struct CUtlMemoryPool
{
class CBlob
{
public:
short m_nAlignment; // to int align the struct.
short m_NumBlobs; // Number of blobs.
const char* m_pszAllocOwner;
CBlob* m_pPrev, * m_pNext;
};
int m_BlockSize;
int m_BlocksPerBlob;
int m_GrowMode;
int m_BlocksAllocated;
int unk;
CBlob m_BlobHead;
};
#endif // MEMPOOL_H

View File

@ -28,6 +28,7 @@
<ClCompile Include="..\ebisusdk\EbisuSDK.cpp" />
<ClCompile Include="..\engine\baseclient.cpp" />
<ClCompile Include="..\engine\baseclientstate.cpp" />
<ClCompile Include="..\engine\clockdriftmgr.cpp" />
<ClCompile Include="..\engine\cl_rcon.cpp" />
<ClCompile Include="..\engine\cmodel_bsp.cpp" />
<ClCompile Include="..\engine\common.cpp" />
@ -139,11 +140,14 @@
<ClInclude Include="..\ebisusdk\EbisuSDK.h" />
<ClInclude Include="..\engine\baseclient.h" />
<ClInclude Include="..\engine\baseclientstate.h" />
<ClInclude Include="..\engine\clockdriftmgr.h" />
<ClInclude Include="..\engine\cl_main.h" />
<ClInclude Include="..\engine\cl_rcon.h" />
<ClInclude Include="..\engine\cmodel_bsp.h" />
<ClInclude Include="..\engine\common.h" />
<ClInclude Include="..\engine\datablock.h" />
<ClInclude Include="..\engine\debugoverlay.h" />
<ClInclude Include="..\engine\framesnapshot.h" />
<ClInclude Include="..\engine\gl_matsysiface.h" />
<ClInclude Include="..\engine\gl_model_private.h" />
<ClInclude Include="..\engine\gl_rsurf.h" />
@ -154,6 +158,7 @@
<ClInclude Include="..\engine\modelloader.h" />
<ClInclude Include="..\engine\net.h" />
<ClInclude Include="..\engine\net_chan.h" />
<ClInclude Include="..\engine\packed_entity.h" />
<ClInclude Include="..\engine\sys_dll.h" />
<ClInclude Include="..\engine\sys_dll2.h" />
<ClInclude Include="..\engine\sys_engine.h" />
@ -196,6 +201,7 @@
<ClInclude Include="..\public\include\edict.h" />
<ClInclude Include="..\public\include\globalvars_base.h" />
<ClInclude Include="..\public\include\inetchannel.h" />
<ClInclude Include="..\public\include\inetmsghandler.h" />
<ClInclude Include="..\public\include\ivrenderview.h" />
<ClInclude Include="..\public\include\memaddr.h" />
<ClInclude Include="..\public\include\bansystem.h" />
@ -408,6 +414,7 @@
<ClInclude Include="..\tier1\cmd.h" />
<ClInclude Include="..\tier1\cvar.h" />
<ClInclude Include="..\tier1\IConVar.h" />
<ClInclude Include="..\tier1\mempool.h" />
<ClInclude Include="..\tier1\NetAdr2.h" />
<ClInclude Include="..\tier1\utldict.h" />
<ClInclude Include="..\tier1\utlmemory.h" />

View File

@ -483,6 +483,9 @@
<ClCompile Include="..\squirrel\sqstdaux.cpp">
<Filter>sdk\squirrel</Filter>
</ClCompile>
<ClCompile Include="..\engine\clockdriftmgr.cpp">
<Filter>sdk\engine</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\client\cdll_engine_int.h">
@ -1439,6 +1442,24 @@
<ClInclude Include="..\squirrel\sqstdaux.h">
<Filter>sdk\squirrel</Filter>
</ClInclude>
<ClInclude Include="..\engine\framesnapshot.h">
<Filter>sdk\engine</Filter>
</ClInclude>
<ClInclude Include="..\engine\datablock.h">
<Filter>sdk\engine</Filter>
</ClInclude>
<ClInclude Include="..\engine\clockdriftmgr.h">
<Filter>sdk\engine</Filter>
</ClInclude>
<ClInclude Include="..\engine\packed_entity.h">
<Filter>sdk\engine</Filter>
</ClInclude>
<ClInclude Include="..\public\include\inetmsghandler.h">
<Filter>sdk\public\include</Filter>
</ClInclude>
<ClInclude Include="..\tier1\mempool.h">
<Filter>sdk\tier1</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Image Include="..\shared\resource\lockedserver.png">

View File

@ -147,9 +147,12 @@
<ClInclude Include="..\ebisusdk\EbisuSDK.h" />
<ClInclude Include="..\engine\baseclient.h" />
<ClInclude Include="..\engine\baseserver.h" />
<ClInclude Include="..\engine\clockdriftmgr.h" />
<ClInclude Include="..\engine\cl_main.h" />
<ClInclude Include="..\engine\cmodel_bsp.h" />
<ClInclude Include="..\engine\common.h" />
<ClInclude Include="..\engine\datablock.h" />
<ClInclude Include="..\engine\framesnapshot.h" />
<ClInclude Include="..\engine\gl_matsysiface.h" />
<ClInclude Include="..\engine\gl_model_private.h" />
<ClInclude Include="..\engine\host.h" />
@ -158,6 +161,7 @@
<ClInclude Include="..\engine\modelloader.h" />
<ClInclude Include="..\engine\net.h" />
<ClInclude Include="..\engine\net_chan.h" />
<ClInclude Include="..\engine\packed_entity.h" />
<ClInclude Include="..\engine\sv_main.h" />
<ClInclude Include="..\engine\sv_rcon.h" />
<ClInclude Include="..\engine\sys_dll.h" />
@ -199,6 +203,7 @@
<ClInclude Include="..\public\include\edict.h" />
<ClInclude Include="..\public\include\globalvars_base.h" />
<ClInclude Include="..\public\include\inetchannel.h" />
<ClInclude Include="..\public\include\inetmsghandler.h" />
<ClInclude Include="..\public\include\memaddr.h" />
<ClInclude Include="..\public\include\bansystem.h" />
<ClInclude Include="..\public\include\binstream.h" />
@ -400,6 +405,7 @@
<ClInclude Include="..\tier1\cmd.h" />
<ClInclude Include="..\tier1\cvar.h" />
<ClInclude Include="..\tier1\IConVar.h" />
<ClInclude Include="..\tier1\mempool.h" />
<ClInclude Include="..\tier1\NetAdr2.h" />
<ClInclude Include="..\tier1\utldict.h" />
<ClInclude Include="..\tier1\utlmemory.h" />
@ -432,6 +438,7 @@
<ClCompile Include="..\ebisusdk\EbisuSDK.cpp" />
<ClCompile Include="..\engine\baseclient.cpp" />
<ClCompile Include="..\engine\baseserver.cpp" />
<ClCompile Include="..\engine\clockdriftmgr.cpp" />
<ClCompile Include="..\engine\cmodel_bsp.cpp" />
<ClCompile Include="..\engine\common.cpp" />
<ClCompile Include="..\engine\host_cmd.cpp" />

View File

@ -1065,6 +1065,24 @@
<ClInclude Include="..\squirrel\sqstdaux.h">
<Filter>sdk\squirrel</Filter>
</ClInclude>
<ClInclude Include="..\engine\framesnapshot.h">
<Filter>sdk\engine</Filter>
</ClInclude>
<ClInclude Include="..\engine\datablock.h">
<Filter>sdk\engine</Filter>
</ClInclude>
<ClInclude Include="..\engine\clockdriftmgr.h">
<Filter>sdk\engine</Filter>
</ClInclude>
<ClInclude Include="..\engine\packed_entity.h">
<Filter>sdk\engine</Filter>
</ClInclude>
<ClInclude Include="..\public\include\inetmsghandler.h">
<Filter>sdk\public\include</Filter>
</ClInclude>
<ClInclude Include="..\tier1\mempool.h">
<Filter>sdk\tier1</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\common\opcodes.cpp">
@ -1304,6 +1322,9 @@
<ClCompile Include="..\squirrel\sqstdaux.cpp">
<Filter>sdk\squirrel</Filter>
</ClCompile>
<ClCompile Include="..\engine\clockdriftmgr.cpp">
<Filter>sdk\engine</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="..\Dedicated.def" />

View File

@ -29,6 +29,7 @@
<ClCompile Include="..\engine\baseclient.cpp" />
<ClCompile Include="..\engine\baseclientstate.cpp" />
<ClCompile Include="..\engine\baseserver.cpp" />
<ClCompile Include="..\engine\clockdriftmgr.cpp" />
<ClCompile Include="..\engine\cl_rcon.cpp" />
<ClCompile Include="..\engine\cmodel_bsp.cpp" />
<ClCompile Include="..\engine\common.cpp" />
@ -148,11 +149,14 @@
<ClInclude Include="..\engine\baseclient.h" />
<ClInclude Include="..\engine\baseclientstate.h" />
<ClInclude Include="..\engine\baseserver.h" />
<ClInclude Include="..\engine\clockdriftmgr.h" />
<ClInclude Include="..\engine\cl_main.h" />
<ClInclude Include="..\engine\cl_rcon.h" />
<ClInclude Include="..\engine\cmodel_bsp.h" />
<ClInclude Include="..\engine\common.h" />
<ClInclude Include="..\engine\datablock.h" />
<ClInclude Include="..\engine\debugoverlay.h" />
<ClInclude Include="..\engine\framesnapshot.h" />
<ClInclude Include="..\engine\gl_matsysiface.h" />
<ClInclude Include="..\engine\gl_model_private.h" />
<ClInclude Include="..\engine\gl_rsurf.h" />
@ -163,6 +167,7 @@
<ClInclude Include="..\engine\modelloader.h" />
<ClInclude Include="..\engine\net.h" />
<ClInclude Include="..\engine\net_chan.h" />
<ClInclude Include="..\engine\packed_entity.h" />
<ClInclude Include="..\engine\sv_main.h" />
<ClInclude Include="..\engine\sys_dll.h" />
<ClInclude Include="..\engine\sys_dll2.h" />
@ -214,6 +219,7 @@
<ClInclude Include="..\public\include\globalvars_base.h" />
<ClInclude Include="..\public\include\icliententitylist.h" />
<ClInclude Include="..\public\include\inetchannel.h" />
<ClInclude Include="..\public\include\inetmsghandler.h" />
<ClInclude Include="..\public\include\ivrenderview.h" />
<ClInclude Include="..\public\include\memaddr.h" />
<ClInclude Include="..\public\include\bansystem.h" />
@ -427,6 +433,7 @@
<ClInclude Include="..\tier1\cmd.h" />
<ClInclude Include="..\tier1\cvar.h" />
<ClInclude Include="..\tier1\IConVar.h" />
<ClInclude Include="..\tier1\mempool.h" />
<ClInclude Include="..\tier1\NetAdr2.h" />
<ClInclude Include="..\tier1\utldict.h" />
<ClInclude Include="..\tier1\utlmemory.h" />

View File

@ -513,6 +513,9 @@
<ClCompile Include="..\squirrel\sqstdaux.cpp">
<Filter>sdk\squirrel</Filter>
</ClCompile>
<ClCompile Include="..\engine\clockdriftmgr.cpp">
<Filter>sdk\engine</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\client\cdll_engine_int.h">
@ -1502,6 +1505,24 @@
<ClInclude Include="..\squirrel\sqstdaux.h">
<Filter>sdk\squirrel</Filter>
</ClInclude>
<ClInclude Include="..\engine\clockdriftmgr.h">
<Filter>sdk\engine</Filter>
</ClInclude>
<ClInclude Include="..\engine\datablock.h">
<Filter>sdk\engine</Filter>
</ClInclude>
<ClInclude Include="..\engine\framesnapshot.h">
<Filter>sdk\engine</Filter>
</ClInclude>
<ClInclude Include="..\engine\packed_entity.h">
<Filter>sdk\engine</Filter>
</ClInclude>
<ClInclude Include="..\tier1\mempool.h">
<Filter>sdk\tier1</Filter>
</ClInclude>
<ClInclude Include="..\public\include\inetmsghandler.h">
<Filter>sdk\public\include</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Image Include="..\shared\resource\lockedserver.png">