More in-depth countdown calculation

Hooooopefully this makes sure time over doesn't happen prematurely at random
This commit is contained in:
TehRealSalt 2018-11-24 20:59:22 -05:00
parent 7dcc55951b
commit 7608055679

View file

@ -2003,19 +2003,6 @@ boolean P_CheckRacers(void)
countdown = countdown2 = 0;
return true;
}
else if (!countdown) // Check to see if the winners have finished, to set countdown.
{
for (i = 0; i < MAXPLAYERS; i++)
{
if (!playeringame[i] || players[i].spectator)
continue;
if (players[i].exiting || K_IsPlayerLosing(&players[i])) // Only start countdown when all winners are declared
continue;
break;
}
if (i == MAXPLAYERS)
countdown = (((netgame || multiplayer) ? cv_countdowntime.value : 30)*TICRATE) + 1; // 30 seconds to finish, get going!
}
if (cv_karteliminatelast.value)
{
@ -2046,6 +2033,28 @@ boolean P_CheckRacers(void)
}
}
if (!countdown) // Check to see if the winners have finished, to set countdown.
{
UINT8 numingame = 0, numexiting = 0;
UINT8 winningpos = 1;
for (i = 0; i < MAXPLAYERS; i++)
{
if (!playeringame[i] || players[i].spectator)
continue;
numingame++;
if (players[i].exiting)
numexiting++;
}
winningpos = max(1, numingame/2);
if (numingame % 2) // any remainder?
winningpos++;
if (numexiting >= winningpos)
countdown = (((netgame || multiplayer) ? cv_countdowntime.value : 30)*TICRATE) + 1; // 30 seconds to finish, get going!
}
return false;
}