From 56a47b6f9055c8eb94827c317cab02f67d8d154a Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Fri, 27 Dec 2019 00:19:24 +0100 Subject: [PATCH] Increase the client/server update rate to 125 Hz and 100 Hz This decreases effective latency significantly by making clients and servers sending and receiving updates sooner. This increases network traffic by a factor of 3, but it should be manageable on today's networks. The average game-induced latency (on top of network lag) should now be 8 ms instead of 40 ms. See https://extra-a.github.io/#bnet for more information. --- src/game/client.cpp | 2 +- src/game/server.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/game/client.cpp b/src/game/client.cpp index 3520640f1..ebf9ded9c 100644 --- a/src/game/client.cpp +++ b/src/game/client.cpp @@ -2215,7 +2215,7 @@ namespace client void c2sinfo(bool force) // send update to the server { static int lastupdate = -1000; - if(totalmillis-lastupdate < 40 && !force) return; // don't update faster than 25fps + if(totalmillis-lastupdate < 8 && !force) return; // don't update faster than 125 FPS lastupdate = totalmillis ? totalmillis : 1; sendpositions(); sendmessages(); diff --git a/src/game/server.cpp b/src/game/server.cpp index 761eecc68..7feb2090b 100644 --- a/src/game/server.cpp +++ b/src/game/server.cpp @@ -5932,9 +5932,12 @@ namespace server { if(clients.empty() || (!hasnonlocalclients() && !demorecord)) return false; enet_uint32 millis = enet_time_get()-lastsend; - if(millis < 40 && !force) return false; + // Send packets at 100 Hz. Higher update rates result in lower effective latency. + // This update rate should be slower than the one defined on the client to avoid "slipped" frames, + // which makes interpolation look worse. + if(millis < 10 && !force) return false; bool flush = buildworldstate(); - lastsend += millis - (millis%40); + lastsend += millis - (millis%10); return flush; }