mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
New fields for CBaseClient, fixed CBaseServer functions.
This commit is contained in:
parent
87b53d1731
commit
404ef9255c
@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
#include "server/IVEngineServer.h"
|
||||
|
||||
// PLEASE REMOVE AND FULLY MIGRATE TO CBASECLIENT!
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Forward declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -110,7 +110,6 @@ void Systems_Init()
|
||||
{
|
||||
std::cerr << "Failed to start Winsock via WSAStartup: (" << NET_ErrorString(WSAGetLastError()) << ")" << std::endl;
|
||||
}
|
||||
|
||||
// Begin the detour transaction to hook the the process
|
||||
DetourTransactionBegin();
|
||||
DetourUpdateThread(GetCurrentThread());
|
||||
|
@ -10,13 +10,14 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
#include "core/stdafx.h"
|
||||
#include "engine/baseclient.h"
|
||||
#include "engine/baseserver.h"
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
// Purpose: gets the client from buffer by index
|
||||
//---------------------------------------------------------------------------------
|
||||
CBaseClient* CBaseClient::GetClient(int nIndex) const
|
||||
{
|
||||
return (CBaseClient*)(std::uintptr_t)(g_pClientBuffer.GetPtr() + (nIndex * g_dwCClientSize));
|
||||
return (CBaseClient*)(std::uintptr_t)(g_pClientBuffer.GetPtr() + (nIndex * sizeof(CBaseClient)));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
@ -24,7 +25,7 @@ CBaseClient* CBaseClient::GetClient(int nIndex) const
|
||||
//---------------------------------------------------------------------------------
|
||||
int32_t CBaseClient::GetUserID(void) const
|
||||
{
|
||||
return m_UserID;
|
||||
return m_nUserID;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
@ -32,7 +33,7 @@ int32_t CBaseClient::GetUserID(void) const
|
||||
//---------------------------------------------------------------------------------
|
||||
int64_t CBaseClient::GetOriginID(void) const
|
||||
{
|
||||
return m_OriginID;
|
||||
return m_nOriginID;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
@ -64,7 +65,7 @@ void* CBaseClient::GetNetChan(void) const
|
||||
//---------------------------------------------------------------------------------
|
||||
void CBaseClient::SetUserID(int32_t nUserID)
|
||||
{
|
||||
m_UserID = nUserID;
|
||||
m_nUserID = nUserID;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
@ -72,7 +73,7 @@ void CBaseClient::SetUserID(int32_t nUserID)
|
||||
//---------------------------------------------------------------------------------
|
||||
void CBaseClient::SetOriginID(int64_t nOriginID)
|
||||
{
|
||||
m_OriginID = nOriginID;
|
||||
m_nOriginID = nOriginID;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
|
@ -2,6 +2,8 @@
|
||||
#include "client/client.h"
|
||||
#include "common/protocol.h"
|
||||
|
||||
class CBaseServer;
|
||||
|
||||
class CBaseClient
|
||||
{
|
||||
public:
|
||||
@ -27,22 +29,30 @@ public:
|
||||
static void* Clear(CBaseClient* pBaseClient);
|
||||
|
||||
private:
|
||||
char pad_0000[0x10]; //0x0000
|
||||
int32_t m_UserID; //0x0010
|
||||
char pad_0014[0x38C]; //0x0014
|
||||
void* m_NetChannel; //0x03A0
|
||||
char pad_03A8[0x8]; //0x03A8
|
||||
SIGNONSTATE m_nSignonState; //0x03B0
|
||||
char pad_03B4[0x4]; //0x03B4
|
||||
int64_t m_OriginID; //0x03B8
|
||||
char pad_03C0[0x1D8]; //0x03C0
|
||||
#if defined (GAMEDLL_S2) || defined (GAMEDLL_S3)
|
||||
int64_t pad_0598; //0x0598
|
||||
#endif
|
||||
bool m_bFakePlayer; //0x05A0
|
||||
char pad_05A4[0x18]; //0x05A4
|
||||
PERSISTENCE m_nPersistenceState; //0x05BC
|
||||
char pad_05C0[g_dwCClientPadding]; //0x05C0
|
||||
// [ PIXIE ]: AMOS PLEASE VERIFY STRUCT INTEGRITY FOR EARLIER SEASONS. THERE WAS A PADDING AFTER ORIGINID BEFORE.
|
||||
char pad_0000[16]; //0x0000
|
||||
std::int32_t m_nUserID; //0x0010
|
||||
char pad_0014[844]; //0x0014
|
||||
void* m_ConVars; //0x0360
|
||||
char pad_0368[8]; //0x0368
|
||||
CBaseServer* m_Server; //0x0370
|
||||
char pad_0378[40]; //0x0378
|
||||
void* m_NetChannel; //0x03A0
|
||||
char pad_03A8[8]; //0x03A8
|
||||
SIGNONSTATE m_nSignonState; //0x03B0
|
||||
std::int32_t m_nDeltaTick; //0x03B4
|
||||
std::int64_t m_nOriginID; //0x03B8
|
||||
char pad_03C0[480]; //0x03C0
|
||||
bool m_bFakePlayer; //0x05A0
|
||||
bool m_bReceivedPacket; //0x05A1
|
||||
bool m_bLowViolence; //0x05A2
|
||||
bool m_bFullyAuthenticated; //0x05A3
|
||||
char pad_05A4[24]; //0x05A4
|
||||
PERSISTENCE m_nPersistenceState; //0x05BC
|
||||
char pad_05C0[302676]; //0x05C0
|
||||
std::int32_t m_LastMovementTick; //0x4A414
|
||||
char pad_4A418[168]; //0x4A418
|
||||
|
||||
};
|
||||
|
||||
namespace
|
||||
|
@ -12,35 +12,26 @@
|
||||
#include "common/protocol.h"
|
||||
#include "engine/baseserver.h"
|
||||
#include "engine/baseclient.h"
|
||||
#include "public/include/edict.h"
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
// Purpose: Gets the number of human players on the server
|
||||
// Output : int64_t
|
||||
// !TODO : Rebuild properly..
|
||||
//---------------------------------------------------------------------------------
|
||||
int64_t CBaseServer::GetNumHumanPlayers(void) const
|
||||
int CBaseServer::GetNumHumanPlayers(void) const
|
||||
{
|
||||
uint32_t nHumans = 0i64;
|
||||
if (SHIDWORD(*g_dwMaxClients) > 0)
|
||||
int nHumans = 0;
|
||||
for (int i = 0; i < g_ServerGlobalVariables->m_nMaxClients; i++)
|
||||
{
|
||||
bool v13 = false;
|
||||
uint32_t v14 = 0;
|
||||
int32_t* v11 = reinterpret_cast<int*>(&*m_Clients); // CUtlVector<CBaseClient*> m_Clients.
|
||||
int64_t nHumanCount = HIDWORD(*g_dwMaxClients);
|
||||
do
|
||||
{
|
||||
if (*(v11 - 124) >= static_cast<int>(SIGNONSTATE::SIGNONSTATE_CONNECTED)) // m_Client[i]->IsConnected().
|
||||
v13 = *v11 == 0;
|
||||
else
|
||||
v13 = 0;
|
||||
v14 = nHumans + 1;
|
||||
if (!v13)
|
||||
v14 = nHumans;
|
||||
v11 += 0x12930;
|
||||
nHumans = v14;
|
||||
--nHumanCount;
|
||||
} while (nHumanCount);
|
||||
CBaseClient* client = g_pClient->GetClient(i);
|
||||
if (!client)
|
||||
continue;
|
||||
|
||||
if (client->IsConnected())
|
||||
nHumans++;
|
||||
}
|
||||
|
||||
return nHumans;
|
||||
}
|
||||
|
||||
@ -49,21 +40,20 @@ int64_t CBaseServer::GetNumHumanPlayers(void) const
|
||||
// Output : int64_t
|
||||
// !TODO : Rebuild properly..
|
||||
//---------------------------------------------------------------------------------
|
||||
int64_t CBaseServer::GetNumFakeClients(void) const
|
||||
int CBaseServer::GetNumFakeClients(void) const
|
||||
{
|
||||
int nBots = 0i64;
|
||||
if (SHIDWORD(*g_dwMaxClients) > 0)
|
||||
int nBots = 0;
|
||||
for (int i = 0; i < g_ServerGlobalVariables->m_nMaxClients; i++)
|
||||
{
|
||||
int32_t* v16 = reinterpret_cast<int*>(&*m_Clients); // CUtlVector<CBaseClient*> m_Clients.
|
||||
int64_t nBotCount = HIDWORD(*g_dwMaxClients);
|
||||
do
|
||||
{
|
||||
if (*(v16 - 124) >= 2 && *v16)
|
||||
nBots = (nBots + 1);
|
||||
v16 += 76080;
|
||||
--nBotCount;
|
||||
} while (nBotCount);
|
||||
CBaseClient* client = g_pClient->GetClient(i);
|
||||
if (!client)
|
||||
continue;
|
||||
|
||||
if (client->IsConnected() && client->IsFakeClient())
|
||||
nBots++;
|
||||
}
|
||||
|
||||
return nBots;
|
||||
}
|
||||
|
||||
CBaseServer* g_pServer = new CBaseServer(); // !TODO: Replace with engine global if found.
|
||||
|
@ -3,25 +3,14 @@
|
||||
|
||||
namespace
|
||||
{
|
||||
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1)
|
||||
int64_t* g_dwMaxClients = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x8B\x05\x00\x00\x00\x00\xC3\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\x48\x83\xEC\x28\x45\x33\xC0",
|
||||
"xx????xxxxxxxxxxxxxxxxx").ResolveRelativeAddressSelf(0x2, 0x6).RCast<int64_t*>(); /*8B 05 ? ? ? ? C3 CC CC CC CC CC CC CC CC CC 48 83 EC 28 45 33 C0*/
|
||||
#elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3)
|
||||
int64_t* g_dwMaxClients = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x8B\x05\x00\x00\x00\x00\xC3\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\x48\x83\xEC\x28\x48\x8B\x05\x00\x00\x00\x00",
|
||||
"xx????xxxxxxxxxxxxxxxxx????").ResolveRelativeAddressSelf(0x2, 0x6).RCast<int64_t*>(); /*8B 05 ? ? ? ? C3 CC CC CC CC CC CC CC CC CC 48 83 EC 28 48 8B 05 ? ? ? ?*/
|
||||
#endif
|
||||
int64_t* g_dwMaxFakeClients = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x8B\x15\x00\x00\x00\x00\x33\xC0\x85\xD2\x7E\x37",
|
||||
"xx????xxxxxx").ResolveRelativeAddressSelf(0x2, 0x6).RCast<int64_t*>(); /*8B 15 ? ? ? ? 33 C0 85 D2 7E 37*/
|
||||
|
||||
// This is a CUtlVector
|
||||
CBaseClient* m_Clients = p_IVEngineServer__GetNumHumanPlayers.Offset(0x0).FindPatternSelf("48 8D", ADDRESS::Direction::DOWN).ResolveRelativeAddress(0x3, 0x7).RCast<CBaseClient*>();
|
||||
}
|
||||
|
||||
class CBaseServer
|
||||
{
|
||||
public:
|
||||
int64_t GetNumHumanPlayers(void) const;
|
||||
int64_t GetNumFakeClients(void) const;
|
||||
int GetNumHumanPlayers(void) const;
|
||||
int GetNumFakeClients(void) const;
|
||||
};
|
||||
extern CBaseServer* g_pServer;
|
||||
|
||||
@ -30,9 +19,8 @@ class HBaseServer : public IDetour
|
||||
{
|
||||
virtual void debugp()
|
||||
{
|
||||
std::cout << "| VAR: g_dwMaxClients : 0x" << std::hex << std::uppercase << g_dwMaxClients << std::setw(0) << " |" << std::endl;
|
||||
std::cout << "| VAR: g_dwMaxFakeClients : 0x" << std::hex << std::uppercase << g_dwMaxFakeClients << std::setw(0) << " |" << std::endl;
|
||||
std::cout << "| VAR: m_Clients : 0x" << std::hex << std::uppercase << m_Clients << std::setw(0) << " |" << std::endl;
|
||||
//std::cout << "| VAR: g_dwMaxClients : 0x" << std::hex << std::uppercase << g_dwMaxClients << std::setw(0) << " |" << std::endl;
|
||||
//std::cout << "| VAR: g_dwMaxFakeClients : 0x" << std::hex << std::uppercase << g_dwMaxFakeClients << std::setw(0) << " |" << std::endl;
|
||||
std::cout << "+----------------------------------------------------------------+" << std::endl;
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user