Make sure MT_LOOPCENTERPOINT doesn't have an invalid stack-allocated spawnpoint pointer

Fixes connecting to a server that's currently on a map with a loop.

Also tidies P_SpawnItemRow, P_SpawnItemCircle to reduce the likelihood of this happening again, and possible crash with Lua-shortcircuited loop spawning
This commit is contained in:
toaster 2023-07-17 13:51:48 +01:00
parent a59896ef88
commit 45012dbd6a

View file

@ -13788,8 +13788,15 @@ static void P_SpawnItemRow(mapthing_t *mthing, mobjtype_t *itemtypes, UINT8 numi
y + FixedMul(length, FINESINE(fineangle)),
z, MT_LOOPCENTERPOINT);
if (!P_MobjWasRemoved(loopanchor))
Obj_LinkLoopAnchor(loopanchor, loopcenter, mthing->args[0]);
if (P_MobjWasRemoved(loopanchor))
{
// No recovery.
return;
}
loopanchor->spawnpoint = NULL;
Obj_LinkLoopAnchor(loopanchor, loopcenter, mthing->args[0]);
}
for (r = 0; r < numitems; r++)
@ -13809,15 +13816,15 @@ static void P_SpawnItemRow(mapthing_t *mthing, mobjtype_t *itemtypes, UINT8 numi
if (!inclusive)
mobj = P_SpawnMobjFromMapThing(&dummything, x, y, z, itemtype);
if (!mobj)
if (P_MobjWasRemoved(mobj))
continue;
if (isloopend)
{
Obj_InitLoopEndpoint(mobj, loopanchor);
}
mobj->spawnpoint = NULL;
if (!isloopend)
continue;
Obj_InitLoopEndpoint(mobj, loopanchor);
}
}
@ -13875,11 +13882,12 @@ static void P_SpawnItemCircle(mapthing_t *mthing, mobjtype_t *itemtypes, UINT8 n
mobj = P_SpawnMobjFromMapThing(&dummything, x + v[0], y + v[1], z + v[2], itemtype);
if (!mobj)
if (P_MobjWasRemoved(mobj))
continue;
mobj->z -= mobj->height/2;
mobj->spawnpoint = NULL;
mobj->z -= mobj->height/2;
}
}