Always accept tics received from the server

This commit is contained in:
Gustaf Alhäll 2026-04-24 20:24:00 -04:00 committed by NepDisk
parent b0f8492c94
commit 699153fd52

View file

@ -979,6 +979,8 @@ static boolean CL_SendJoin(void)
CONS_Printf(M_GetText("Sending join request...\n"));
netbuffer->packettype = PT_CLIENTJOIN;
neededtic = 0;
if (splitscreen)
localplayers += splitscreen;
@ -5560,7 +5562,7 @@ static void PT_ServerTics(SINT8 node, INT32 netconsole)
{
doomdata_t *netbuffer = DOOMCOM_DATA(doomcom);
UINT8 *pak, *txtpak, numtxtpak;
UINT8 numtxtpak;
tic_t realend, realstart;
if (!nodeingame[node])
@ -5586,57 +5588,46 @@ static void PT_ServerTics(SINT8 node, INT32 netconsole)
realstart = ExpandTics(netbuffer->u.serverpak.starttic, maketic);
realend = realstart + netbuffer->u.serverpak.numtics;
txtpak = (UINT8 *)&netbuffer->u.serverpak.cmds[netbuffer->u.serverpak.numslots
* netbuffer->u.serverpak.numtics];
if (realend > gametic + CLIENTBACKUPTICS)
realend = gametic + CLIENTBACKUPTICS;
cl_packetmissed = realstart > neededtic;
if (realstart <= neededtic && realend > neededtic)
{
tic_t i, j;
pak = (UINT8 *)&netbuffer->u.serverpak.cmds;
// NOTE: we just blindly accept what we get, since it's impossible for the client to know which tic the server is on
UINT8 *pak = (UINT8 *)&netbuffer->u.serverpak.cmds;
UINT8 *txtpak = (UINT8 *)&netbuffer->u.serverpak.cmds[netbuffer->u.serverpak.numslots
* netbuffer->u.serverpak.numtics];
for (i = realstart; i < realend; i++)
for (tic_t i = realstart; i < realend; i++)
{
// clear first
D_Clearticcmd(i);
// copy the tics
pak = G_ScpyTiccmd(netcmds[i%BACKUPTICS], pak,
netbuffer->u.serverpak.numslots*sizeof (ticcmd_t));
// copy the textcmds
numtxtpak = *txtpak++;
for (tic_t j = 0; j < numtxtpak; j++)
{
// clear first
D_Clearticcmd(i);
INT32 playernum = *txtpak++; // playernum
const size_t txtsize = txtpak[0]+1;
// copy the tics
pak = G_ScpyTiccmd(netcmds[i%BACKUPTICS], pak,
netbuffer->u.serverpak.numslots*sizeof (ticcmd_t));
// copy the textcmds
numtxtpak = *txtpak++;
for (j = 0; j < numtxtpak; j++)
if (playernum < 0 || playernum >= MAXPLAYERS)
{
INT32 playernum = *txtpak++; // playernum
const size_t txtsize = txtpak[0]+1;
if (playernum < 0 || playernum >= MAXPLAYERS)
{
CONS_Alert(CONS_WARNING, "Got bogus NetXCmd packet targetting player %d\n", playernum);
return;
}
if (i >= gametic) // Don't copy old net commands
memcpy(D_GetTextcmd(i, playernum), txtpak, txtsize);
txtpak += txtsize;
CONS_Alert(CONS_WARNING, "Got bogus NetXCmd packet targetting player %d\n", playernum);
return;
}
}
neededtic = realend;
}
else
{
DEBFILE(va("frame not in bound: %u\n", neededtic));
/*if (realend < neededtic - 2 * TICRATE || neededtic + 2 * TICRATE < realstart)
* I_Error("Received an out of order PT_SERVERTICS packet!\n"
* "Got tics %d-%d, needed tic %d\n\n"
* "Please report this crash on the Master Board,\n"
* "IRC or Discord so it can be fixed.\n", (INT32)realstart, (INT32)realend, (INT32)neededtic);*/
if (i >= gametic) // Don't copy old net commands
memcpy(D_GetTextcmd(i, playernum), txtpak, txtsize);
txtpak += txtsize;
}
}
neededtic = realend;
}
static void PT_Ping(SINT8 node, INT32 netconsole)