From 2a5feab064a183ca6c96126f4ad2cd8bebf9470b Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Sun, 14 Apr 2024 22:10:48 +0800 Subject: [PATCH] [raknet] Implement `ReliabilityLayer::UpdateNextActionTime()` --- raknet/ReliabilityLayer.cpp | 13 +++++++++++++ raknet/ReliabilityLayer.h | 12 ++++++++++++ 2 files changed, 25 insertions(+) diff --git a/raknet/ReliabilityLayer.cpp b/raknet/ReliabilityLayer.cpp index 236c656..3cacca6 100644 --- a/raknet/ReliabilityLayer.cpp +++ b/raknet/ReliabilityLayer.cpp @@ -2,6 +2,9 @@ #include "ReliabilityLayer.h" +static const float PING_MULTIPLIER_TO_RESEND=3.0; // So internet ping variation doesn't cause needless resends +static const RakNetTime MIN_PING_TO_RESEND=30; // So system timer changes and CPU lag don't send needless resends + ReliabilityLayer::ReliabilityLayer() { // TODO: ReliabilityLayer::ReliabilityLayer @@ -13,3 +16,13 @@ void ReliabilityLayer::InitializeVariables( void ) { // TODO: ReliabilityLayer::InitializeVariables } + +//------------------------------------------------------------------------------------------------------- +void ReliabilityLayer::UpdateNextActionTime(void) +{ + //double multiple = log10(currentBandwidth/MINIMUM_SEND_BPS) / 0.30102999566398119521373889472449; + if (ping*(RakNetTime)PING_MULTIPLIER_TO_RESEND < MIN_PING_TO_RESEND) + ackTimeIncrement=(RakNetTimeNS)MIN_PING_TO_RESEND*1000; + else + ackTimeIncrement=(RakNetTimeNS)(ping*(RakNetTime)PING_MULTIPLIER_TO_RESEND)*1000; +} diff --git a/raknet/ReliabilityLayer.h b/raknet/ReliabilityLayer.h index 26d9198..a01cc4f 100644 --- a/raknet/ReliabilityLayer.h +++ b/raknet/ReliabilityLayer.h @@ -13,9 +13,21 @@ public: /// Constructor ReliabilityLayer(); +private: + // Initialize the variables void InitializeVariables( void ); + // Make it so we don't do resends within a minimum threshold of time + void UpdateNextActionTime(void); + + char _gap0[713]; + + RakNetTime ping; + + char _gap[1020]; + + RakNetTimeNS ackTimeIncrement; }; #endif