From 4f1a49c0fb76ba7219ba0e6a945577651e8c16d1 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Mon, 2 Sep 2024 21:52:46 -0700 Subject: [PATCH] WIP: Duel infinite laps in circuit --- src/doomstat.h | 1 + src/g_game.c | 1 + src/k_hud.cpp | 10 +++++++--- src/k_kart.c | 3 ++- src/p_saveg.c | 2 ++ src/p_spec.c | 5 +++++ 6 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/doomstat.h b/src/doomstat.h index b880a4c22..628ff22be 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -868,6 +868,7 @@ extern SINT8 spbplace; extern boolean rainbowstartavailable; extern tic_t linecrossed; extern boolean inDuel; +extern UINT8 extralaps; extern tic_t bombflashtimer; // Used to avoid causing seizures if multiple mines explode close to you :) extern boolean legitimateexit; diff --git a/src/g_game.c b/src/g_game.c index 0158f6e6b..56991ea59 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -319,6 +319,7 @@ SINT8 spbplace; // SPB exists, give the person behind better items boolean rainbowstartavailable; // Boolean, keeps track of if the rainbow start was gotten tic_t linecrossed; // For Time Attack boolean inDuel; // Boolean, keeps track of if it is a 1v1 +UINT8 extralaps; // Duel extensions! // Client-sided, unsynched variables (NEVER use in anything that needs to be synced with other players) tic_t bombflashtimer = 0; // Cooldown before another FlashPal can be intialized by a bomb exploding near a displayplayer. Avoids seizures. diff --git a/src/k_hud.cpp b/src/k_hud.cpp index 1c8ece97a..8918e3233 100644 --- a/src/k_hud.cpp +++ b/src/k_hud.cpp @@ -2999,11 +2999,15 @@ static void K_drawKartLaps(void) if (inDuel) { - UINT8 flashflag = (leveltime % 2 && abs(stplyr->duelscore >= 2)) ? V_TRANSLUCENT : 0; + UINT32 flashflag = (stplyr->duelscore >= 0) ? V_BLUEMAP : V_REDMAP; + if (leveltime % 2) + if (abs(stplyr->duelscore) >= 2) + flashflag = V_YELLOWMAP; + if (stplyr->duelscore >= 0) - V_DrawCenteredString(BASEVIDWIDTH/2, 5, V_BLUEMAP|flashflag, va("+%d", stplyr->duelscore)); + V_DrawCenteredString(BASEVIDWIDTH/2, 5, flashflag, va("+%d", stplyr->duelscore)); else - V_DrawCenteredString(BASEVIDWIDTH/2, 5, V_REDMAP|flashflag, va("%d", stplyr->duelscore)); + V_DrawCenteredString(BASEVIDWIDTH/2, 5, flashflag, va("%d", stplyr->duelscore)); } if (numlaps != 1) diff --git a/src/k_kart.c b/src/k_kart.c index f3b2a672c..1fa198003 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -145,6 +145,7 @@ void K_TimerReset(void) numbulbs = 1; inDuel = rainbowstartavailable = false; linecrossed = 0; + extralaps = 0; timelimitintics = extratimeintics = secretextratime = 0; g_pointlimit = 0; } @@ -10684,7 +10685,7 @@ static void K_UpdateDistanceFromFinishLine(player_t *const player) const mapheader_t *mapheader = mapheaderinfo[gamemap - 1]; if ((mapheader->levelflags & LF_SECTIONRACE) == 0U) { - const UINT8 numfulllapsleft = ((UINT8)numlaps - player->laps) / mapheader->lapspersection; + const UINT8 numfulllapsleft = ((UINT8)numlaps - player->laps) / mapheader->lapspersection + extralaps; player->distancetofinish += numfulllapsleft * K_GetCircuitLength(); } } diff --git a/src/p_saveg.c b/src/p_saveg.c index 4a697e3eb..1b697bd66 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -6679,6 +6679,7 @@ static void P_NetArchiveMisc(savebuffer_t *save, boolean resending) WRITESINT8(save->p, spbplace); WRITEUINT8(save->p, rainbowstartavailable); WRITEUINT8(save->p, inDuel); + WRITEUINT8(save->p, extralaps); WRITEUINT32(save->p, introtime); WRITEUINT32(save->p, starttime); @@ -6884,6 +6885,7 @@ static boolean P_NetUnArchiveMisc(savebuffer_t *save, boolean reloading) spbplace = READSINT8(save->p); rainbowstartavailable = (boolean)READUINT8(save->p); inDuel = (boolean)READUINT8(save->p); + extralaps = (boolean)READUINT8(save->p); introtime = READUINT32(save->p); starttime = READUINT32(save->p); diff --git a/src/p_spec.c b/src/p_spec.c index bd1bcd579..875d08072 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1993,6 +1993,11 @@ static void K_HandleLapIncrement(player_t *player) boolean specialduelexit = (inDuel && !(mapheaderinfo[gamemap-1]->levelflags & LF_SECTIONRACE)); + if (specialduelexit) + { + extralaps += 1; + } + // finished race exit setup if (player->laps > numlaps && !specialduelexit) {