From 7e9710e81ab38d63edc5315f7b09ffbabf818bb3 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Mon, 9 Sep 2024 02:09:30 -0700 Subject: [PATCH] WIP --- src/k_kart.c | 31 ++++++++++++++++++++++--------- src/p_spec.c | 6 ++---- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 727b0cca7..217a2aae9 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -297,7 +297,7 @@ void K_TimerInit(void) } if (K_InRaceDuel()) - numlaps = 200; + numlaps = 1; } } @@ -10764,15 +10764,28 @@ static void K_UpdateDistanceFromFinishLine(player_t *const player) } Z_Free(pathtofinish.array); - // distancetofinish is currently a flat distance to the finish line, but in order to be fully - // correct we need to add to it the length of the entire circuit multiplied by the number of laps - // left after this one. This will give us the total distance to the finish line, and allow item - // distance calculation to work easily - const mapheader_t *mapheader = mapheaderinfo[gamemap - 1]; - if ((mapheader->levelflags & LF_SECTIONRACE) == 0U) + if (K_InRaceDuel() && player->position == 1) { - const UINT8 numfulllapsleft = ((UINT8)numlaps - player->laps) / mapheader->lapspersection; - player->distancetofinish += numfulllapsleft * K_GetCircuitLength(); + // As far as we're concerned, the race starts and ends with our position. + // Don't care about laps at all! + } + else + { + // distancetofinish is currently a flat distance to the finish line, but in order to be fully + // correct we need to add to it the length of the entire circuit multiplied by the number of laps + // left after this one. This will give us the total distance to the finish line, and allow item + // distance calculation to work easily + const mapheader_t *mapheader = mapheaderinfo[gamemap - 1]; + if ((mapheader->levelflags & LF_SECTIONRACE) == 0U) + { + UINT8 numfulllapsleft = ((UINT8)numlaps - player->laps) / mapheader->lapspersection; + if (K_InRaceDuel()) + { + player_t *opp = K_DuelOpponent(player); + numfulllapsleft = opp->laps - player->laps; + } + player->distancetofinish += numfulllapsleft * K_GetCircuitLength(); + } } } } diff --git a/src/p_spec.c b/src/p_spec.c index 0712f049f..f9091c145 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1992,10 +1992,8 @@ static void K_HandleLapIncrement(player_t *player) player->latestlap = player->laps; } - boolean specialduelexit = (inDuel && !(mapheaderinfo[gamemap-1]->levelflags & LF_SECTIONRACE)); - // finished race exit setup - if (player->laps > numlaps && !specialduelexit) + if (player->laps > numlaps && !K_InRaceDuel()) { pflags_t applyflags = 0; if (specialstageinfo.valid == true) @@ -2021,7 +2019,7 @@ static void K_HandleLapIncrement(player_t *player) : skins[player->skin].flags; if (skinflags & SF_IRONMAN) { - if (!K_InRaceDuel()) // We'll do this in K_CheckpointCrossAward if necessary. + if ((player->laps == 1 && lapisfresh) || !K_InRaceDuel()) // We'll do this in K_CheckpointCrossAward if necessary. SetRandomFakePlayerSkin(player, true, false); }