Store tic values in packets on two bytes instead of one

This commit is contained in:
Louis-Antoine 2020-05-16 23:37:15 +02:00
parent 208af4e710
commit 9b7764df9f
2 changed files with 15 additions and 15 deletions

View file

@ -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;

View file

@ -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