From 7608055679514c62ecc4f2ff4994adbd0da95494 Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Sat, 24 Nov 2018 20:59:22 -0500 Subject: [PATCH] More in-depth countdown calculation Hooooopefully this makes sure time over doesn't happen prematurely at random --- src/p_inter.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/src/p_inter.c b/src/p_inter.c index baae2701..f75bd4d0 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -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; }