diff --git a/src/p_maputl.c b/src/p_maputl.c index 760e45c4fb0b6da874b51e91e9a87585d0a1f15c..17df33a917256bdff71cb3e9dea03b4739bf22a0 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -1034,7 +1034,10 @@ boolean P_BlockThingsIterator(INT32 x, INT32 y, boolean (*func)(mobj_t *)) { P_SetTarget(&bnext, mobj->bnext); // We want to note our reference to bnext here incase it is MF_NOTHINK and gets removed! if (!func(mobj)) + { + P_SetTarget(&bnext, NULL); return false; + } if (P_MobjWasRemoved(tmthing) // func just popped our tmthing, cannot continue. || (bnext && P_MobjWasRemoved(bnext))) // func just broke blockmap chain, cannot continue. { @@ -1042,6 +1045,7 @@ boolean P_BlockThingsIterator(INT32 x, INT32 y, boolean (*func)(mobj_t *)) return true; } } + P_SetTarget(&bnext, NULL); return true; } diff --git a/src/p_mobj.c b/src/p_mobj.c index 530dd37dcdb56e07222589514fecead57a8bc139..bfdb5a7f59f8eda454eb35609cb473782e607021 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9893,6 +9893,9 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) break; } + if (!(mobj->flags & MF_NOTHINK)) + P_AddThinker(&mobj->thinker); // Needs to come before the shadow spawn, or else the shadow's reference gets forgotten + switch (mobj->type) { case MT_PLAYER: @@ -9916,9 +9919,6 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) break; } - if (!(mobj->flags & MF_NOTHINK)) - P_AddThinker(&mobj->thinker); - // Call action functions when the state is set if (st->action.acp1 && (mobj->flags & MF_RUNSPAWNFUNC)) {