Skip to content

Commit

Permalink
Increase the client/server update rate to 125 Hz
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Calinou committed Dec 26, 2019
1 parent 06f3161 commit 09d59cd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/game/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion src/game/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5932,7 +5932,8 @@ namespace server
{
if(clients.empty() || (!hasnonlocalclients() && !demorecord)) return false;
enet_uint32 millis = enet_time_get()-lastsend;
if(millis < 40 && !force) return false;
// Update at 125 Hz. Higher update rates result in lower effective latency.
if(millis < 8 && !force) return false;
bool flush = buildworldstate();
lastsend += millis - (millis%40);
return flush;
Expand Down

0 comments on commit 09d59cd

Please sign in to comment.