Skip to content

Fix segfault when calling P_RemoveMobj from MobjCollide hook

Hanicef requested to merge Hanicef/SRB2:fix-mobjcollide-removemobj-segfault into next

When P_RemoveMobj is called from the MobjCollide hook, the game can segfault when bouncing objects hit a wall. This was, as always, caused by missing P_MobjWasRemoved checks around calls to P_TryMove in P_BounceMove. All P_TryMove calls are now followed by checks with P_MobjWasRemoved, and a label was replaced with a do-while for readability reasons.

As always with these bugs, they don't trigger consistently on a release build, so make sure to do a debug build when testing this!

This addon is known to trigger this bug: https://mb.srb2.org/addons/plague-knight.3667/

Merge request reports