From 0ef7aff5c0a847a46147ef525695c4361f12e8ac Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 16 Jan 2018 15:21:49 +0000 Subject: [PATCH] Prevent SV_SpawnPlayer from being able to freeze the game if gametic is 0. Additionally add a sanity check to prevent the loop going on more than necessary anyway This commit fixes -playdemo and -timedemo params for command line, allowing them to actually work again --- src/d_clisrv.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index d48f223c7..378b23f95 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4445,6 +4445,7 @@ static void Local_Maketic(INT32 realtics) void SV_SpawnPlayer(INT32 playernum, INT32 x, INT32 y, angle_t angle) { tic_t tic; + UINT8 numadjust = 0; (void)x; (void)y; @@ -4454,7 +4455,21 @@ void SV_SpawnPlayer(INT32 playernum, INT32 x, INT32 y, angle_t angle) // spawning, but will be applied afterwards. for (tic = server ? maketic : (neededtic - 1); tic >= gametic; tic--) + { + if (numadjust++ == BACKUPTICS) + { + DEBFILE(va("SV_SpawnPlayer: All netcmds for player %d adjusted!\n", playernum)); + // We already adjusted them all, waste of time doing the same thing over and over + // This shouldn't happen normally though, either gametic was 0 (which is handled now anyway) + // or maketic >= gametic + BACKUPTICS + // -- Monster Iestyn 16/01/18 + break; + } netcmds[tic%BACKUPTICS][playernum].angleturn = (INT16)((angle>>16) | TICCMD_RECEIVED); + + if (!tic) // failsafe for gametic == 0 -- Monster Iestyn 16/01/18 + break; + } } // create missed tic