diff --git a/src/d_player.h b/src/d_player.h index 1bc481388..44d0e59e3 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -514,6 +514,7 @@ typedef struct player_s tic_t realtime; // integer replacement for leveltime UINT8 laps; // Number of laps (optional) UINT8 latestlap; + boolean lapvalidation; // A hack to prevent lap 1 (0) from incrementing the lap count on waypoint only maps // Starpost information INT16 starpostx; diff --git a/src/g_game.c b/src/g_game.c index e12e58691..c295e1e97 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2217,6 +2217,7 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps) INT16 totalring; UINT8 laps; UINT8 latestlap; + boolean lapvalidation; UINT16 skincolor; INT32 skin; UINT32 availabilities; @@ -2307,6 +2308,7 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps) nocontrol = 0; laps = 0; latestlap = 0; + lapvalidation = false; roundscore = 0; exiting = 0; khudcardanimation = 0; @@ -2353,6 +2355,7 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps) laps = players[player].laps; latestlap = players[player].latestlap; + lapvalidation = players[player].lapvalidation; roundscore = players[player].roundscore; @@ -2433,6 +2436,7 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps) p->laps = laps; p->latestlap = latestlap; + p->lapvalidation = lapvalidation; p->totalring = totalring; p->bot = bot; diff --git a/src/k_hud.c b/src/k_hud.c index ab1e331a5..31f28aff3 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -2214,7 +2214,7 @@ void K_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, IN else if (players[tab[i].num].pflags & PF_NOCONTEST) V_DrawRightAlignedThinString(x+rightoffset, y-1, V_6WIDTHSPACE, "NO CONTEST."); else if (circuitmap) - V_DrawRightAlignedThinString(x+rightoffset, y-1, V_6WIDTHSPACE, va("Lap %d", tab[i].count)); + V_DrawRightAlignedThinString(x+rightoffset, y-1, V_6WIDTHSPACE, va("Lap %d", tab[i].count+1)); } else { @@ -2223,7 +2223,7 @@ void K_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, IN else if (players[tab[i].num].pflags & PF_NOCONTEST) V_DrawRightAlignedThinString(x+rightoffset, y-1, 0, "NO CONTEST."); else if (circuitmap) - V_DrawRightAlignedString(x+rightoffset, y, 0, va("Lap %d", tab[i].count)); + V_DrawRightAlignedString(x+rightoffset, y, 0, va("Lap %d", tab[i].count+1)); } #undef timestring } @@ -2371,7 +2371,7 @@ static void K_drawKartLapsAndRings(void) { // Laps V_DrawScaledPatch(LAPS_X, LAPS_Y, V_HUDTRANS|splitflags, kp_lapsticker); - V_DrawKartString(LAPS_X+33, LAPS_Y+3, V_HUDTRANS|splitflags, va("%d/%d", min(stplyr->laps, numlaps), numlaps)); + V_DrawKartString(LAPS_X+33, LAPS_Y+3, V_HUDTRANS|splitflags, va("%d/%d", min(stplyr->laps+1, numlaps), numlaps)); if (!ringsdisabled) { @@ -4198,7 +4198,7 @@ static void K_drawLapStartAnim(void) kp_lapanim_hand[stplyr->karthud[khud_laphand]-1], NULL); } - if (stplyr->laps == (UINT8)(numlaps)) + if (stplyr->laps == (UINT8)(numlaps-1)) { newval = (62 - (32 * max(0, progress - 76))) * FRACUNIT; oldval = (62 - (32 * max(0, progressOld - 76))) * FRACUNIT; @@ -4245,7 +4245,7 @@ static void K_drawLapStartAnim(void) interpx, // 194 30*FRACUNIT, // 24 FRACUNIT, V_SNAPTOTOP|V_HUDTRANS, - kp_lapanim_number[(((UINT32)stplyr->laps) / 10)][min(progress/2-8, 2)], NULL); + kp_lapanim_number[(((UINT32)stplyr->laps+1) / 10)][min(progress/2-8, 2)], NULL); if (progress/2-10 >= 0) { @@ -4257,7 +4257,7 @@ static void K_drawLapStartAnim(void) interpx, // 221 30*FRACUNIT, // 24 FRACUNIT, V_SNAPTOTOP|V_HUDTRANS, - kp_lapanim_number[(((UINT32)stplyr->laps) % 10)][min(progress/2-10, 2)], NULL); + kp_lapanim_number[(((UINT32)stplyr->laps+1) % 10)][min(progress/2-10, 2)], NULL); } } } diff --git a/src/k_kart.c b/src/k_kart.c index c20ddc03c..8f1bda7a4 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -6730,10 +6730,6 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) } player->superring--; } - - // Start at lap 1 when using old checkpoint system just to be safe. - if ((numbosswaypoints > 0) && (player->laps == 0) && (numlaps > 0)) - player->laps = 1; if (player->stealingtimer == 0 && player->stolentimer == 0 && player->rocketsneakertimer) diff --git a/src/p_saveg.c b/src/p_saveg.c index a7cfcee76..260899a93 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -166,6 +166,7 @@ static void P_NetArchivePlayers(void) WRITEUINT32(save_p, players[i].realtime); WRITEUINT8(save_p, players[i].laps); WRITEUINT8(save_p, players[i].latestlap); + WRITEUINT8(save_p, players[i].lapvalidation); WRITEUINT32(save_p, players[i].starposttime); WRITEINT16(save_p, players[i].starpostx); @@ -460,6 +461,7 @@ static void P_NetUnArchivePlayers(void) players[i].realtime = READUINT32(save_p); // integer replacement for leveltime players[i].laps = READUINT8(save_p); // Number of laps (optional) players[i].latestlap = READUINT8(save_p); + players[i].lapvalidation = READUINT8(save_p); players[i].starposttime = READUINT32(save_p); players[i].starpostx = READINT16(save_p); diff --git a/src/p_spec.c b/src/p_spec.c index f6f740e44..3d7c9fa3c 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1885,11 +1885,16 @@ void P_SwitchWeather(preciptype_t newWeather) } // Passed over the finish line forwards -static void K_HandleLapIncrement(player_t *player) +static void K_HandleLapIncrement(player_t *player, boolean fromsector) { if (player) { - if (((numbosswaypoints > 0) ? (player->starpostnum >= (numstarposts - (numstarposts/2))) : (player->starpostnum == numstarposts)) || (player->laps == 0)) + if (fromsector == true || numstarposts > 0) // These already handle their own form of lapvalidation + { + player->lapvalidation = true; + } + + if (((numbosswaypoints > 0) ? (player->starpostnum >= (numstarposts - (numstarposts/2))) : (player->starpostnum == numstarposts))) { size_t i = 0; UINT8 nump = 0; @@ -1922,11 +1927,18 @@ static void K_HandleLapIncrement(player_t *player) player->starpostangle = player->starpostx = player->starposty = player->starpostz = player->starpostflip = 0; } - player->laps++; + if (player->lapvalidation == false) + { + player->lapvalidation = true; + } + else + { + player->laps++; + } K_UpdateAllPlayerPositions(); // Set up lap animation vars - if (player->laps > 1) + if (player->laps > 0) { if (nump > 1) { @@ -1951,11 +1963,11 @@ static void K_HandleLapIncrement(player_t *player) if (P_IsDisplayPlayer(player)) { - if (player->laps == numlaps) // final lap + if (player->laps == numlaps-1) // final lap S_StartSound(NULL, sfx_s3k68); - else if ((player->laps > 1) && (player->laps < numlaps)) // non-final lap + else if ((player->laps > 0) && (player->laps < numlaps-1)) // non-final lap S_StartSound(NULL, sfx_s221); - else if (player->laps > numlaps) + else if (player->laps >= numlaps) { // finished S_StartSound(NULL, sfx_s3k6a); @@ -1972,7 +1984,7 @@ static void K_HandleLapIncrement(player_t *player) } // finished race exit setup - if (player->laps > numlaps) + if (player->laps >= numlaps) { P_DoPlayerExit(player); P_SetupSignExit(player); @@ -1980,7 +1992,7 @@ static void K_HandleLapIncrement(player_t *player) if (player->laps > player->latestlap) { - if (player->laps > 1) + if (player->laps > 0) { // save best lap for record attack if (modeattacking && player == &players[consoleplayer]) @@ -2000,53 +2012,57 @@ static void K_HandleLapIncrement(player_t *player) player->latestlap = player->laps; } - thwompsactive = true; // Lap 2 effects - player->grieftime = 0; - - lowestLap = P_FindLowestLap(); - - for (i = 0; i < numlines; i++) + if (player->laps > 0) { - if (lines[i].special == 2002) // Race lap trigger + thwompsactive = true; // Lap 2 effects + player->grieftime = 0; + + + lowestLap = P_FindLowestLap(); + + for (i = 0; i < numlines; i++) { - UINT8 lap; - - if (lines[i].flags & ML_MIDSOLID) + if (lines[i].special == 2002) // Race lap trigger { - lap = player->laps; - } - else - { - lap = lowestLap; + UINT8 lap; - if (lap <= lastLowestLap) + if (lines[i].flags & ML_MIDSOLID) { - // Need to be able to search for E4 linedefs - continue; + lap = player->laps; } - } + else + { + lap = lowestLap; - if (lines[i].flags & ML_NOCLIMB) // Need higher than or equal to - { - if (lap < (sides[lines[i].sidenum[0]].textureoffset >> FRACBITS)) - continue; - } - else if (lines[i].flags & ML_BLOCKMONSTERS) // Need lower than or equal to - { - if (lap > (sides[lines[i].sidenum[0]].textureoffset >> FRACBITS)) - continue; - } - else // Need equal to - { - if (lap != (sides[lines[i].sidenum[0]].textureoffset >> FRACBITS)) - continue; - } + if (lap <= lastLowestLap) + { + // Need to be able to search for E4 linedefs + continue; + } + } - P_RunTriggerLinedef(&lines[i], player->mo, NULL); + if (lines[i].flags & ML_NOCLIMB) // Need higher than or equal to + { + if (lap < (sides[lines[i].sidenum[0]].textureoffset >> FRACBITS)) + continue; + } + else if (lines[i].flags & ML_BLOCKMONSTERS) // Need lower than or equal to + { + if (lap > (sides[lines[i].sidenum[0]].textureoffset >> FRACBITS)) + continue; + } + else // Need equal to + { + if (lap != (sides[lines[i].sidenum[0]].textureoffset >> FRACBITS)) + continue; + } + + P_RunTriggerLinedef(&lines[i], player->mo, NULL); + } } - } - lastLowestLap = lowestLap; + lastLowestLap = lowestLap; + } } else if (player->starpostnum) { @@ -2062,6 +2078,12 @@ static void K_HandleLapDecrement(player_t *player) { if (player) { + + if (player->laps == 0) + { + player->lapvalidation = false; + } + if ((player->starpostnum == 0) && (player->laps > 0)) { player->starpostnum = numstarposts; @@ -4200,7 +4222,7 @@ boolean P_ProcessSpecial(activator_t *activator, INT16 special, INT32 *args, cha if (((args[0] & TMCFF_FLIP) && (side == 0)) || (!(args[0] & TMCFF_FLIP) && (side == 1))) // crossed from behind to infront { - K_HandleLapIncrement(mo->player); + K_HandleLapIncrement(mo->player,false); } else { @@ -5162,10 +5184,7 @@ static void P_EvaluateOldSectorSpecial(player_t *player, sector_t *sector, secto { if ((gametyperules & GTR_CIRCUIT) && (player->exiting == 0) && !(player->pflags & PF_HITFINISHLINE)) { - K_HandleLapIncrement(player); - - //ACS_RunLapScript(mo, line); - //K_HandleLapIncrement(player); + K_HandleLapIncrement(player, true); player->pflags |= PF_HITFINISHLINE; } break;