From 01227814b93b6dd8415c4d32c403a4b21800cce5 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 23 Feb 2023 19:55:43 -0800 Subject: [PATCH] Refactor Battle points cap to use g_pointlimit Fixes players leaving mid-game lowering the point limit and instantly ending the match. see 94c811b55 --- src/k_battle.c | 17 ----------------- src/k_kart.c | 26 +++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/k_battle.c b/src/k_battle.c index c16158e80..b34c7a151 100644 --- a/src/k_battle.c +++ b/src/k_battle.c @@ -140,11 +140,6 @@ void K_CheckBumpers(void) else { g_hiscore = toproundscore; - - if (toproundscore < (numingame * 3)) - { - return; - } } if (numingame <= 1) @@ -158,18 +153,6 @@ void K_CheckBumpers(void) return; } - - for (i = 0; i < MAXPLAYERS; i++) // This can't go in the earlier loop because winning adds points - K_KartUpdatePosition(&players[i]); - - for (i = 0; i < MAXPLAYERS; i++) // and it can't be merged with this loop because it needs to be all updated before exiting... multi-loops suck... - { - if (!playeringame[i]) - continue; - if (players[i].spectator) - continue; - P_DoPlayerExit(&players[i]); - } } void K_CheckEmeralds(player_t *player) diff --git a/src/k_kart.c b/src/k_kart.c index 644e1035e..7612a9ef5 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -11350,6 +11350,9 @@ tic_t K_TimeLimitForGametype(void) UINT32 K_PointLimitForGametype(void) { const UINT32 gametypeDefault = gametypes[gametype]->pointlimit; + const UINT32 battleRules = GTR_BUMPERS|GTR_CLOSERPLAYERS|GTR_PAPERITEMS; + + UINT32 ptsCap = gametypeDefault; if (!(gametyperules & GTR_POINTLIMIT)) { @@ -11361,7 +11364,28 @@ UINT32 K_PointLimitForGametype(void) return cv_pointlimit.value; } - return gametypeDefault; + if (battlecapsules || bossinfo.valid) + { + return 0; + } + + if ((gametyperules & battleRules) == battleRules) + { + INT32 i; + + // It's frustrating that this shitty for-loop needs to + // be duplicated every time the players need to be + // counted. + for (i = 0; i < MAXPLAYERS; ++i) + { + if (D_IsPlayerHumanAndGaming(i)) + { + ptsCap += 3; + } + } + } + + return ptsCap; } //}