From 5561928ad478af5f1002f10b06b5007a99043f52 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 25 Apr 2024 17:45:33 -0700 Subject: [PATCH] Tutorial Skip: clear bots so Eggman bot does not carry over from Tutorial --- src/k_bot.cpp | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/k_bot.cpp b/src/k_bot.cpp index ad4619dd7..48ac1557b 100644 --- a/src/k_bot.cpp +++ b/src/k_bot.cpp @@ -319,6 +319,27 @@ void K_UpdateMatchRaceBots(void) } } + auto clear_bots = [&numbots](UINT8 max) + { + UINT8 i = MAXPLAYERS; + while (numbots > max && i > 0) + { + i--; + + if (playeringame[i] && players[i].bot) + { + CL_RemovePlayer(i, KR_LEAVE); + numbots--; + } + } + }; + + if (tutorialchallenge == TUTORIALSKIP_INPROGRESS) + { + // Prevent Eggman bot carrying over from Tutorial + clear_bots(0); + } + if (numbots < wantedbots) { // We require MORE bots! @@ -372,17 +393,7 @@ void K_UpdateMatchRaceBots(void) } else if (numbots > wantedbots) { - i = MAXPLAYERS; - while (numbots > wantedbots && i > 0) - { - i--; - - if (playeringame[i] && players[i].bot) - { - CL_RemovePlayer(i, KR_LEAVE); - numbots--; - } - } + clear_bots(wantedbots); } // We should have enough bots now :)