From c6a9b855a2c4d9b963419f0601a6d29b4e2aa010 Mon Sep 17 00:00:00 2001 From: Amos Date: Wed, 12 Jul 2023 09:11:31 +0200 Subject: [PATCH] Make simple CClient getters, inline Small enough to be inline. --- r5dev/engine/client/client.cpp | 191 --------------------------------- r5dev/engine/client/client.h | 51 +++++---- 2 files changed, 28 insertions(+), 214 deletions(-) diff --git a/r5dev/engine/client/client.cpp b/r5dev/engine/client/client.cpp index 13338404..0715f4c6 100644 --- a/r5dev/engine/client/client.cpp +++ b/r5dev/engine/client/client.cpp @@ -14,197 +14,6 @@ #include "engine/server/server.h" #include "engine/client/client.h" -//--------------------------------------------------------------------------------- -// Purpose: gets the client's team number -//--------------------------------------------------------------------------------- -int64_t CClient::GetTeamNum() const -{ - return m_iTeamNum; -} - -//--------------------------------------------------------------------------------- -// Purpose: gets the handle of this client -//--------------------------------------------------------------------------------- -edict_t CClient::GetHandle(void) const -{ - return m_nHandle; -} - -//--------------------------------------------------------------------------------- -// Purpose: gets the userID of this client -//--------------------------------------------------------------------------------- -int CClient::GetUserID(void) const -{ - return m_nUserID; -} - -//--------------------------------------------------------------------------------- -// Purpose: gets the nucleusID of this client -//--------------------------------------------------------------------------------- -uint64_t CClient::GetNucleusID(void) const -{ - return m_nNucleusID; -} - -//--------------------------------------------------------------------------------- -// Purpose: gets the signon state of this client -//--------------------------------------------------------------------------------- -SIGNONSTATE CClient::GetSignonState(void) const -{ - return m_nSignonState; -} - -//--------------------------------------------------------------------------------- -// Purpose: gets the persistence state of this client -//--------------------------------------------------------------------------------- -PERSISTENCE CClient::GetPersistenceState(void) const -{ - return m_nPersistenceState; -} - -//--------------------------------------------------------------------------------- -// Purpose: gets the net channel of this client -//--------------------------------------------------------------------------------- -CNetChan* CClient::GetNetChan(void) const -{ - return m_NetChannel; -} - -//--------------------------------------------------------------------------------- -// Purpose: gets the pointer to the server object -//--------------------------------------------------------------------------------- -CServer* CClient::GetServer(void) const -{ - return m_pServer; -} - -//--------------------------------------------------------------------------------- -// Purpose: gets the command tick -//--------------------------------------------------------------------------------- -int CClient::GetCommandTick(void) const -{ - return m_nCommandTick; -} - -//--------------------------------------------------------------------------------- -// Purpose: gets the name of this client (managed by server) -//--------------------------------------------------------------------------------- -const char* CClient::GetServerName(void) const -{ - return m_szServerName; -} - -//--------------------------------------------------------------------------------- -// Purpose: gets the name of this client (obtained from connectionless packet) -//--------------------------------------------------------------------------------- -const char* CClient::GetClientName(void) const -{ - return m_szClientName; -} - -//--------------------------------------------------------------------------------- -// Purpose: sets the handle of this client -//--------------------------------------------------------------------------------- -void CClient::SetHandle(edict_t nHandle) -{ - m_nHandle = nHandle; -} - -//--------------------------------------------------------------------------------- -// Purpose: sets the userID of this client -//--------------------------------------------------------------------------------- -void CClient::SetUserID(uint32_t nUserID) -{ - m_nUserID = nUserID; -} - -//--------------------------------------------------------------------------------- -// Purpose: sets the nucleusID of this client -//--------------------------------------------------------------------------------- -void CClient::SetNucleusID(uint64_t nNucleusID) -{ - m_nNucleusID = nNucleusID; -} - -//--------------------------------------------------------------------------------- -// Purpose: sets the signon state of this client -//--------------------------------------------------------------------------------- -void CClient::SetSignonState(SIGNONSTATE nSignonState) -{ - m_nSignonState = nSignonState; -} - -//--------------------------------------------------------------------------------- -// Purpose: sets the persistence state of this client -//--------------------------------------------------------------------------------- -void CClient::SetPersistenceState(PERSISTENCE nPersistenceState) -{ - m_nPersistenceState = nPersistenceState; -} - -//--------------------------------------------------------------------------------- -// Purpose: sets the net channel of this client -// !TODO : Remove this and rebuild INetChannel -//--------------------------------------------------------------------------------- -void CClient::SetNetChan(CNetChan* pNetChan) -{ - m_NetChannel = pNetChan; -} - -//--------------------------------------------------------------------------------- -// Purpose: checks if client is connected to server -// Output : true if connected, false otherwise -//--------------------------------------------------------------------------------- -bool CClient::IsConnected(void) const -{ - return m_nSignonState >= SIGNONSTATE::SIGNONSTATE_CONNECTED; -} - -//--------------------------------------------------------------------------------- -// Purpose: checks if client is spawned to server -// Output : true if connected, false otherwise -//--------------------------------------------------------------------------------- -bool CClient::IsSpawned(void) const -{ - return m_nSignonState >= SIGNONSTATE::SIGNONSTATE_NEW; -} - -//--------------------------------------------------------------------------------- -// Purpose: checks if client is active to server -// Output : true if connected, false otherwise -//--------------------------------------------------------------------------------- -bool CClient::IsActive(void) const -{ - return m_nSignonState == SIGNONSTATE::SIGNONSTATE_FULL; -} - -//--------------------------------------------------------------------------------- -// Purpose: checks if client's persistence data is available -// Output : true if available, false otherwise -//--------------------------------------------------------------------------------- -bool CClient::IsPersistenceAvailable(void) const -{ - return m_nPersistenceState >= PERSISTENCE::PERSISTENCE_AVAILABLE; -} - -//--------------------------------------------------------------------------------- -// Purpose: checks if client's persistence data is ready -// Output : true if ready, false otherwise -//--------------------------------------------------------------------------------- -bool CClient::IsPersistenceReady(void) const -{ - return m_nPersistenceState == PERSISTENCE::PERSISTENCE_READY; -} - -//--------------------------------------------------------------------------------- -// Purpose: checks if client is a fake client -// Output : true if connected, false otherwise -//--------------------------------------------------------------------------------- -bool CClient::IsFakeClient(void) const -{ - return m_bFakePlayer; -} - //--------------------------------------------------------------------------------- // Purpose: checks if this client is an actual human player // Output : true if human, false otherwise diff --git a/r5dev/engine/client/client.h b/r5dev/engine/client/client.h index f95e75ab..17dfba70 100644 --- a/r5dev/engine/client/client.h +++ b/r5dev/engine/client/client.h @@ -63,29 +63,34 @@ class CClient : IClientMessageHandler, INetChannelHandler { friend class ServerDataBlockSender; public: - int64_t GetTeamNum() const; - edict_t GetHandle(void) const; - int GetUserID(void) const; - uint64_t GetNucleusID(void) const; - SIGNONSTATE GetSignonState(void) const; - PERSISTENCE GetPersistenceState(void) const; - CNetChan* GetNetChan(void) const; - CServer* GetServer(void) const; - int GetCommandTick(void) const; - const char* GetServerName(void) const; - const char* GetClientName(void) const; - void SetHandle(edict_t nHandle); - void SetUserID(uint32_t nUserID); - void SetNucleusID(uint64_t nNucleusID); - void SetSignonState(SIGNONSTATE nSignonState); - void SetPersistenceState(PERSISTENCE nPersistenceState); - void SetNetChan(CNetChan* pNetChan); - bool IsConnected(void) const; - bool IsSpawned(void) const; - bool IsActive(void) const; - bool IsPersistenceAvailable(void) const; - bool IsPersistenceReady(void) const; - bool IsFakeClient(void) const; + inline int64_t GetTeamNum() const { return m_iTeamNum; } + inline edict_t GetHandle(void) const { return m_nHandle; } + inline int GetUserID(void) const { return m_nUserID; } + inline uint64_t GetNucleusID(void) const { return m_nNucleusID; } + + inline SIGNONSTATE GetSignonState(void) const { return m_nSignonState; } + inline PERSISTENCE GetPersistenceState(void) const { return m_nPersistenceState; } + inline CNetChan* GetNetChan(void) const { return m_NetChannel; } + inline CServer* GetServer(void) const { return m_pServer; } + + inline int GetCommandTick(void) const { return m_nCommandTick; } + inline const char* GetServerName(void) const { return m_szServerName; } + inline const char* GetClientName(void) const { return m_szClientName; } + + inline void SetHandle(edict_t nHandle) { m_nHandle = nHandle; } + inline void SetUserID(uint32_t nUserID) { m_nUserID = nUserID; } + inline void SetNucleusID(uint64_t nNucleusID) { m_nNucleusID = nNucleusID; } + + inline void SetSignonState(SIGNONSTATE nSignonState) { m_nSignonState = nSignonState; } + inline void SetPersistenceState(PERSISTENCE nPersistenceState) { m_nPersistenceState = nPersistenceState; } + inline void SetNetChan(CNetChan* pNetChan) { m_NetChannel = pNetChan; } + + inline bool IsConnected(void) const { return m_nSignonState >= SIGNONSTATE::SIGNONSTATE_CONNECTED; } + inline bool IsSpawned(void) const { return m_nSignonState >= SIGNONSTATE::SIGNONSTATE_NEW; } + inline bool IsActive(void) const { return m_nSignonState == SIGNONSTATE::SIGNONSTATE_FULL; } + inline bool IsPersistenceAvailable(void) const { return m_nPersistenceState >= PERSISTENCE::PERSISTENCE_AVAILABLE; } + inline bool IsPersistenceReady(void) const { return m_nPersistenceState == PERSISTENCE::PERSISTENCE_READY; } + inline bool IsFakeClient(void) const { return m_bFakePlayer; } bool IsHumanPlayer(void) const; bool SendNetMsgEx(CNetMessage* pMsg, char bLocal, bool bForceReliable, bool bVoice);