From bc429ad4f827c58c878b203a2dcbf36068d1ae51 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sat, 5 Jan 2019 01:13:16 -0600 Subject: [PATCH] Determine latency with leveltime BS instead of nettics --- src/d_clisrv.c | 19 ------------------- src/g_game.c | 4 ++++ src/p_user.c | 5 ++++- 3 files changed, 8 insertions(+), 20 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index f131ef0b..eafc1283 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4007,25 +4007,6 @@ FILESTAMP &netbuffer->u.client4pak.cmd4, 1); } - { // Store the node's latency in tics on the ticcmd right as we receive it. I think this should be sync-stable - UINT8 latency = min(maketic - nettics[node], MAXPREDICTTICS-1); //@TODO add a cvar to allow setting this max - - switch (netbuffer->packettype) - { - case PT_CLIENT4CMD: - netcmds[maketic%BACKUPTICS][(UINT8)nodetoplayer4[node]].latency = latency; - - case PT_CLIENT3CMD: - netcmds[maketic%BACKUPTICS][(UINT8)nodetoplayer3[node]].latency = latency; - - case PT_CLIENT2CMD: - netcmds[maketic%BACKUPTICS][(UINT8)nodetoplayer2[node]].latency = latency; - - default: - netcmds[maketic%BACKUPTICS][netconsole].latency = latency; - } - } - // A delay before we check resynching // Used on join or just after a synch fail if (resynch_delay[node]) diff --git a/src/g_game.c b/src/g_game.c index c35d4c5d..c9b242b1 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1567,6 +1567,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) lang += (cmd->angleturn<<16); cmd->angleturn = (INT16)(lang >> 16); + cmd->latency = leveltime & 0xFF; // Send leveltime when this tic was generated to the server for control lag calculations if (!hu_stopped) { @@ -2142,6 +2143,9 @@ void G_Ticker(boolean run) players[i].kartstuff[k_throwdir] = 0; G_CopyTiccmd(cmd, &netcmds[buf][i], 1); + + // Use the leveltime sent in the player's ticcmd to determine control lag + cmd->latency = min((leveltime & 0xFF) - cmd->latency, MAXPREDICTTICS-1); //@TODO add a cvar to allow setting this max } } diff --git a/src/p_user.c b/src/p_user.c index 65ec2547..32223e6e 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -6678,7 +6678,10 @@ static void P_MovePlayer(player_t *player) if (add_delta) { player->mo->angle += angle_diff<<16; player->mo->angle &= ~0xFFFF; // Try to keep the turning somewhat similar to how it was before? - CONS_Printf("leftover turn (%s): %d\n", player_names[player-players], (INT16) (cmd->angleturn - (player->mo->angle>>16))); + CONS_Printf("leftover turn (%s): %5d or %4d%%\n", + player_names[player-players], + (INT16) (cmd->angleturn - (player->mo->angle>>16)), + (INT16) (cmd->angleturn - (player->mo->angle>>16)) * 100 / (angle_diff ?: 1)); } }