From fcf0836e7b7bd674a5ecbfa30be7ef3e0a62eeb9 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 12 Nov 2023 16:09:34 +0100 Subject: [PATCH] Fix shadows from sometimes crashing on mapload this properly fixes the mapchange spam from crashing the game P_RunShadows, like any other thinker function, should also be called in preticker not just ticker potentioally also fixes other issues --- src/p_mobj.c | 35 +++++++++++++++++++++++------------ src/p_tick.c | 2 ++ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 12653d39d..ad437585f 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6063,13 +6063,22 @@ static void P_AddOverlay(mobj_t *thing) static void P_RemoveOverlay(mobj_t *thing) { mobj_t *mo; + if (overlaycap == thing) + { + P_SetTarget(&overlaycap, thing->hnext); + P_SetTarget(&thing->hnext, NULL); + return; + } + for (mo = overlaycap; mo; mo = mo->hnext) - if (mo->hnext == thing) - { - P_SetTarget(&mo->hnext, thing->hnext); - P_SetTarget(&thing->hnext, NULL); - return; - } + { + if (mo->hnext != thing) + continue; + + P_SetTarget(&mo->hnext, thing->hnext); + P_SetTarget(&thing->hnext, NULL); + return; + } } void P_RunShadows(void) @@ -6175,12 +6184,14 @@ static void P_RemoveShadow(mobj_t *thing) } for (mo = shadowcap; mo; mo = mo->hnext) - if (mo->hnext == thing) - { - P_SetTarget(&mo->hnext, thing->hnext); - P_SetTarget(&thing->hnext, NULL); - return; - } + { + if (mo->hnext != thing) + continue; + + P_SetTarget(&mo->hnext, thing->hnext); + P_SetTarget(&thing->hnext, NULL); + return; + } } void A_BossDeath(mobj_t *mo); diff --git a/src/p_tick.c b/src/p_tick.c index 39e32e4c8..c3d12e77b 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -918,6 +918,8 @@ void P_PreTicker(INT32 frames) // Run shield positioning //P_RunShields(); P_RunOverlays(); + + P_RunShadows(); P_UpdateSpecials(); P_RespawnSpecials();