From 03478b64581bf0ea2461551e2def824c9c02e353 Mon Sep 17 00:00:00 2001 From: NepDisk Date: Mon, 6 Jan 2025 12:45:49 -0500 Subject: [PATCH] Use RingRacers line fudge for setting starpost values with new waypoitns --- src/k_kart.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/k_kart.c b/src/k_kart.c index dd3ea002a..19353221e 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7777,6 +7777,21 @@ static UINT32 u32_delta(UINT32 x, UINT32 y) return x > y ? x - y : y - x; } +/*-------------------------------------------------- + * static void K_FudgeRespawn(player_t *player, const waypoint_t *const waypoint) + * + * Fudges respawn coordinates to slightly before the waypoint if it would + * be exactly on a line. See K_GetWaypointIsOnLine. + - *-------------------------------------------------*/ +static void K_FudgeRespawn(player_t *player, const waypoint_t *const waypoint) +{ + const angle_t from = R_PointToAngle2(waypoint->mobj->x, waypoint->mobj->y, + player->mo->x, player->mo->y) >> ANGLETOFINESHIFT; + + player->starpostx += FixedMul(16, FINECOSINE(from)); + player->starposty += FixedMul(16, FINESINE(from)); +} + /*-------------------------------------------------- static void K_UpdatePlayerWaypoints(player_t *const player) @@ -7833,6 +7848,11 @@ static void K_UpdatePlayerWaypoints(player_t *const player) // Then do x and y player->starpostx = player->mo->x >> FRACBITS; player->starposty = player->mo->y >> FRACBITS; + + if (player->nextwaypoint->onaline) + { + K_FudgeRespawn(player, player->nextwaypoint); + } } }