Merge branch 'fix-mobjcollide-removemobj-segfault' into 'next'

Fix segfault when calling P_RemoveMobj from MobjCollide hook

See merge request STJr/SRB2!2041
This commit is contained in:
Sal 2023-07-26 12:03:09 +00:00
commit 99c95e2d7a

View file

@ -4009,7 +4009,8 @@ void P_BounceMove(mobj_t *mo)
slidemo = mo;
hitcount = 0;
retry:
do
{
if (++hitcount == 3)
goto bounceback; // don't loop forever
@ -4086,8 +4087,12 @@ bounceback:
newy = FixedMul(mmomy, bestslidefrac);
if (!P_TryMove(mo, mo->x + newx, mo->y + newy, true))
{
if (P_MobjWasRemoved(mo))
return;
goto bounceback;
}
}
// Now continue along the wall.
// First calculate remainder.
@ -4131,9 +4136,8 @@ bounceback:
mo->player->cmomx = tmxmove;
mo->player->cmomy = tmymove;
}
if (!P_TryMove(mo, mo->x + tmxmove, mo->y + tmymove, true))
goto retry;
}
while (!P_TryMove(mo, mo->x + tmxmove, mo->y + tmymove, true) && !P_MobjWasRemoved(mo));
}
//