Pause waypoint updates while player is touching finish line but not crossing it

- Right on the line, P_PointOnLineSide may disagree with
  P_TraceWaypointTraversal.
- If this happens, nextwaypoint may update ahead of the
  finish line before the player crosses it.
- This bloats the finish line distance and triggers lap
  cheat prevention, preventing the player from gaining a
  lap.
- Since this only seems like it can happen very near to
  the line, simply don't update waypoints if the player is
  touching the line but hasn't crossed it.
- This will cause distancetofinish to jump but only for a
  very short distance (the radius of the player).
This commit is contained in:
James R 2024-03-16 06:50:14 -07:00
parent e1f4aef2ef
commit 99656765e5
4 changed files with 29 additions and 2 deletions

View file

@ -106,8 +106,9 @@ typedef enum
PF_ANALOGSTICK = 1<<14, // This player is using an analog joystick
PF_TRUSTWAYPOINTS = 1<<15, // Do not activate lap cheat prevention next time finish line distance is updated
PF_FREEZEWAYPOINTS = 1<<16, // Skip the next waypoint/finish line distance update
//16-17 free, was previously itemflags stuff
//1<<17 free, was previously itemflags stuff
PF_DRIFTINPUT = 1<<18, // Drifting!
PF_GETSPARKS = 1<<19, // Can get sparks

View file

@ -4049,7 +4049,7 @@ const char *const PLAYERFLAG_LIST[] = {
"ANALOGSTICK", // This player is using an analog joystick
"TRUSTWAYPOINTS", // Do not activate lap cheat prevention next time finish line distance is updated
"\x01", // Free
"FREEZEWAYPOINTS", // Skip the next waypoint/finish line distance update
"\x01", // Free
"DRIFTINPUT", // Drifting!

View file

@ -10013,6 +10013,12 @@ static UINT32 u32_delta(UINT32 x, UINT32 y)
--------------------------------------------------*/
static void K_UpdatePlayerWaypoints(player_t *const player)
{
if (player->pflags & PF_FREEZEWAYPOINTS)
{
player->pflags &= ~PF_FREEZEWAYPOINTS;
return;
}
const UINT32 distance_threshold = FixedMul(32768, mapobjectscale);
waypoint_t *const old_currentwaypoint = player->currentwaypoint;

View file

@ -3147,6 +3147,26 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff, Try
{
P_CrossSpecialLine(ld, oldside, thing);
}
else if (ld->special == 2001 && thing->player) // Finish Line
{
// ~~ WAYPOINT BULLSHIT ~~
// Right on the line, P_PointOnLineSide may
// disagree with P_TraceWaypointTraversal.
// If this happens, nextwaypoint may update
// ahead of the finish line before the player
// crosses it.
// This bloats the finish line distance and
// triggers lap cheat prevention, preventing
// the player from gaining a lap.
// Since this only seems like it can happen
// very near to the line, simply don't update
// waypoints if the player is touching the
// line but hasn't crossed it.
// This will cause distancetofinish to jump
// but only for a very short distance (the
// radius of the player).
thing->player->pflags |= PF_FREEZEWAYPOINTS;
}
}
// Currently this just iterates all checkpoints.