Init mobj references before mobj specific spawning in P_SpawnMobj

Fixes MT_MONITOR leaking references due to
Obj_MonitorSpawnParts called before P_AddThinker.

Thanks to toaster
This commit is contained in:
James R 2023-03-20 19:42:41 -07:00
parent d0719ef5ba
commit a396ffe676

View file

@ -10464,6 +10464,9 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
// Set shadowscale here, before spawn hook so that Lua can change it
P_DefaultMobjShadowScale(mobj);
if (!(mobj->flags & MF_NOTHINK))
P_AddThinker(THINK_MOBJ, &mobj->thinker);
// DANGER! This can cause P_SpawnMobj to return NULL!
// Avoid using P_RemoveMobj on the newly created mobj in "MobjSpawn" Lua hooks!
if (LUA_HookMobj(mobj, MOBJ_HOOK(MobjSpawn)))
@ -10926,9 +10929,6 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
}
}
if (!(mobj->flags & MF_NOTHINK))
P_AddThinker(THINK_MOBJ, &mobj->thinker);
if (mobj->skin) // correct inadequecies above.
{
mobj->sprite2 = P_GetSkinSprite2(mobj->skin, (mobj->frame & FF_FRAMEMASK), NULL);