From 41053eaf55a2fcc2fa01525f2aaa75f55e489316 Mon Sep 17 00:00:00 2001 From: pionere Date: Wed, 15 Nov 2023 10:48:32 +0100 Subject: [PATCH] improve adaptive net-update --- Source/nthread.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Source/nthread.cpp b/Source/nthread.cpp index 6d234c56892..465b146fa55 100644 --- a/Source/nthread.cpp +++ b/Source/nthread.cpp @@ -22,7 +22,7 @@ BYTE gbNetUpdateRate; BYTE gbEmptyTurns; #ifdef ADAPTIVE_NETUPDATE /* The 'health' of the connection. Incremented on timeout, decremented if a turn is received on time. */ -int8_t gbNetUpdateWeight; +int gbNetUpdateWeight; #endif // ADAPTIVE_NETUPDATE /* The thread to handle turns while connecting or loading a level. */ static SDL_Thread* sghThread = NULL; @@ -80,14 +80,12 @@ int nthread_recv_turns() if (status == TS_TIMEOUT) { #ifdef ADAPTIVE_NETUPDATE if (_gbTickInSync) { - gbNetUpdateWeight += 10; - if (gbNetUpdateWeight > 100) { + gbNetUpdateWeight += 200; + if (gbNetUpdateWeight > 1000) { if (((gbEmptyTurns * gbNetUpdateRate) * gnTickDelay) < 200) { gbEmptyTurns++; - gbNetUpdateWeight = 0; - } else { - gbNetUpdateWeight = 50; } + gbNetUpdateWeight = 0; } } #endif @@ -97,12 +95,12 @@ int nthread_recv_turns() } else { #ifdef ADAPTIVE_NETUPDATE gbNetUpdateWeight--; - if (gbNetUpdateWeight < -100) { + if (gbNetUpdateWeight < -1000) { if (gbEmptyTurns != 0) { gbEmptyTurns--; gbNetUpdateWeight = 0; } else { - gbNetUpdateWeight = -50; + gbNetUpdateWeight = -500; } } #endif