From 841827480b658b389d21398f6c7fdbfd3ba35089 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 22 Jan 2024 17:51:31 -0800 Subject: [PATCH] Add K_EndBattleRound, end the round and give a player 100 points if they won --- src/k_battle.c | 41 ++++++++++++++++++++++++++++------------- src/k_battle.h | 1 + src/k_kart.c | 3 +-- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/src/k_battle.c b/src/k_battle.c index 21f4961bb..d08fcee2c 100644 --- a/src/k_battle.c +++ b/src/k_battle.c @@ -173,14 +173,9 @@ void K_CheckBumpers(void) } else if (eliminated >= numingame - 1) { - if (kingofthehill != -1) - { - // If every other player is eliminated, the - // last player standing wins by default. - players[kingofthehill].roundscore = 100; - } - - P_DoAllPlayersExit(0, false); + // If every other player is eliminated, the + // last player standing wins by default. + K_EndBattleRound(kingofthehill != -1 ? &players[kingofthehill] : NULL); return; } @@ -209,15 +204,11 @@ void K_CheckEmeralds(player_t *player) return; } - if (player->exiting) + if (!K_EndBattleRound(player)) { return; } - player->roundscore = 100; // lmao - - P_DoAllPlayersExit(0, false); - // TODO: this would be better if the timing lived in // Tally code. But I didn't do it that, so this just // shittily approximates syncing up with Tally. @@ -969,3 +960,27 @@ boolean K_BattleOvertimeKiller(mobj_t *mobj) return true; } + +boolean K_EndBattleRound(player_t *victor) +{ + if (victor) + { + if (victor->exiting) + { + // In Battle, players always exit altogether. + // So it can be assumed that if this player is + // exiting, the round has already ended. + return false; + } + + if (gametyperules & GTR_POINTLIMIT) + { + // Lock the winner in before the round ends. + victor->roundscore = 100; + } + } + + P_DoAllPlayersExit(0, false); + + return true; +} diff --git a/src/k_battle.h b/src/k_battle.h index bc894c150..f1310e4d1 100644 --- a/src/k_battle.h +++ b/src/k_battle.h @@ -53,6 +53,7 @@ void K_BattleInit(boolean singleplayercontext); UINT8 K_Bumpers(player_t *player); INT32 K_BumpersToHealth(UINT8 bumpers); boolean K_BattleOvertimeKiller(mobj_t *mobj); +boolean K_EndBattleRound(player_t *victor); #ifdef __cplusplus } // extern "C" diff --git a/src/k_kart.c b/src/k_kart.c index 86b15c5a9..8a7c32c13 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3929,8 +3929,7 @@ void K_BattleAwardHit(player_t *player, player_t *victim, mobj_t *inflictor, UIN // Check this before adding to player score if ((gametyperules & GTR_BUMPERS) && finishOff && g_pointlimit <= player->roundscore) { - player->roundscore = 100; // Make sure you win! - P_DoAllPlayersExit(0, false); + K_EndBattleRound(player); mobj_t *source = !P_MobjWasRemoved(inflictor) ? inflictor : player->mo;