Skip to content

Commit 56a47b6

Browse files
committed
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.
1 parent 06f3161 commit 56a47b6

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/game/client.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2215,7 +2215,7 @@ namespace client
22152215
void c2sinfo(bool force) // send update to the server
22162216
{
22172217
static int lastupdate = -1000;
2218-
if(totalmillis-lastupdate < 40 && !force) return; // don't update faster than 25fps
2218+
if(totalmillis-lastupdate < 8 && !force) return; // don't update faster than 125 FPS
22192219
lastupdate = totalmillis ? totalmillis : 1;
22202220
sendpositions();
22212221
sendmessages();

src/game/server.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5932,9 +5932,12 @@ namespace server
59325932
{
59335933
if(clients.empty() || (!hasnonlocalclients() && !demorecord)) return false;
59345934
enet_uint32 millis = enet_time_get()-lastsend;
5935-
if(millis < 40 && !force) return false;
5935+
// Send packets at 100 Hz. Higher update rates result in lower effective latency.
5936+
// This update rate should be slower than the one defined on the client to avoid "slipped" frames,
5937+
// which makes interpolation look worse.
5938+
if(millis < 10 && !force) return false;
59365939
bool flush = buildworldstate();
5937-
lastsend += millis - (millis%40);
5940+
lastsend += millis - (millis%10);
59385941
return flush;
59395942
}
59405943

0 commit comments

Comments
 (0)