mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Improve finish line distance big jump prevention
- Freeze finish line distance (instead of recalculating it from old nextwaypoint) - Reset auto respawn timer right before it runs out (instead of AS SOON as finish line distance returns to normal) - Do not ever update respawn waypoint while auto respawn timer is ticking - Do not interact with finish line while auto respawn timer is ticking
This commit is contained in:
parent
69ed099490
commit
6642449908
2 changed files with 11 additions and 6 deletions
13
src/k_kart.c
13
src/k_kart.c
|
|
@ -9884,16 +9884,17 @@ static void K_UpdatePlayerWaypoints(player_t *const player)
|
|||
K_UpdateDistanceFromFinishLine(player);
|
||||
|
||||
// Respawning should be a full reset.
|
||||
// So should touching the first waypoint ever.
|
||||
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",
|
||||
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->nextwaypoint = old_nextwaypoint;
|
||||
K_UpdateDistanceFromFinishLine(player);
|
||||
player->distancetofinish = player->distancetofinishprev;
|
||||
|
||||
// Start the auto respawn timer when the distance jumps.
|
||||
if (!player->bigwaypointgap)
|
||||
|
|
@ -9904,11 +9905,15 @@ static void K_UpdatePlayerWaypoints(player_t *const player)
|
|||
else
|
||||
{
|
||||
// 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
|
||||
if ((updaterespawn) &&
|
||||
(player->bigwaypointgap == 0) &&
|
||||
(player->respawn.state == RESPAWNST_NONE) &&
|
||||
(player->nextwaypoint != old_nextwaypoint) &&
|
||||
(K_GetWaypointIsSpawnpoint(player->nextwaypoint)) &&
|
||||
|
|
|
|||
|
|
@ -1911,7 +1911,7 @@ static void K_HandleLapIncrement(player_t *player)
|
|||
{
|
||||
if (player)
|
||||
{
|
||||
if (player->respawn.state == RESPAWNST_MOVE)
|
||||
if (player->respawn.state == RESPAWNST_MOVE || player->bigwaypointgap)
|
||||
return;
|
||||
if (!G_TimeAttackStart() && leveltime < starttime && !(gametyperules & GTR_ROLLINGSTART))
|
||||
{
|
||||
|
|
@ -2184,7 +2184,7 @@ static void K_HandleLapDecrement(player_t *player)
|
|||
{
|
||||
if (player)
|
||||
{
|
||||
if (player->respawn.state == RESPAWNST_MOVE)
|
||||
if (player->respawn.state == RESPAWNST_MOVE || player->bigwaypointgap)
|
||||
return;
|
||||
if ((player->cheatchecknum == 0) && (player->laps > 0))
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue