Merge branch 'fix-mobj-thinker-reference-corruption' into 'next'

Fix faulty references when spawning mobjs

See merge request STJr/SRB2!2126
This commit is contained in:
Logan Aerl Arias 2024-02-18 01:02:42 +00:00
commit 8bffe3e3a7

View file

@ -10869,9 +10869,6 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type, ...)
)))
mobj->flags2 |= MF2_DONTRESPAWN;
if (!(mobj->flags & MF_NOTHINK))
P_AddThinker(THINK_MOBJ, &mobj->thinker);
if (type == MT_PLAYER)
{
// when spawning MT_PLAYER, set mobj->player before calling MobjSpawn hook to prevent P_RemoveMobj from succeeding on player mobj.
@ -10881,6 +10878,9 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type, ...)
va_end(args);
}
if (!(mobj->flags & MF_NOTHINK) || (titlemapinaction && mobj->type == MT_ALTVIEWMAN))
P_AddThinker(THINK_MOBJ, &mobj->thinker);
// increment mobj reference, so we don't get a dangling reference in case MobjSpawn calls P_RemoveMobj
mobj->thinker.references++;