From 174f9b46f3e4cccbd3e7b555bb1acb1fb9759e8a Mon Sep 17 00:00:00 2001 From: Amos Date: Fri, 18 Aug 2023 02:33:41 +0200 Subject: [PATCH] Fully map out net frame and flow structures Mapped out 'netframe_header_s', 'netframe_s', and 'netflow_s' entirely. --- r5dev/engine/net_chan.cpp | 12 ++++++------ r5dev/engine/net_chan.h | 33 +++++++++++++++++++++------------ 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/r5dev/engine/net_chan.cpp b/r5dev/engine/net_chan.cpp index 311590b6..b80919fc 100644 --- a/r5dev/engine/net_chan.cpp +++ b/r5dev/engine/net_chan.cpp @@ -24,15 +24,15 @@ //----------------------------------------------------------------------------- float CNetChan::GetNetworkLoss() const { - float v1 = *&m_DataFlow[1].frames[0].one; - if (!v1 && !m_nSequencesSkipped_MAYBE) + int64_t totalupdates = this->m_DataFlow[FLOW_INCOMING].totalupdates; + if (!totalupdates && !this->m_nSequencesSkipped_MAYBE) return 0.0f; - float v4 = (v1 + m_nSequencesSkipped_MAYBE); - if (v1 + m_nSequencesSkipped_MAYBE < 0) - v4 = v4 + float(2 ^ 64); + float loss = (float)(totalupdates + m_nSequencesSkipped_MAYBE); + if (totalupdates + m_nSequencesSkipped_MAYBE < 0.0f) + loss += float(2 ^ 64); - return m_nSequencesSkipped_MAYBE / v4; + return m_nSequencesSkipped_MAYBE / loss; } //----------------------------------------------------------------------------- diff --git a/r5dev/engine/net_chan.h b/r5dev/engine/net_chan.h index 982cf113..501cde4e 100644 --- a/r5dev/engine/net_chan.h +++ b/r5dev/engine/net_chan.h @@ -28,18 +28,23 @@ class CClient; class CNetChan; //----------------------------------------------------------------------------- -struct netframe_t +typedef struct netframe_header_s { - float one; - float two; - float three; - float four; - float five; - float six; -}; + float time; + int size; + short choked; + bool valid; + float latency; +} netframe_header_t; + +typedef struct netframe_s +{ + int dropped; + float avg_latency; +} netframe_t; //----------------------------------------------------------------------------- -struct netflow_t +typedef struct netflow_s { float nextcompute; float avgbytespersec; @@ -48,11 +53,15 @@ struct netflow_t float avgchoke; float avglatency; float latency; + float maxlatency; int64_t totalpackets; int64_t totalbytes; + int64_t totalupdates; + int currentindex; + netframe_header_t frame_headers[NET_FRAMES_BACKUP]; netframe_t frames[NET_FRAMES_BACKUP]; - netframe_t current_frame; -}; + netframe_t* current_frame; +} netflow_t; //----------------------------------------------------------------------------- struct dataFragments_t @@ -197,7 +206,7 @@ private: int64_t m_StreamSendBuffer; bf_write m_StreamSend; uint8_t m_bInMatch_maybe; - netflow_t m_DataFlow[2]; + netflow_t m_DataFlow[MAX_FLOWS]; int m_nLifetimePacketsDropped; int m_nSessionPacketsDropped; int m_nSequencesSkipped_MAYBE;