Merge branch 'dont-cheat-lap' into 'master'

Finish line cheese Super Prevention

See merge request KartKrew/Kart!1972
This commit is contained in:
Oni 2024-03-03 01:56:34 +00:00
commit 6c60d7165d
2 changed files with 13 additions and 6 deletions

View file

@ -9903,16 +9903,17 @@ static void K_UpdatePlayerWaypoints(player_t *const player)
K_UpdateDistanceFromFinishLine(player); K_UpdateDistanceFromFinishLine(player);
// Respawning should be a full reset. // Respawning should be a full reset.
// So should touching the first waypoint ever.
UINT32 delta = u32_delta(player->distancetofinish, player->distancetofinishprev); UINT32 delta = u32_delta(player->distancetofinish, player->distancetofinishprev);
if (player->respawn.state == RESPAWNST_NONE && delta > distance_threshold) if (player->respawn.state == RESPAWNST_NONE && delta > distance_threshold && old_currentwaypoint != NULL)
{ {
CONS_Debug(DBG_GAMELOGIC, "Player %s: waypoint ID %d too far away (%u > %u)\n", CONS_Debug(DBG_GAMELOGIC, "Player %s: waypoint ID %d too far away (%u > %u)\n",
sizeu1(player - players), K_GetWaypointID(player->nextwaypoint), delta, distance_threshold); sizeu1(player - players), K_GetWaypointID(player->nextwaypoint), delta, distance_threshold);
// Distance jump is too great, keep the old waypoints and recalculate distance. // Distance jump is too great, keep the old waypoints and old distance.
player->currentwaypoint = old_currentwaypoint; player->currentwaypoint = old_currentwaypoint;
player->nextwaypoint = old_nextwaypoint; player->nextwaypoint = old_nextwaypoint;
K_UpdateDistanceFromFinishLine(player); player->distancetofinish = player->distancetofinishprev;
// Start the auto respawn timer when the distance jumps. // Start the auto respawn timer when the distance jumps.
if (!player->bigwaypointgap) if (!player->bigwaypointgap)
@ -9923,11 +9924,15 @@ static void K_UpdatePlayerWaypoints(player_t *const player)
else else
{ {
// Reset the auto respawn timer if distance changes are back to normal. // Reset the auto respawn timer if distance changes are back to normal.
player->bigwaypointgap = 0; if (player->bigwaypointgap == 1)
{
player->bigwaypointgap = 0;
}
} }
// Respawn point should only be updated when we're going to a nextwaypoint // Respawn point should only be updated when we're going to a nextwaypoint
if ((updaterespawn) && if ((updaterespawn) &&
(player->bigwaypointgap == 0) &&
(player->respawn.state == RESPAWNST_NONE) && (player->respawn.state == RESPAWNST_NONE) &&
(player->nextwaypoint != old_nextwaypoint) && (player->nextwaypoint != old_nextwaypoint) &&
(K_GetWaypointIsSpawnpoint(player->nextwaypoint)) && (K_GetWaypointIsSpawnpoint(player->nextwaypoint)) &&
@ -10884,7 +10889,7 @@ void K_UpdateAllPlayerPositions(void)
if (player->respawn.state == RESPAWNST_MOVE && if (player->respawn.state == RESPAWNST_MOVE &&
player->respawn.init == true && player->respawn.init == true &&
player->lastsafelap < player->laps) player->lastsafelap != player->laps)
{ {
player->laps = player->lastsafelap; player->laps = player->lastsafelap;
player->cheatchecknum = player->lastsafecheatcheck; player->cheatchecknum = player->lastsafecheatcheck;

View file

@ -1911,6 +1911,8 @@ static void K_HandleLapIncrement(player_t *player)
{ {
if (player) if (player)
{ {
if (player->respawn.state == RESPAWNST_MOVE || player->bigwaypointgap)
return;
if (!G_TimeAttackStart() && leveltime < starttime && !(gametyperules & GTR_ROLLINGSTART)) if (!G_TimeAttackStart() && leveltime < starttime && !(gametyperules & GTR_ROLLINGSTART))
{ {
// freeze 'em until fault penalty is over // freeze 'em until fault penalty is over
@ -2182,7 +2184,7 @@ static void K_HandleLapDecrement(player_t *player)
{ {
if (player) if (player)
{ {
if (player->respawn.state == RESPAWNST_MOVE) if (player->respawn.state == RESPAWNST_MOVE || player->bigwaypointgap)
return; return;
if ((player->cheatchecknum == 0) && (player->laps > 0)) if ((player->cheatchecknum == 0) && (player->laps > 0))
{ {