From 699153fd5213035c38a3ff3e18d8947d1c01991e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustaf=20Alh=C3=A4ll?= Date: Fri, 24 Apr 2026 20:24:00 -0400 Subject: [PATCH] Always accept tics received from the server --- src/d_clisrv.c | 71 ++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 40 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 33802170e..82cb904cb 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -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)