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/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 6e399dee9..3d7c9fa3c 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1885,10 +1885,15 @@ 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 (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; @@ -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;