Merge branch 'finish-line-inaccuracy' into 'master'

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

Closes #1170

See merge request KartKrew/Kart!2119
This commit is contained in:
AJ Martinez 2024-03-17 10:40:10 +00:00
commit 1a9dc17945
5 changed files with 29 additions and 10 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

@ -203,15 +203,7 @@ void K_DoIngameRespawn(player_t *player)
{
if (player->respawn.fromRingShooter == true)
{
waypoint_t *finishline = K_GetFinishLineWaypoint();
waypoint_t *prevWP = player->respawn.wp;
// Laps don't decrement while respawning, so don't cross behind the finish line
while (prevWP->numprevwaypoints > 0 && prevWP != finishline)
{
prevWP = prevWP->prevwaypoints[0];
if (K_GetWaypointIsSpawnpoint(prevWP) == true)
break;
}
const UINT32 dist = (player->airtime * 48);
player->respawn.distanceleft = (dist * mapobjectscale) / FRACUNIT;

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.