Merge branch 'first-overlay-remove-fix' into 'next'

Fix segfault when first mobj in overlaycap is removed

See merge request STJr/SRB2!1963
This commit is contained in:
sphere 2023-05-01 21:16:32 +00:00
commit a78922d022

View file

@ -6904,6 +6904,13 @@ static void P_AddOverlay(mobj_t *thing)
static void P_RemoveOverlay(mobj_t *thing) static void P_RemoveOverlay(mobj_t *thing)
{ {
mobj_t *mo; mobj_t *mo;
if (overlaycap == thing)
{
P_SetTarget(&overlaycap, thing->hnext);
P_SetTarget(&thing->hnext, NULL);
return;
}
for (mo = overlaycap; mo; mo = mo->hnext) for (mo = overlaycap; mo; mo = mo->hnext)
{ {
if (mo->hnext != thing) if (mo->hnext != thing)