From dc1f1d71b17b0ce9db97fea350ef9b1564059b15 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sun, 1 Jan 2023 00:42:19 +1000 Subject: [PATCH] Don't wait for bot death anims before ending MP match --- src/game/lv.c | 77 +++++++++++++++++++++--------------- src/game/mplayer/mplayer.c | 2 +- src/game/mplayer/scenarios.c | 2 +- src/game/player.c | 2 +- src/include/data.h | 2 +- 5 files changed, 50 insertions(+), 35 deletions(-) diff --git a/src/game/lv.c b/src/game/lv.c index 765a235fe..1138f4cb5 100644 --- a/src/game/lv.c +++ b/src/game/lv.c @@ -105,7 +105,7 @@ s32 g_MpTimeLimit60 = SECSTOTIME60(60 * 10); // 10 minutes s32 g_MpScoreLimit = 10; s32 g_MpTeamScoreLimit = 20; struct sndstate *g_MiscAudioHandle = NULL; -s32 g_NumReasonsToEndMpMatch = 0; +s32 g_MpMatchIsEnding = 0; f32 g_StageTimeElapsed1f = 0; bool var80084040 = true; @@ -123,6 +123,8 @@ u32 g_FadePrevColour = 0; u32 g_FadeColour = 0; s16 g_FadeDelay = 0; +s32 g_MpEndTimer; + u32 getVar80084040(void) { return var80084040; @@ -420,6 +422,9 @@ void lvReset(s32 stagenum) var80084018 = 1; lvSetPaused(0); + g_MpMatchIsEnding = false; + g_MpEndTimer = -1; + #if PIRACYCHECKS { u32 checksum = 0; @@ -1703,8 +1708,6 @@ void lvTick(void) bgunTickBoost(); hudmsgsTick(); - g_NumReasonsToEndMpMatch = 0; - // Handle MP match ending if (g_Vars.normmplayerisrunning && g_Vars.stagenum < STAGE_TITLE) { if (g_MpTimeLimit60 > 0) { @@ -1737,46 +1740,58 @@ void lvTick(void) } if (g_Vars.lvupdate240 != 0) { - s32 numdying = 0; + if (!g_MpMatchIsEnding) { + // Check for match ending conditions + if (g_MpScoreLimit > 0) { + s32 count = mpGetPlayerRankings(g_MpRankings); - for (i = 0; i < PLAYERCOUNT(); i++) { - if (g_Vars.players[i]->isdead) { - if (g_Vars.players[i]->redbloodfinished == false - || g_Vars.players[i]->deathanimfinished == false - || g_Vars.players[i]->colourfadetimemax60 >= 0) { - numdying++; + for (i = 0; i < count; i++) { + if (g_MpRankings[i].score >= g_MpScoreLimit) { + g_MpMatchIsEnding = true; + break; + } } } - } - for (i = 0; i < g_MpNumChrs; i++) { - if (g_MpChrs[i].chr->actiontype == ACT_DIE) { - numdying++; - } - } + if (!g_MpMatchIsEnding && (g_MpSetup.options & MPOPTION_TEAMSENABLED) && g_MpTeamScoreLimit > 0) { + s32 count = mpGetTeamRankings(g_MpRankings); - if (g_MpScoreLimit > 0) { - s32 count = mpGetPlayerRankings(g_MpRankings); - - for (i = 0; i < count; i++) { - if (g_MpRankings[i].score >= g_MpScoreLimit) { - g_NumReasonsToEndMpMatch++; + for (i = 0; i < count; i++) { + if (g_MpRankings[i].score >= g_MpTeamScoreLimit) { + g_MpMatchIsEnding = true; + break; + } } } - } - if (g_MpTeamScoreLimit > 0) { - s32 count = mpGetTeamRankings(g_MpRankings); + if (g_MpMatchIsEnding) { + g_MpEndTimer = TICKS(240 * 4); + } + } else { + // If a player is dying then the match end timer will be ignored + // and the match will end once the death animation has finished. + bool playerdying = false; - for (i = 0; i < count; i++) { - if (g_MpRankings[i].score >= g_MpTeamScoreLimit) { - g_NumReasonsToEndMpMatch++; + for (i = 0; i < PLAYERCOUNT(); i++) { + if (g_Vars.players[i]->isdead) { + if (g_Vars.players[i]->redbloodfinished == false + || g_Vars.players[i]->deathanimfinished == false + || g_Vars.players[i]->colourfadetimemax60 >= 0) { + playerdying = true; + break; + } } } - } - if (g_NumReasonsToEndMpMatch > 0 && numdying == 0) { - mainEndStage(); + if (playerdying) { + g_MpEndTimer = -1; + } else { + g_MpEndTimer -= g_Vars.lvupdate240; + } + + if (g_MpEndTimer <= 0 && !playerdying) { + mainEndStage(); + } } } } diff --git a/src/game/mplayer/mplayer.c b/src/game/mplayer/mplayer.c index 1eee225f8..dbe6abbf1 100644 --- a/src/game/mplayer/mplayer.c +++ b/src/game/mplayer/mplayer.c @@ -1178,7 +1178,7 @@ Gfx *mpRenderModalText(Gfx *gdl) && g_Vars.currentplayer->isdead && g_Vars.currentplayer->redbloodfinished && g_Vars.currentplayer->deathanimfinished - && g_NumReasonsToEndMpMatch == 0) { + && g_MpMatchIsEnding == 0) { // Render "Press START" text gdl = text0f153628(gdl); diff --git a/src/game/mplayer/scenarios.c b/src/game/mplayer/scenarios.c index ef04593ad..5726e2f00 100644 --- a/src/game/mplayer/scenarios.c +++ b/src/game/mplayer/scenarios.c @@ -586,7 +586,7 @@ Gfx *scenarioRenderHud(Gfx *gdl) if (g_Vars.normmplayerisrunning) { if (g_MpScenarios[g_MpSetup.scenario].hudfunc) { #if VERSION >= VERSION_NTSC_1_0 - if (g_MpSetup.paused != MPPAUSEMODE_GAMEOVER && g_NumReasonsToEndMpMatch == 0) { + if (g_MpSetup.paused != MPPAUSEMODE_GAMEOVER && g_MpMatchIsEnding == 0) { gDPSetTextureFilter(gdl++, G_TF_POINT); gDPSetColorDither(gdl++, G_CD_DISABLE); gSPClearGeometryMode(gdl++, G_ZBUFFER); diff --git a/src/game/player.c b/src/game/player.c index 5405d28c9..40fdf3334 100644 --- a/src/game/player.c +++ b/src/game/player.c @@ -3426,7 +3426,7 @@ Gfx *playerRenderHud(Gfx *gdl) if (joyGetButtons(optionsGetContpadNum1(g_Vars.currentplayerstats->mpindex), 0xb000) && !mpIsPaused() - && g_NumReasonsToEndMpMatch == 0) { + && g_MpMatchIsEnding == 0) { canrestart = true; } diff --git a/src/include/data.h b/src/include/data.h index 99e144736..46bbdf2e9 100644 --- a/src/include/data.h +++ b/src/include/data.h @@ -435,7 +435,7 @@ extern f32 var8007fcb4; extern struct stagetableentry g_Stages[61]; extern s32 var80082050; extern u32 g_GfxNumSwaps; -extern s32 g_NumReasonsToEndMpMatch; +extern s32 g_MpMatchIsEnding; extern s32 g_MusicEventQueueLength; extern bool g_MusicNrgIsActive; extern s32 var800840e0;