Reversed CServer structure (almost complete). See desc

* Mostly rebuild CServer structure.
* Partially rebuild CNetworkStringTable structure.
* Partially rebuild CNetworkStringTableContainer structure.
* Removed redundant patterns which are now covered in the data structure.
This commit is contained in:
Kawe Mazidjatari 2022-05-20 20:14:39 +02:00
parent efb7c36408
commit 52883808e1
25 changed files with 274 additions and 70 deletions

View File

@ -61,9 +61,6 @@
#include "engine/client/cl_main.h" #include "engine/client/cl_main.h"
#include "engine/client/client.h" #include "engine/client/client.h"
#include "engine/client/clientstate.h" #include "engine/client/clientstate.h"
#ifndef CLIENT_DLL
#include "engine/server/server.h"
#endif // !CLIENT_DLL
#include "engine/common.h" #include "engine/common.h"
#include "engine/cmodel_bsp.h" #include "engine/cmodel_bsp.h"
#include "engine/host.h" #include "engine/host.h"

View File

@ -10,7 +10,6 @@
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
#include "core/stdafx.h" #include "core/stdafx.h"
#include "engine/client/client.h" #include "engine/client/client.h"
#include "engine/server/server.h"
//--------------------------------------------------------------------------------- //---------------------------------------------------------------------------------
// Purpose: gets the client from buffer by index // Purpose: gets the client from buffer by index
@ -23,7 +22,7 @@ CClient* CClient::GetClient(int nIndex) const
//--------------------------------------------------------------------------------- //---------------------------------------------------------------------------------
// Purpose: gets the userID of this client // Purpose: gets the userID of this client
//--------------------------------------------------------------------------------- //---------------------------------------------------------------------------------
std::int32_t CClient::GetUserID(void) const int32_t CClient::GetUserID(void) const
{ {
return m_nUserID; return m_nUserID;
} }
@ -31,7 +30,7 @@ std::int32_t CClient::GetUserID(void) const
//--------------------------------------------------------------------------------- //---------------------------------------------------------------------------------
// Purpose: gets the userID of this client // Purpose: gets the userID of this client
//--------------------------------------------------------------------------------- //---------------------------------------------------------------------------------
std::int64_t CClient::GetOriginID(void) const int64_t CClient::GetOriginID(void) const
{ {
return m_nOriginID; return m_nOriginID;
} }

View File

@ -2,7 +2,6 @@
#include "vpc/keyvalues.h" #include "vpc/keyvalues.h"
#include "common/protocol.h" #include "common/protocol.h"
#include "engine/net_chan.h" #include "engine/net_chan.h"
#include "server/vengineserver_impl.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Forward declarations // Forward declarations

View File

@ -19,7 +19,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool CClientState::IsPaused() bool CClientState::IsPaused()
{ {
return *cl_m_bPaused; return m_bPaused;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -30,7 +30,7 @@ float CClientState::GetClientTime()
{ {
if (*cl_time_use_host_tickcount) if (*cl_time_use_host_tickcount)
{ {
return (float)(int)*cl_host_tickcount * (float)*client_debugdraw_int_unk; return (float)(int)m_ClockDriftMgr.m_nClientTick * (float)*client_debugdraw_int_unk;
} }
else else
{ {
@ -43,7 +43,7 @@ float CClientState::GetClientTime()
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int CClientState::GetClientTickCount() const int CClientState::GetClientTickCount() const
{ {
return *cl_host_tickcount; return m_ClockDriftMgr.m_nClientTick;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -51,7 +51,8 @@ int CClientState::GetClientTickCount() const
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void CClientState::SetClientTickCount(int tick) void CClientState::SetClientTickCount(int tick)
{ {
*cl_host_tickcount = tick; m_ClockDriftMgr.m_nClientTick = tick;
} }
CClientState* g_pBaseClientState = nullptr; /////////////////////////////////////////////////////////////////////////////////
CClientState* g_pClientState = nullptr;

View File

@ -10,9 +10,6 @@
#include "engine/framesnapshot.h" #include "engine/framesnapshot.h"
#include "engine/packed_entity.h" #include "engine/packed_entity.h"
inline bool* cl_m_bPaused = nullptr;
inline int* cl_host_tickcount = nullptr;
struct __declspec(align(8)) CClientSnapshotManager struct __declspec(align(8)) CClientSnapshotManager
{ {
void* __vftable /*VFT*/; void* __vftable /*VFT*/;
@ -170,7 +167,9 @@ public:
char byte34A38; char byte34A38;
char field_34A39[7]; char field_34A39[7];
}; };
extern CClientState* g_pBaseClientState; #ifndef DEDICATED
extern CClientState* g_pClientState;
#endif // DEDICATED
/* ==== CCLIENTSTATE ==================================================================================================================================================== */ /* ==== CCLIENTSTATE ==================================================================================================================================================== */
inline CMemory p_CClientState__RunFrame; inline CMemory p_CClientState__RunFrame;
@ -191,8 +190,9 @@ class VClientState : public IDetour
spdlog::debug("| FUN: CClientState::RunFrame : {:#18x} |\n", p_CClientState__RunFrame.GetPtr()); spdlog::debug("| FUN: CClientState::RunFrame : {:#18x} |\n", p_CClientState__RunFrame.GetPtr());
spdlog::debug("| FUN: CClientState::Disconnect : {:#18x} |\n", p_CClientState__Disconnect.GetPtr()); spdlog::debug("| FUN: CClientState::Disconnect : {:#18x} |\n", p_CClientState__Disconnect.GetPtr());
spdlog::debug("| FUN: CClientState::CheckForResend : {:#18x} |\n", p_CClientState__CheckForResend.GetPtr()); spdlog::debug("| FUN: CClientState::CheckForResend : {:#18x} |\n", p_CClientState__CheckForResend.GetPtr());
spdlog::debug("| VAR: cl_m_bPaused : {:#18x} |\n", reinterpret_cast<uintptr_t>(cl_m_bPaused)); #ifndef DEDICATED
spdlog::debug("| VAR: cl_host_tickcount : {:#18x} |\n", reinterpret_cast<uintptr_t>(cl_host_tickcount)); spdlog::debug("| VAR: g_pClientState : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_pClientState));
#endif // DEDICATED
spdlog::debug("+----------------------------------------------------------------+\n"); spdlog::debug("+----------------------------------------------------------------+\n");
} }
virtual void GetFun(void) const virtual void GetFun(void) const
@ -223,32 +223,11 @@ class VClientState : public IDetour
} }
virtual void GetVar(void) const virtual void GetVar(void) const
{ {
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1)
CMemory localRef = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>(
"\x40\x55\x48\x83\xEC\x50\x48\x8B\x05\x00\x00\x00\x00"), "xxxxxxxxx????");
cl_m_bPaused = localRef.Offset(0x90)
.FindPatternSelf("80 3D ? ? ? 0B ?", CMemory::Direction::DOWN, 150).ResolveRelativeAddressSelf(0x2, 0x2).RCast<bool*>();
cl_host_tickcount = localRef.Offset(0xC0)
.FindPatternSelf("66 0F 6E", CMemory::Direction::DOWN, 150).ResolveRelativeAddressSelf(0x4, 0x8).RCast<int*>();
#elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3)
CMemory localRef = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>(
"\x40\x55\x48\x83\xEC\x30\x48\x8B\x05\x00\x00\x00\x00\x0F\xB6\xE9"), "xxxxxxxxx????xxx");
cl_m_bPaused = localRef.Offset(0x70)
.FindPatternSelf("80 3D ? ? ? 01 ?", CMemory::Direction::DOWN, 150).ResolveRelativeAddressSelf(0x2, 0x7).RCast<bool*>();
cl_host_tickcount = localRef.Offset(0xC0)
.FindPatternSelf("66 0F 6E", CMemory::Direction::DOWN, 150).ResolveRelativeAddressSelf(0x4, 0x8).RCast<int*>();
#endif
}
virtual void GetCon(void) const
{
#ifndef DEDICATED #ifndef DEDICATED
g_pBaseClientState = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x0F\x84\x00\x00\x00\x00\x48\x8D\x0D\x00\x00\x00\x00\x48\x83\xC4\x28"), "xx????xxx????xxxx").FindPatternSelf("48 8D").ResolveRelativeAddressSelf(0x3, 0x7).RCast<CClientState*>(); /*0F 84 ? ? ? ? 48 8D 0D ? ? ? ? 48 83 C4 28*/ g_pClientState = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x0F\x84\x00\x00\x00\x00\x48\x8D\x0D\x00\x00\x00\x00\x48\x83\xC4\x28"), "xx????xxx????xxxx").FindPatternSelf("48 8D").ResolveRelativeAddressSelf(0x3, 0x7).RCast<CClientState*>(); /*0F 84 ? ? ? ? 48 8D 0D ? ? ? ? 48 83 C4 28*/
#endif #endif // DEDICATED
} }
virtual void GetCon(void) const { }
virtual void Attach(void) const { } virtual void Attach(void) const { }
virtual void Detach(void) const { } virtual void Detach(void) const { }
}; };

View File

@ -3,7 +3,9 @@
// Purpose: Runs the state machine for the host & server. // Purpose: Runs the state machine for the host & server.
// //
//=============================================================================// //=============================================================================//
// host_state.cpp: methods are declared inline to prevent stack corruption.
//
/////////////////////////////////////////////////////////////////////////////////
#include "core/stdafx.h" #include "core/stdafx.h"
#include "tier0/jobthread.h" #include "tier0/jobthread.h"
#include "tier0/commandline.h" #include "tier0/commandline.h"

View File

@ -37,7 +37,7 @@ public:
HostStates_t m_iNextState; //0x0004 HostStates_t m_iNextState; //0x0004
Vector3 m_vecLocation; //0x0008 Vector3 m_vecLocation; //0x0008
QAngle m_angLocation; //0x0014 QAngle m_angLocation; //0x0014
char m_levelName[MAX_LEVELNAME_LEN]; //0x0020 char m_levelName[MAX_MAP_NAME_HOST]; //0x0020
char m_mapGroupName[256]; //0x0060 char m_mapGroupName[256]; //0x0060
char m_landMarkName[256]; //0x0160 char m_landMarkName[256]; //0x0160
float m_flShortFrameTime; //0x0260 float m_flShortFrameTime; //0x0260

View File

@ -15,6 +15,7 @@
#include "engine/net.h" #include "engine/net.h"
#include "engine/net_chan.h" #include "engine/net_chan.h"
#ifndef CLIENT_DLL #ifndef CLIENT_DLL
#include "engine/server/server.h"
#include "engine/client/client.h" #include "engine/client/client.h"
#endif // !CLIENT_DLL #endif // !CLIENT_DLL
#endif // !NETCONSOLE #endif // !NETCONSOLE

View File

@ -116,11 +116,11 @@ private:
int m_nLastRecvFlags; int m_nLastRecvFlags;
RTL_SRWLOCK LOCK; RTL_SRWLOCK LOCK;
bf_write m_StreamReliable; bf_write m_StreamReliable;
CUtlMemory m_ReliableDataBuffer; CUtlMemory<byte> m_ReliableDataBuffer;
bf_write m_StreamUnreliable; bf_write m_StreamUnreliable;
CUtlMemory m_UnreliableDataBuffer; CUtlMemory<byte> m_UnreliableDataBuffer;
bf_write m_StreamVoice; bf_write m_StreamVoice;
CUtlMemory m_VoiceDataBuffer; CUtlMemory<byte> m_VoiceDataBuffer;
int m_Socket; int m_Socket;
int m_MaxReliablePayloadSize; int m_MaxReliablePayloadSize;
double last_received; double last_received;

View File

@ -0,0 +1,79 @@
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose:
//
// $NoKeywords: $
//===========================================================================//
#include "core/stdafx.h"
#include "engine/networkstringtable.h"
//-----------------------------------------------------------------------------
// Purpose:
// Input : i -
// Output : CNetworkStringTableItem
//-----------------------------------------------------------------------------
//CNetworkStringTableItem* CNetworkStringTable::GetItem(int i)
//{
// if (i >= 0)
// {
// return &m_pItems->Element(i);
// }
//
// Assert(m_pItemsClientSide);
// return &m_pItemsClientSide->Element(-i);
//}
//-----------------------------------------------------------------------------
// Purpose: Returns the table identifier
// Output : TABLEID
//-----------------------------------------------------------------------------
TABLEID CNetworkStringTable::GetTableId(void) const
{
return m_id;
}
//-----------------------------------------------------------------------------
// Purpose: Returns the max size of the table
// Output : int
//-----------------------------------------------------------------------------
int CNetworkStringTable::GetMaxStrings(void) const
{
return m_nMaxEntries;
}
//-----------------------------------------------------------------------------
// Purpose: Returns a table, by name
// Output : const char
//-----------------------------------------------------------------------------
const char* CNetworkStringTable::GetTableName(void) const
{
return m_pszTableName;
}
//-----------------------------------------------------------------------------
// Purpose: Returns the number of bits needed to encode an entry index
// Output : int
//-----------------------------------------------------------------------------
int CNetworkStringTable::GetEntryBits(void) const
{
return m_nEntryBits;
}
//-----------------------------------------------------------------------------
// Purpose: Sets the tick count
//-----------------------------------------------------------------------------
void CNetworkStringTable::SetTick(int tick_count)
{
assert(tick_count >= m_nTickCount);
m_nTickCount = tick_count;
}
//-----------------------------------------------------------------------------
// Purpose: Locks the string table
//-----------------------------------------------------------------------------
bool CNetworkStringTable::Lock(bool bLock)
{
bool bState = m_bLocked;
m_bLocked = bLock;
return bState;
}

View File

@ -0,0 +1,49 @@
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose:
//
// $NoKeywords: $
//===========================================================================//
#ifndef NETWORKSTRINGTABLE_H
#define NETWORKSTRINGTABLE_H
typedef int TABLEID;
class INetworkStringTable
{
INetworkStringTable* m_pVTable;
};
class CNetworkStringTable : public INetworkStringTable
{
public:
TABLEID GetTableId(void) const;
int GetMaxStrings(void) const;
const char* GetTableName(void) const;
int GetEntryBits(void) const;
void SetTick(int tick_count);
bool Lock(bool bLock);
TABLEID m_id;
bool m_bLocked; // Might be wrong!
char* m_pszTableName;
int m_nMaxEntries;
int m_nEntryBits;
int m_nTickCount;
int m_nLastChangedTick;
uint32_t m_nFlags;
// !TODO
};
class CNetworkStringTableContainer : public INetworkStringTable
{
public:
bool m_bAllowCreation; // creat guard Guard
int m_nTickCount; // current tick
bool m_bLocked; // currently locked?
bool m_bEnableRollback; // enables rollback feature
//CUtlVector < CNetworkStringTable* > m_Tables; // the string tables
};
#endif // NETWORKSTRINGTABLE_H

View File

@ -14,7 +14,6 @@
#include "engine/sys_utils.h" #include "engine/sys_utils.h"
#include "engine/server/sv_main.h" #include "engine/server/sv_main.h"
#include "engine/server/server.h" #include "engine/server/server.h"
#include "engine/client/client.h"
#include "networksystem/r5net.h" #include "networksystem/r5net.h"
#include "public/include/edict.h" #include "public/include/edict.h"
#include "public/include/bansystem.h" #include "public/include/bansystem.h"
@ -59,13 +58,13 @@ int CServer::GetNumFakeClients(void) const
return nBots; return nBots;
} }
//----------------------------------------------------------------------------- //---------------------------------------------------------------------------------
// Purpose: client to server authentication // Purpose: client to server authentication
// Input : *this - // Input : *this -
// *pInpacket - // *pInpacket -
// Output : pointer to client instance on success, nullptr on failure // Output : pointer to client instance on success, nullptr on failure
//----------------------------------------------------------------------------- //---------------------------------------------------------------------------------
CClient* CServer::Authenticate(CServer* pServer, user_creds* pInpacket) CClient* CServer::Authenticate(CServer* pServer, user_creds_s* pInpacket)
{ {
std::string svIpAddress = pInpacket->m_nAddr.GetAddress(); std::string svIpAddress = pInpacket->m_nAddr.GetAddress();
if (sv_showconnecting->GetBool()) if (sv_showconnecting->GetBool())
@ -122,4 +121,4 @@ void CServer_Detach()
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
bool g_bCheckCompBanDB = true; bool g_bCheckCompBanDB = true;
CServer* g_pServer = new CServer(); // !TODO: Replace with engine global if found. CServer* g_pServer = nullptr;

View File

@ -2,8 +2,21 @@
#include "tier1/NetAdr2.h" #include "tier1/NetAdr2.h"
#include "networksystem/r5net.h" #include "networksystem/r5net.h"
#include "engine/client/client.h" #include "engine/client/client.h"
#include "engine/networkstringtable.h"
#include "public/include/iserver.h"
#ifndef CLIENT_DLL
#include "server/vengineserver_impl.h"
#endif // !CLIENT_DLL
struct user_creds enum class server_state_t
{
ss_dead = 0, // Dead
ss_loading, // Spawning
ss_active, // Running
ss_paused, // Running, but paused
};
struct user_creds_s
{ {
v_netadr_t m_nAddr; v_netadr_t m_nAddr;
int32_t m_nProtocolVer; int32_t m_nProtocolVer;
@ -13,12 +26,49 @@ struct user_creds
int64_t m_nUserID; int64_t m_nUserID;
}; };
class CServer class CServer : public IServer
{ {
public: public:
int GetTick(void) const { return m_nTickCount; }
#ifndef CLIENT_DLL // Only the connectionless packet handler is implemented on the client via the IServer base class.
int GetNumHumanPlayers(void) const; int GetNumHumanPlayers(void) const;
int GetNumFakeClients(void) const; int GetNumFakeClients(void) const;
static CClient* Authenticate(CServer* pServer, user_creds* pInpacket); const char* GetMapName(void) const { return m_szMapname; }
const char* GetMapGroupName(void) const { return m_szMapGroupName; }
int GetNumClasses(void) const { return serverclasses; }
int GetClassBits(void) const { return serverclassbits; }
bool IsActive(void) const { return m_State >= server_state_t::ss_active; }
bool IsLoading(void) const { return m_State == server_state_t::ss_loading; }
bool IsDedicated(void) const { return g_bDedicated; }
static CClient* Authenticate(CServer* pServer, user_creds_s* pInpacket);
#endif // !CLIENT_DLL
private:
server_state_t m_State; // some actions are only valid during load
int m_Socket; // network socket
int m_nTickCount; // current server tick
bool m_bResetMaxTeams; // reset max players on the server
char m_szMapname[MAX_MAP_NAME]; // map name and path without extension
char m_szMapGroupName[64]; // map group name
char m_szPassword[32]; // server password
uint32_t worldmapCRC; // for detecting that client has a hacked local copy of map, the client will be dropped if this occurs.
uint32_t clientDllCRC; // the dll that this server is expecting clients to be using.
CNetworkStringTableContainer* m_StringTables; // network string table container
CNetworkStringTable* m_pInstanceBaselineTable; // instancebaseline
CNetworkStringTable* m_pLightStyleTable; // lightstyles
CNetworkStringTable* m_pUserInfoTable; // userinfo
CNetworkStringTable* m_pServerQueryTable; // server_query_inf
bool m_bReplay; // MAYBE
bool m_bUpdateFrame; // perform snapshot update
bool m_bUseReputation; // use of player reputation on the server
bool m_bSimulating; // are we simulating or not
int m_nPad; // padding
bf_write m_Signon; // signon bitbuf
CUtlMemory<byte> m_SignonBuffer; // signon memory
int serverclasses; // number of unique server classes
int serverclassbits; // log2 of serverclasses
char m_szHostInfo[128]; // see '[r5apex_ds.exe + 0x237740]' for more details. fmt: '[IPv6]:PORT:TIMEi64u'
// TODO: Reverse the rest.
}; };
extern CServer* g_pServer; extern CServer* g_pServer;
@ -27,18 +77,14 @@ inline CMemory p_CServer_Think;
inline auto v_CServer_Think = p_CServer_Think.RCast<void (*)(bool bCheckClockDrift, bool bIsSimulating)>(); inline auto v_CServer_Think = p_CServer_Think.RCast<void (*)(bool bCheckClockDrift, bool bIsSimulating)>();
inline CMemory p_CServer_Authenticate; inline CMemory p_CServer_Authenticate;
inline auto v_CServer_Authenticate = p_CServer_Authenticate.RCast<CClient* (*)(CServer* pServer, user_creds* pCreds)>(); inline auto v_CServer_Authenticate = p_CServer_Authenticate.RCast<CClient* (*)(CServer* pServer, user_creds_s* pCreds)>();
inline CMemory p_CServer_RejectConnection; inline CMemory p_CServer_RejectConnection;
inline auto v_CServer_RejectConnection = p_CServer_RejectConnection.RCast<void* (*)(CServer* pServer, unsigned int a2, user_creds* pCreds, const char* szMessage)>(); inline auto v_CServer_RejectConnection = p_CServer_RejectConnection.RCast<void* (*)(CServer* pServer, unsigned int a2, user_creds_s* pCreds, const char* szMessage)>();
inline int* sv_m_nTickCount = nullptr;
void CServer_Attach(); void CServer_Attach();
void CServer_Detach(); void CServer_Detach();
void SV_IsClientBanned(R5Net::Client* r5net, const std::string ipaddr, std::int64_t nucleus_id);
extern bool g_bCheckCompBanDB; extern bool g_bCheckCompBanDB;
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -49,7 +95,7 @@ class VServer : public IDetour
spdlog::debug("| FUN: CServer::Think : {:#18x} |\n", p_CServer_Think.GetPtr()); spdlog::debug("| FUN: CServer::Think : {:#18x} |\n", p_CServer_Think.GetPtr());
spdlog::debug("| FUN: CServer::Authenticate : {:#18x} |\n", p_CServer_Authenticate.GetPtr()); spdlog::debug("| FUN: CServer::Authenticate : {:#18x} |\n", p_CServer_Authenticate.GetPtr());
spdlog::debug("| FUN: CServer::RejectConnection : {:#18x} |\n", p_CServer_RejectConnection.GetPtr()); spdlog::debug("| FUN: CServer::RejectConnection : {:#18x} |\n", p_CServer_RejectConnection.GetPtr());
spdlog::debug("| VAR: sv_m_nTickCount : {:#18x} |\n", reinterpret_cast<uintptr_t>(sv_m_nTickCount)); spdlog::debug("| VAR: g_pServer : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_pServer));
spdlog::debug("+----------------------------------------------------------------+\n"); spdlog::debug("+----------------------------------------------------------------+\n");
} }
virtual void GetFun(void) const virtual void GetFun(void) const
@ -65,12 +111,13 @@ class VServer : public IDetour
p_CServer_RejectConnection = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x4C\x89\x4C\x24\x00\x53\x55\x56\x57\x48\x81\xEC\x00\x00\x00\x00\x49\x8B\xD9"), "xxxx?xxxxxxx????xxx"); p_CServer_RejectConnection = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x4C\x89\x4C\x24\x00\x53\x55\x56\x57\x48\x81\xEC\x00\x00\x00\x00\x49\x8B\xD9"), "xxxx?xxxxxxx????xxx");
v_CServer_Think = p_CServer_Think.RCast<void (*)(bool bCheckClockDrift, bool bIsSimulating)>(); /*48 89 5C 24 ?? 48 89 74 24 ?? 57 48 81 EC ?? ?? ?? ?? 80 3D ?? ?? ?? ?? ??*/ v_CServer_Think = p_CServer_Think.RCast<void (*)(bool bCheckClockDrift, bool bIsSimulating)>(); /*48 89 5C 24 ?? 48 89 74 24 ?? 57 48 81 EC ?? ?? ?? ?? 80 3D ?? ?? ?? ?? ??*/
v_CServer_Authenticate = p_CServer_Authenticate.RCast<CClient* (*)(CServer* pServer, user_creds* pCreds)>(); /*40 55 57 41 55 41 57 48 8D AC 24 ?? ?? ?? ??*/ v_CServer_Authenticate = p_CServer_Authenticate.RCast<CClient* (*)(CServer* pServer, user_creds_s* pCreds)>(); /*40 55 57 41 55 41 57 48 8D AC 24 ?? ?? ?? ??*/
v_CServer_RejectConnection = p_CServer_RejectConnection.RCast<void* (*)(CServer* pServer, unsigned int a2, user_creds* pCreds, const char* szMessage)>(); /*4C 89 4C 24 ?? 53 55 56 57 48 81 EC ?? ?? ?? ?? 49 8B D9*/ v_CServer_RejectConnection = p_CServer_RejectConnection.RCast<void* (*)(CServer* pServer, unsigned int a2, user_creds_s* pCreds, const char* szMessage)>(); /*4C 89 4C 24 ?? 53 55 56 57 48 81 EC ?? ?? ?? ?? 49 8B D9*/
} }
virtual void GetVar(void) const virtual void GetVar(void) const
{ {
sv_m_nTickCount = p_CServer_Think.Offset(0xB0).FindPatternSelf("8B 15", CMemory::Direction::DOWN).ResolveRelativeAddressSelf(0x2, 0x6).RCast<int*>(); g_pServer = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x48\x89\x5C\x24\x00\x57\x48\x83\xEC\x20\x48\x0F\xBF\xD1"), "xxxx?xxxxxxxxx")
.FindPatternSelf("48 8D 3D").ResolveRelativeAddressSelf(0x3, 0x7).RCast<CServer*>();
} }
virtual void GetCon(void) const { } virtual void GetCon(void) const { }
virtual void Attach(void) const { } virtual void Attach(void) const { }

View File

@ -23,7 +23,9 @@ History:
#include "engine/net.h" #include "engine/net.h"
#include "engine/sys_utils.h" #include "engine/sys_utils.h"
#include "engine/host_state.h" #include "engine/host_state.h"
#ifndef CLIENT_DLL
#include "engine/server/server.h" #include "engine/server/server.h"
#endif // CLIENT_DLL
#include "networksystem/serverlisting.h" #include "networksystem/serverlisting.h"
#include "networksystem/r5net.h" #include "networksystem/r5net.h"
#include "squirrel/sqinit.h" #include "squirrel/sqinit.h"

View File

@ -0,0 +1,9 @@
#ifndef ISERVER_H
#define ISERVER_H
class IServer
{
IServer* m_pVTable;
};
#endif // ISERVER_H

View File

@ -13,7 +13,9 @@
#include "core/stdafx.h" #include "core/stdafx.h"
#include "engine/sys_utils.h" #include "engine/sys_utils.h"
#ifndef CLIENT_DLL
#include "engine/server/server.h" #include "engine/server/server.h"
#endif // CLIENT_DLL
#include "squirrel/sqtype.h" #include "squirrel/sqtype.h"
#include "squirrel/sqapi.h" #include "squirrel/sqapi.h"
#include "squirrel/sqinit.h" #include "squirrel/sqinit.h"

View File

@ -17,10 +17,11 @@
#define MAX_PLAYERS 128 // Max R5 players. #define MAX_PLAYERS 128 // Max R5 players.
#if !defined (GAMEDLL_S0) && !defined (GAMEDLL_S1) && !defined (GAMEDLL_S2) #if !defined (GAMEDLL_S0) && !defined (GAMEDLL_S1) && !defined (GAMEDLL_S2)
#define MAX_LEVELNAME_LEN 64 #define MAX_MAP_NAME_HOST 64
#else #else
#define MAX_LEVELNAME_LEN 32 #define MAX_MAP_NAME_HOST 32
#endif // Max BSP file name len. #endif // Max BSP file name len.
#define MAX_MAP_NAME 64
#define SDK_VERSION "beta 1.6"/*"VGameSDK001"*/ // Increment this with every /breaking/ SDK change (i.e. security/backend changes breaking compatibility). #define SDK_VERSION "beta 1.6"/*"VGameSDK001"*/ // Increment this with every /breaking/ SDK change (i.e. security/backend changes breaking compatibility).

View File

@ -8,8 +8,14 @@
//===========================================================================// //===========================================================================//
#pragma once #pragma once
struct __declspec(align(8)) CUtlMemory template <class T>
class CUtlMemory
{ {
public:
CUtlMemory() {};
CUtlMemory<T>(uintptr_t ptr) : m_pMemory(ptr) {};
private:
void* m_pMemory; void* m_pMemory;
int64_t m_nAllocationCount; int64_t m_nAllocationCount;
int64_t m_nGrowSize; int64_t m_nGrowSize;

View File

@ -133,7 +133,7 @@ void CLogSystem::DrawSimStats(void) const
static Color c = { 255, 255, 255, 255 }; static Color c = { 255, 255, 255, 255 };
static const char* szLogbuf[4096]{}; static const char* szLogbuf[4096]{};
snprintf((char*)szLogbuf, 4096, "Server Frame: (%d) Client Frame: (%d) Render Frame: (%d)\n", snprintf((char*)szLogbuf, 4096, "Server Frame: (%d) Client Frame: (%d) Render Frame: (%d)\n",
*sv_m_nTickCount, *cl_host_tickcount, *render_tickcount); g_pServer->GetTick(), g_pClientState->GetClientTickCount(), *render_tickcount);
if (cl_simstats_invert_rect_x->GetBool()) if (cl_simstats_invert_rect_x->GetBool())
{ {

View File

@ -38,6 +38,7 @@
<ClCompile Include="..\engine\host_state.cpp" /> <ClCompile Include="..\engine\host_state.cpp" />
<ClCompile Include="..\engine\modelloader.cpp" /> <ClCompile Include="..\engine\modelloader.cpp" />
<ClCompile Include="..\engine\net.cpp" /> <ClCompile Include="..\engine\net.cpp" />
<ClCompile Include="..\engine\networkstringtable.cpp" />
<ClCompile Include="..\engine\net_chan.cpp" /> <ClCompile Include="..\engine\net_chan.cpp" />
<ClCompile Include="..\engine\sys_dll.cpp" /> <ClCompile Include="..\engine\sys_dll.cpp" />
<ClCompile Include="..\engine\sys_dll2.cpp" /> <ClCompile Include="..\engine\sys_dll2.cpp" />
@ -157,6 +158,7 @@
<ClInclude Include="..\engine\host_state.h" /> <ClInclude Include="..\engine\host_state.h" />
<ClInclude Include="..\engine\modelloader.h" /> <ClInclude Include="..\engine\modelloader.h" />
<ClInclude Include="..\engine\net.h" /> <ClInclude Include="..\engine\net.h" />
<ClInclude Include="..\engine\networkstringtable.h" />
<ClInclude Include="..\engine\net_chan.h" /> <ClInclude Include="..\engine\net_chan.h" />
<ClInclude Include="..\engine\packed_entity.h" /> <ClInclude Include="..\engine\packed_entity.h" />
<ClInclude Include="..\engine\sys_dll.h" /> <ClInclude Include="..\engine\sys_dll.h" />

View File

@ -492,6 +492,9 @@
<ClCompile Include="..\engine\client\cl_rcon.cpp"> <ClCompile Include="..\engine\client\cl_rcon.cpp">
<Filter>sdk\engine\client</Filter> <Filter>sdk\engine\client</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\engine\networkstringtable.cpp">
<Filter>sdk\engine</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\client\cdll_engine_int.h"> <ClInclude Include="..\client\cdll_engine_int.h">
@ -1466,6 +1469,9 @@
<ClInclude Include="..\engine\client\cl_rcon.h"> <ClInclude Include="..\engine\client\cl_rcon.h">
<Filter>sdk\engine\client</Filter> <Filter>sdk\engine\client</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\engine\networkstringtable.h">
<Filter>sdk\engine</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Image Include="..\shared\resource\lockedserver.png"> <Image Include="..\shared\resource\lockedserver.png">

View File

@ -159,6 +159,7 @@
<ClInclude Include="..\engine\host_state.h" /> <ClInclude Include="..\engine\host_state.h" />
<ClInclude Include="..\engine\modelloader.h" /> <ClInclude Include="..\engine\modelloader.h" />
<ClInclude Include="..\engine\net.h" /> <ClInclude Include="..\engine\net.h" />
<ClInclude Include="..\engine\networkstringtable.h" />
<ClInclude Include="..\engine\net_chan.h" /> <ClInclude Include="..\engine\net_chan.h" />
<ClInclude Include="..\engine\packed_entity.h" /> <ClInclude Include="..\engine\packed_entity.h" />
<ClInclude Include="..\engine\server\server.h" /> <ClInclude Include="..\engine\server\server.h" />
@ -204,6 +205,7 @@
<ClInclude Include="..\public\include\globalvars_base.h" /> <ClInclude Include="..\public\include\globalvars_base.h" />
<ClInclude Include="..\public\include\inetchannel.h" /> <ClInclude Include="..\public\include\inetchannel.h" />
<ClInclude Include="..\public\include\inetmsghandler.h" /> <ClInclude Include="..\public\include\inetmsghandler.h" />
<ClInclude Include="..\public\include\iserver.h" />
<ClInclude Include="..\public\include\memaddr.h" /> <ClInclude Include="..\public\include\memaddr.h" />
<ClInclude Include="..\public\include\bansystem.h" /> <ClInclude Include="..\public\include\bansystem.h" />
<ClInclude Include="..\public\include\binstream.h" /> <ClInclude Include="..\public\include\binstream.h" />
@ -444,6 +446,7 @@
<ClCompile Include="..\engine\host_state.cpp" /> <ClCompile Include="..\engine\host_state.cpp" />
<ClCompile Include="..\engine\modelloader.cpp" /> <ClCompile Include="..\engine\modelloader.cpp" />
<ClCompile Include="..\engine\net.cpp" /> <ClCompile Include="..\engine\net.cpp" />
<ClCompile Include="..\engine\networkstringtable.cpp" />
<ClCompile Include="..\engine\net_chan.cpp" /> <ClCompile Include="..\engine\net_chan.cpp" />
<ClCompile Include="..\engine\server\server.cpp" /> <ClCompile Include="..\engine\server\server.cpp" />
<ClCompile Include="..\engine\server\sv_main.cpp" /> <ClCompile Include="..\engine\server\sv_main.cpp" />

View File

@ -1086,6 +1086,12 @@
<ClInclude Include="..\engine\server\sv_rcon.h"> <ClInclude Include="..\engine\server\sv_rcon.h">
<Filter>sdk\engine\server</Filter> <Filter>sdk\engine\server</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\engine\networkstringtable.h">
<Filter>sdk\engine</Filter>
</ClInclude>
<ClInclude Include="..\public\include\iserver.h">
<Filter>sdk\public\include</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\common\opcodes.cpp"> <ClCompile Include="..\common\opcodes.cpp">
@ -1328,6 +1334,9 @@
<ClCompile Include="..\engine\server\server.cpp"> <ClCompile Include="..\engine\server\server.cpp">
<Filter>sdk\engine\server</Filter> <Filter>sdk\engine\server</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\engine\networkstringtable.cpp">
<Filter>sdk\engine</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="..\Dedicated.def" /> <None Include="..\Dedicated.def" />

View File

@ -38,6 +38,7 @@
<ClCompile Include="..\engine\host_state.cpp" /> <ClCompile Include="..\engine\host_state.cpp" />
<ClCompile Include="..\engine\modelloader.cpp" /> <ClCompile Include="..\engine\modelloader.cpp" />
<ClCompile Include="..\engine\net.cpp" /> <ClCompile Include="..\engine\net.cpp" />
<ClCompile Include="..\engine\networkstringtable.cpp" />
<ClCompile Include="..\engine\net_chan.cpp" /> <ClCompile Include="..\engine\net_chan.cpp" />
<ClCompile Include="..\engine\server\server.cpp" /> <ClCompile Include="..\engine\server\server.cpp" />
<ClCompile Include="..\engine\server\sv_main.cpp" /> <ClCompile Include="..\engine\server\sv_main.cpp" />
@ -164,6 +165,7 @@
<ClInclude Include="..\engine\host_state.h" /> <ClInclude Include="..\engine\host_state.h" />
<ClInclude Include="..\engine\modelloader.h" /> <ClInclude Include="..\engine\modelloader.h" />
<ClInclude Include="..\engine\net.h" /> <ClInclude Include="..\engine\net.h" />
<ClInclude Include="..\engine\networkstringtable.h" />
<ClInclude Include="..\engine\net_chan.h" /> <ClInclude Include="..\engine\net_chan.h" />
<ClInclude Include="..\engine\packed_entity.h" /> <ClInclude Include="..\engine\packed_entity.h" />
<ClInclude Include="..\engine\server\server.h" /> <ClInclude Include="..\engine\server\server.h" />
@ -219,6 +221,7 @@
<ClInclude Include="..\public\include\icliententitylist.h" /> <ClInclude Include="..\public\include\icliententitylist.h" />
<ClInclude Include="..\public\include\inetchannel.h" /> <ClInclude Include="..\public\include\inetchannel.h" />
<ClInclude Include="..\public\include\inetmsghandler.h" /> <ClInclude Include="..\public\include\inetmsghandler.h" />
<ClInclude Include="..\public\include\iserver.h" />
<ClInclude Include="..\public\include\ivrenderview.h" /> <ClInclude Include="..\public\include\ivrenderview.h" />
<ClInclude Include="..\public\include\memaddr.h" /> <ClInclude Include="..\public\include\memaddr.h" />
<ClInclude Include="..\public\include\bansystem.h" /> <ClInclude Include="..\public\include\bansystem.h" />

View File

@ -522,6 +522,9 @@
<ClCompile Include="..\engine\client\cl_rcon.cpp"> <ClCompile Include="..\engine\client\cl_rcon.cpp">
<Filter>sdk\engine\client</Filter> <Filter>sdk\engine\client</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\engine\networkstringtable.cpp">
<Filter>sdk\engine</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\client\cdll_engine_int.h"> <ClInclude Include="..\client\cdll_engine_int.h">
@ -1526,6 +1529,12 @@
<ClInclude Include="..\engine\client\cl_main.h"> <ClInclude Include="..\engine\client\cl_main.h">
<Filter>sdk\engine\client</Filter> <Filter>sdk\engine\client</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\engine\networkstringtable.h">
<Filter>sdk\engine</Filter>
</ClInclude>
<ClInclude Include="..\public\include\iserver.h">
<Filter>sdk\public\include</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Image Include="..\shared\resource\lockedserver.png"> <Image Include="..\shared\resource\lockedserver.png">