Send latency in players' ticcmds

This commit is contained in:
fickleheart 2019-01-04 22:27:09 -06:00
parent 87a09e051d
commit 12b0e7d5da
5 changed files with 26 additions and 5 deletions

View File

@ -4007,6 +4007,25 @@ 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], 12); //@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])

View File

@ -433,10 +433,10 @@ typedef struct
UINT8 reserved; // Padding
union
{
clientcmd_pak clientpak; // 144 bytes
client2cmd_pak client2pak; // 200 bytes
client3cmd_pak client3pak; // 256 bytes(?)
client4cmd_pak client4pak; // 312 bytes(?)
clientcmd_pak clientpak; // 145 bytes
client2cmd_pak client2pak; // 202 bytes
client3cmd_pak client3pak; // 258 bytes(?)
client4cmd_pak client4pak; // 316 bytes(?)
servertics_pak serverpak; // 132495 bytes (more around 360, no?)
serverconfig_pak servercfg; // 773 bytes
resynchend_pak resynchend; //

View File

@ -60,6 +60,7 @@ typedef struct
INT16 aiming; // vertical aiming, see G_BuildTicCmd
UINT16 buttons;
INT16 driftturn; // SRB2Kart: Used for getting drift turn speed
UINT8 latency; // Netgames: how many tics ago was this ticcmd generated from this player's end?
} ATTRPACK ticcmd_t;
#if defined(_MSC_VER)

View File

@ -4542,6 +4542,7 @@ ticcmd_t *G_MoveTiccmd(ticcmd_t* dest, const ticcmd_t* src, const size_t n)
dest[i].aiming = (INT16)SHORT(src[i].aiming);
dest[i].buttons = (UINT16)SHORT(src[i].buttons);
dest[i].driftturn = (INT16)SHORT(src[i].driftturn);
dest[i].latency = (INT16)SHORT(src[i].latency);
}
return dest;
}

View File

@ -8263,7 +8263,7 @@ void K_drawKartHUD(void)
{
UINT8 p;
for (p = 0; p < MAXPLAYERS; p++)
V_DrawString(8, 64+(8*p), V_YELLOWMAP, va("%d - %d", p, playernode[p]));
V_DrawString(8, 64+(8*p), V_YELLOWMAP, va("%d - %d (%dl)", p, playernode[p], players[p].cmd.latency));
}
}