diff --git a/r5dev/engine/net_chan.cpp b/r5dev/engine/net_chan.cpp index 15966ed9..af019ebc 100644 --- a/r5dev/engine/net_chan.cpp +++ b/r5dev/engine/net_chan.cpp @@ -18,51 +18,6 @@ #endif // !CLIENT_DLL -//----------------------------------------------------------------------------- -// Purpose: gets the netchannel name -// Output : const char* -//----------------------------------------------------------------------------- -const char* CNetChan::GetName(void) const -{ - return this->m_Name; -} - -//----------------------------------------------------------------------------- -// Purpose: gets the netchannel address -// Output : const char* -//----------------------------------------------------------------------------- -const char* CNetChan::GetAddress(bool onlyBase) const -{ - return this->remote_address.ToString(onlyBase); -} - -//----------------------------------------------------------------------------- -// Purpose: gets the netchannel port in host byte order -// Output : int -//----------------------------------------------------------------------------- -int CNetChan::GetPort(void) const -{ - return int(ntohs(this->remote_address.GetPort())); -} - -//----------------------------------------------------------------------------- -// Purpose: gets the netchannel data rate -// Output : int -//----------------------------------------------------------------------------- -int CNetChan::GetDataRate(void) const -{ - return this->m_Rate; -} - -//----------------------------------------------------------------------------- -// Purpose: gets the netchannel buffer size (NET_FRAMES_BACKUP) -// Output : int -//----------------------------------------------------------------------------- -int CNetChan::GetBufferSize(void) const -{ - return NET_FRAMES_BACKUP; -} - //----------------------------------------------------------------------------- // Purpose: gets the netchannel network loss // Output : float @@ -80,86 +35,6 @@ float CNetChan::GetNetworkLoss() const return m_nSequencesSkipped_MAYBE / v4; } -//----------------------------------------------------------------------------- -// Purpose: gets the netchannel latency -// Input : flow - -// Output : float -//----------------------------------------------------------------------------- -float CNetChan::GetLatency(int flow) const -{ - return this->m_DataFlow[flow].latency; -} - -//----------------------------------------------------------------------------- -// Purpose: gets the netchannel average choke -// Input : flow - -// Output : float -//----------------------------------------------------------------------------- -float CNetChan::GetAvgChoke(int flow) const -{ - return this->m_DataFlow[flow].avgchoke; -} - -//----------------------------------------------------------------------------- -// Purpose: gets the netchannel average latency -// Input : flow - -// Output : float -//----------------------------------------------------------------------------- -float CNetChan::GetAvgLatency(int flow) const -{ - return this->m_DataFlow[flow].avglatency; -} - -//----------------------------------------------------------------------------- -// Purpose: gets the netchannel average loss -// Input : flow - -// Output : float -//----------------------------------------------------------------------------- -float CNetChan::GetAvgLoss(int flow) const -{ - return this->m_DataFlow[flow].avgloss; -} - -//----------------------------------------------------------------------------- -// Purpose: gets the netchannel average packets -// Input : flow - -// Output : float -//----------------------------------------------------------------------------- -float CNetChan::GetAvgPackets(int flow) const -{ - return this->m_DataFlow[flow].avgpacketspersec; -} - -//----------------------------------------------------------------------------- -// Purpose: gets the netchannel average data -// Input : flow - -// Output : float -//----------------------------------------------------------------------------- -float CNetChan::GetAvgData(int flow) const -{ - return this->m_DataFlow[flow].avgbytespersec; -} - -//----------------------------------------------------------------------------- -// Purpose: gets the netchannel total data -// Input : flow - -// Output : int64_t -//----------------------------------------------------------------------------- -int64_t CNetChan::GetTotalData(int flow) const -{ - return this->m_DataFlow[flow].totalbytes; -} - -//----------------------------------------------------------------------------- -// Purpose: gets the netchannel total packets -// Input : flow - -// Output : int64_t -//----------------------------------------------------------------------------- -int64_t CNetChan::GetTotalPackets(int flow) const -{ - return this->m_DataFlow[flow].totalpackets; -} - //----------------------------------------------------------------------------- // Purpose: gets the netchannel sequence number // Input : flow - @@ -169,11 +44,11 @@ int CNetChan::GetSequenceNr(int flow) const { if (flow == FLOW_OUTGOING) { - return this->m_nOutSequenceNr; + return m_nOutSequenceNr; } else if (flow == FLOW_INCOMING) { - return this->m_nInSequenceNr; + return m_nInSequenceNr; } return NULL; @@ -189,57 +64,6 @@ double CNetChan::GetTimeConnected(void) const return (t > 0.0) ? t : 0.0; } -//----------------------------------------------------------------------------- -// Purpose: gets the netchannel timeout -// Output : float -//----------------------------------------------------------------------------- -float CNetChan::GetTimeoutSeconds(void) const -{ - return this->m_Timeout; -} - -//----------------------------------------------------------------------------- -// Purpose: gets the netchannel socket -// Output : int -//----------------------------------------------------------------------------- -int CNetChan::GetSocket(void) const -{ - return this->m_Socket; -} - -//----------------------------------------------------------------------------- -// Purpose: gets a const reference to m_StreamVoice -//----------------------------------------------------------------------------- -const bf_write& CNetChan::GetStreamVoice(void) const -{ - return this->m_StreamVoice; -} - -//----------------------------------------------------------------------------- -// Purpose: gets a const reference to remote_address -//----------------------------------------------------------------------------- -const netadr_t& CNetChan::GetRemoteAddress(void) const -{ - return this->remote_address; -} - -//----------------------------------------------------------------------------- -// Purpose: checks if the reliable stream is overflowed -// Output : true if overflowed, false otherwise -//----------------------------------------------------------------------------- -bool CNetChan::IsOverflowed(void) const -{ - return this->m_StreamReliable.IsOverflowed(); -} - -//----------------------------------------------------------------------------- -// Purpose: clears the netchannel -//----------------------------------------------------------------------------- -void CNetChan::Clear(bool bStopProcessing) -{ - v_NetChan_Clear(this, bStopProcessing); -} - //----------------------------------------------------------------------------- // Purpose: shutdown netchannel // Input : *this - @@ -333,35 +157,6 @@ bool CNetChan::SendNetMsg(INetMessage& msg, bool bForceReliable, bool bVoice) return true; } -//----------------------------------------------------------------------------- -// Purpose: increments choked packet count -//----------------------------------------------------------------------------- -void CNetChan::SetChoked(void) -{ - m_nOutSequenceNr++; // Sends to be done since move command use sequence number. - m_nChokedPackets++; -} - -//----------------------------------------------------------------------------- -// Purpose: sets the remote frame times -// Input : flFrameTime - -// flFrameTimeStdDeviation - -//----------------------------------------------------------------------------- -void CNetChan::SetRemoteFramerate(float flFrameTime, float flFrameTimeStdDeviation) -{ - m_flRemoteFrameTime = flFrameTime; - m_flRemoteFrameTimeStdDeviation = flFrameTimeStdDeviation; -} - -//----------------------------------------------------------------------------- -// Purpose: sets the remote cpu statistics -// Input : nStats - -//----------------------------------------------------------------------------- -void CNetChan::SetRemoteCPUStatistics(uint8_t nStats) -{ - m_nServerCPU = nStats; -} - /////////////////////////////////////////////////////////////////////////////// void VNetChan::Attach() const { diff --git a/r5dev/engine/net_chan.h b/r5dev/engine/net_chan.h index 8f5d60d7..6ad64657 100644 --- a/r5dev/engine/net_chan.h +++ b/r5dev/engine/net_chan.h @@ -97,47 +97,47 @@ inline bool(*v_NetChan_ProcessMessages)(CNetChan* pChan, bf_read* pMsg); class CNetChan { public: - const char* GetName(void) const; - const char* GetAddress(bool onlyBase = false) const; - int GetPort(void) const; - int GetDataRate(void) const; - int GetBufferSize(void) const; + inline const char* GetName(void) const { return m_Name; } + inline const char* GetAddress(bool onlyBase = false) const { return remote_address.ToString(onlyBase); } + inline int GetPort(void) const { return int(ntohs(remote_address.GetPort())); } + inline int GetDataRate(void) const { return m_Rate; } + inline int GetBufferSize(void) const { return NET_FRAMES_BACKUP; } - float GetNetworkLoss() const; + float GetNetworkLoss() const; - float GetLatency(int flow) const; - float GetAvgChoke(int flow) const; - float GetAvgLatency(int flow) const; - float GetAvgLoss(int flow) const; - float GetAvgPackets(int flow) const; - float GetAvgData(int flow) const; + inline float GetLatency(int flow) const { Assert(flow < sizeof(m_DataFlow)); return m_DataFlow[flow].latency; } + inline float GetAvgChoke(int flow) const { Assert(flow < sizeof(m_DataFlow)); return m_DataFlow[flow].avgchoke; } + inline float GetAvgLatency(int flow) const { Assert(flow < sizeof(m_DataFlow)); return m_DataFlow[flow].avglatency; } + inline float GetAvgLoss(int flow) const { Assert(flow < sizeof(m_DataFlow)); return m_DataFlow[flow].avgloss; } + inline float GetAvgPackets(int flow) const { Assert(flow < sizeof(m_DataFlow)); return m_DataFlow[flow].avgpacketspersec; } + inline float GetAvgData(int flow) const { Assert(flow < sizeof(m_DataFlow)); return m_DataFlow[flow].avgbytespersec; } + inline int64_t GetTotalData(int flow) const { Assert(flow < sizeof(m_DataFlow)); return m_DataFlow[flow].totalbytes; } + inline int64_t GetTotalPackets(int flow) const { Assert(flow < sizeof(m_DataFlow)); return m_DataFlow[flow].totalpackets; } - int64_t GetTotalData(int flow) const; - int64_t GetTotalPackets(int flow) const; int GetSequenceNr(int flow) const; - - float GetTimeoutSeconds(void) const; double GetTimeConnected(void) const; - int GetSocket(void) const; - const bf_write& GetStreamVoice(void) const; - const netadr_t& GetRemoteAddress(void) const; + inline float GetTimeoutSeconds(void) const { return m_Timeout; } + inline int GetSocket(void) const { return m_Socket; } + inline const bf_write& GetStreamVoice(void) const { return m_StreamVoice; } + inline const netadr_t& GetRemoteAddress(void) const { return remote_address; } + inline bool IsOverflowed(void) const { return m_StreamReliable.IsOverflowed(); } - bool IsOverflowed(void) const; inline bool CanPacket(void) const { return v_NetChan_CanPacket(this); } inline int SendDatagram(bf_write* pDatagram) { return v_NetChan_SendDatagram(this, pDatagram); } bool SendNetMsg(INetMessage& msg, bool bForceReliable, bool bVoice); - void Clear(bool bStopProcessing); + inline void Clear(bool bStopProcessing) { v_NetChan_Clear(this, bStopProcessing); } inline void Shutdown(const char* szReason, uint8_t bBadRep, bool bRemoveNow) - { _Shutdown(this, szReason, bBadRep, bRemoveNow); } + { v_NetChan_Shutdown(this, szReason, bBadRep, bRemoveNow); } static void _Shutdown(CNetChan* pChan, const char* szReason, uint8_t bBadRep, bool bRemoveNow); static bool _ProcessMessages(CNetChan* pChan, bf_read* pMsg); void SetChoked(); void SetRemoteFramerate(float flFrameTime, float flFrameTimeStdDeviation); - void SetRemoteCPUStatistics(uint8_t nStats); + inline void SetRemoteCPUStatistics(uint8_t nStats) { m_nServerCPU = nStats; } + //----------------------------------------------------------------------------- public: bool m_bProcessingMessages; @@ -211,6 +211,26 @@ static_assert(sizeof(CNetChan) == 0x1AD0); static_assert(sizeof(CNetChan) == 0x1AC8); #endif +//----------------------------------------------------------------------------- +// Purpose: sets the remote frame times +// Input : flFrameTime - +// flFrameTimeStdDeviation - +//----------------------------------------------------------------------------- +inline void CNetChan::SetRemoteFramerate(float flFrameTime, float flFrameTimeStdDeviation) +{ + m_flRemoteFrameTime = flFrameTime; + m_flRemoteFrameTimeStdDeviation = flFrameTimeStdDeviation; +} + +//----------------------------------------------------------------------------- +// Purpose: increments choked packet count +//----------------------------------------------------------------------------- +inline void CNetChan::SetChoked(void) +{ + m_nOutSequenceNr++; // Sends to be done since move command use sequence number. + m_nChokedPackets++; +} + /////////////////////////////////////////////////////////////////////////////// class VNetChan : public IDetour