Fix lap cheat prevention failing when player dies

- Cross a finish line so your lap goes forward and your
  waypoints update ahead of the line
- Turn around to face the opposite direction
- Do this on a map where the lap cheat timer activates
  when you turn around
- Drive a little way backward and make sure the lap cheat
  timer keeps going
- Activate Ring Shooter and start lightsnaking
- Immediately spectate and then rejoin
- The lightsnake would send you ahead of the finish line
  and give you an extra lap
This commit is contained in:
James R 2024-03-10 17:02:56 -07:00
parent 4de4c9e57d
commit fb6ebc6e6f

View file

@ -2209,6 +2209,31 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps)
// SRB2kart
memcpy(&itemRoulette, &players[player].itemRoulette, sizeof (itemRoulette));
memcpy(&respawn, &players[player].respawn, sizeof (respawn));
// Here's the exact scenario:
// - Respawn with Ring Shooter (or lightsnake in general)
// - Spectate, re-enter the game
// - Now respawn.pointxyz is set to where the player
// spectated
// - K_DoIngameRespawn will be called after
// G_PlayerReborn (in P_MovePlayerToCheatcheck)
// - If the respawn state is not reset here, then the
// call to K_DoIngameRespawn will do nothing, and
// respawn.pointxyz will stay the same
// - This is bad, because when K_RespawnChecker runs, it
// clears the init state once the player reaches
// respawn.pointxyz
// - This is because it assumes respawn.pointxyz is where
// the respawn waypoint is located
// - In other words, the init state will reset before
// lightsnake reaches the respawn waypoint
// - This is bad because lap cheat prevention relies on
// the init state being cleared after reaching the
// respawn waypoint (because moving to the respawn
// waypoint could cross a finish line the wrong way and
// lose a lap)
respawn.state = RESPAWNST_NONE;
memcpy(&public_key, &players[player].public_key, sizeof(public_key));
if (betweenmaps || leveltime < introtime)