Fix segfault when calling P_RemoveMobj from MobjCollide hook

This commit is contained in:
Gustaf Alhäll 2023-07-07 21:35:41 +02:00
parent d7a84b967c
commit ecf0c4b45a
No known key found for this signature in database
GPG key ID: 6C1F67D690CDEDFD

View file

@ -4005,7 +4005,8 @@ void P_BounceMove(mobj_t *mo)
slidemo = mo;
hitcount = 0;
retry:
do
{
if (++hitcount == 3)
goto bounceback; // don't loop forever
@ -4082,8 +4083,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.
@ -4127,9 +4132,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));
}
//