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
This commit is contained in:
Monster Iestyn 2018-01-16 15:21:49 +00:00
parent f1b8e122a2
commit 0ef7aff5c0

View file

@ -4445,6 +4445,7 @@ static void Local_Maketic(INT32 realtics)
void SV_SpawnPlayer(INT32 playernum, INT32 x, INT32 y, angle_t angle) void SV_SpawnPlayer(INT32 playernum, INT32 x, INT32 y, angle_t angle)
{ {
tic_t tic; tic_t tic;
UINT8 numadjust = 0;
(void)x; (void)x;
(void)y; (void)y;
@ -4454,7 +4455,21 @@ void SV_SpawnPlayer(INT32 playernum, INT32 x, INT32 y, angle_t angle)
// spawning, but will be applied afterwards. // spawning, but will be applied afterwards.
for (tic = server ? maketic : (neededtic - 1); tic >= gametic; tic--) 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); 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 // create missed tic