Skip to content

Fix desyncs caused by K_PuntMine

Ashnal requested to merge bird/Kart-Public:mine-punt-sync-fix into next

Fixes desyncs caused by punting a mine while it is being held as a trailing item by another player.

My theory as to why syncbombs occur without this code is as follows: Normally, when a mine is thrown by a player, player->mo->hnext is set to NULL after removing the trailing mine, and creating a a non-shield mine. When someone punted it out of your possession however, the mobj was just P_RemoveMobj'ed and player->mo->hnext is never set to NULL.

I wasn't able to completely track down how hnext is used right after, but based on observation, I think the pointer was being used when it didn't have a valid object, causing undefined behavior. Undefined behavior perfectly explains why the game would sometimes desync, and other times be fine, as different computers could process the undefined behavior in different ways, producing desync.

Merge request reports