From 9b7764df9f36f49f4e97c06b4a4034f2b2ceda4e Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Sat, 16 May 2020 23:37:15 +0200 Subject: [PATCH] Store tic values in packets on two bytes instead of one --- src/d_clisrv.c | 20 ++++++++++---------- src/d_clisrv.h | 10 +++++----- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index ed0b8e528..6119a6561 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -205,14 +205,14 @@ tic_t ExpandTics(INT32 low) { INT32 delta; - delta = low - (maketic & UINT8_MAX); + delta = low - (maketic & UINT16_MAX); - if (delta >= -64 && delta <= 64) - return (maketic & ~UINT8_MAX) + low; - else if (delta > 64) - return (maketic & ~UINT8_MAX) - 256 + low; - else //if (delta < -64) - return (maketic & ~UINT8_MAX) + 256 + low; + if (delta >= -128 && delta <= 128) + return (maketic & ~UINT16_MAX) + low; + else if (delta > 128) + return (maketic & ~UINT16_MAX) - 65536 + low; + else //if (delta < -128) + return (maketic & ~UINT16_MAX) + 65536 + low; } // ----------------------------------------------------------------- @@ -4534,8 +4534,8 @@ static void CL_SendClientCmd(void) if (cl_packetmissed) netbuffer->packettype++; - netbuffer->u.clientpak.resendfrom = (UINT8)(neededtic & UINT8_MAX); - netbuffer->u.clientpak.client_tic = (UINT8)(gametic & UINT8_MAX); + netbuffer->u.clientpak.resendfrom = (UINT16)(neededtic & UINT16_MAX); + netbuffer->u.clientpak.client_tic = (UINT16)( gametic & UINT16_MAX); if (gamestate == GS_WAITINGPLAYERS) { @@ -4659,7 +4659,7 @@ static void SV_SendTics(void) // Send the tics netbuffer->packettype = PT_SERVERTICS; - netbuffer->u.serverpak.starttic = (UINT8)realfirsttic; + netbuffer->u.serverpak.starttic = (UINT16)realfirsttic; netbuffer->u.serverpak.numtics = (UINT8)(lasttictosend - realfirsttic); netbuffer->u.serverpak.numslots = (UINT8)SHORT(doomcom->numslots); bufpos = (UINT8 *)&netbuffer->u.serverpak.cmds; diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 463240a2a..5c32731d3 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -104,8 +104,8 @@ void Command_Numnodes(void); // Client to server packet typedef struct { - UINT8 client_tic; - UINT8 resendfrom; + UINT16 client_tic; + UINT16 resendfrom; INT16 consistancy; ticcmd_t cmd; } ATTRPACK clientcmd_pak; @@ -114,8 +114,8 @@ typedef struct // WARNING: must have the same format of clientcmd_pak, for more easy use typedef struct { - UINT8 client_tic; - UINT8 resendfrom; + UINT16 client_tic; + UINT16 resendfrom; INT16 consistancy; ticcmd_t cmd, cmd2; } ATTRPACK client2cmd_pak; @@ -128,7 +128,7 @@ typedef struct // this packet is too large typedef struct { - UINT8 starttic; + UINT16 starttic; UINT8 numtics; UINT8 numslots; // "Slots filled": Highest player number in use plus one. ticcmd_t cmds[45]; // Normally [BACKUPTIC][MAXPLAYERS] but too large