From e5f412bcb2c433dc530340632a8417baa609a2f2 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Tue, 14 Jun 2022 21:41:35 +0200 Subject: [PATCH] CClient improvements Mapped out new fields in CClient --- r5dev/engine/client/client.cpp | 26 +++++++++++++++++++++++++- r5dev/engine/client/client.h | 14 ++++++++++---- r5dev/vstdlib/callback.cpp | 8 ++++---- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/r5dev/engine/client/client.cpp b/r5dev/engine/client/client.cpp index 6b494e45..2e983741 100644 --- a/r5dev/engine/client/client.cpp +++ b/r5dev/engine/client/client.cpp @@ -22,7 +22,15 @@ CClient* CClient::GetClient(int nIndex) const //--------------------------------------------------------------------------------- // Purpose: gets the userID of this client //--------------------------------------------------------------------------------- -int32_t CClient::GetUserID(void) const +uint16_t CClient::GetHandle(void) const +{ + return m_nHandle; +} + +//--------------------------------------------------------------------------------- +// Purpose: gets the userID of this client +//--------------------------------------------------------------------------------- +uint32_t CClient::GetUserID(void) const { return m_nUserID; } @@ -59,6 +67,22 @@ CNetChan* CClient::GetNetChan(void) const return m_NetChannel; } +//--------------------------------------------------------------------------------- +// Purpose: gets the server name of this client (name is managed by server!) +//--------------------------------------------------------------------------------- +const char* CClient::GetServerName(void) const +{ + return m_szServerName; +} + +//--------------------------------------------------------------------------------- +// Purpose: gets the server name of this client (as obtained from the connectionless packet) +//--------------------------------------------------------------------------------- +const char* CClient::GetClientName(void) const +{ + return m_szClientName; +} + //--------------------------------------------------------------------------------- // Purpose: sets the userID of this client //--------------------------------------------------------------------------------- diff --git a/r5dev/engine/client/client.h b/r5dev/engine/client/client.h index c13f4491..cb869a35 100644 --- a/r5dev/engine/client/client.h +++ b/r5dev/engine/client/client.h @@ -16,11 +16,14 @@ class CClient : INetChannelHandler, IClientMessageHandler { public: CClient* GetClient(int nIndex) const; - int32_t GetUserID(void) const; + uint16_t GetHandle(void) const; + uint32_t GetUserID(void) const; uint64_t GetOriginID(void) const; SIGNONSTATE GetSignonState(void) const; PERSISTENCE GetPersistenceState(void) const; CNetChan* GetNetChan(void) const; + const char* GetServerName(void) const; + const char* GetClientName(void) const; void SetUserID(int32_t nUserID); void SetOriginID(uint64_t nOriginID); void SetSignonState(SIGNONSTATE nSignonState); @@ -39,10 +42,13 @@ public: static void VClear(CClient* pBaseClient); private: - int32_t m_nUserID; //0x0010 - char pad_0014[68]; //0x0014 + uint32_t m_nUserID; //0x0010 + uint16_t m_nHandle; //0x0014 + char m_szServerName[64]; //0x0016 int64_t m_nReputation; //0x0058 - char pad_0015[768]; //0x0060 + char pad_0014[182]; //0x0060 + char m_szClientName[64]; //0x0116 + char pad_0015[522]; //0x0156 KeyValues* m_ConVars; //0x0360 char pad_0368[8]; //0x0368 CServer* m_pServer; //0x0370 diff --git a/r5dev/vstdlib/callback.cpp b/r5dev/vstdlib/callback.cpp index 1de55ed5..6c045f5a 100644 --- a/r5dev/vstdlib/callback.cpp +++ b/r5dev/vstdlib/callback.cpp @@ -140,9 +140,9 @@ void Host_KickID_f(const CCommand& args) continue; } } - else // If its not try by userID. + else // If its not try by handle. { - int64_t nClientID = static_cast(pClient->GetUserID() + 1); // Get userID + 1. + uint64_t nClientID = static_cast(pClient->GetHandle()); if (nClientID != nTargetID) { continue; @@ -249,9 +249,9 @@ void Host_BanID_f(const CCommand& args) continue; } } - else // If its not try by userID. + else // If its not try by handle. { - int64_t nClientID = static_cast(pClient->GetUserID() + 1); // Get UserID + 1. + uint64_t nClientID = static_cast(pClient->GetHandle()); if (nClientID != nTargetID) { continue;