From 0ceeac4726cf799ea7f4f645adb7527bd8b63ab8 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Apr 2025 13:23:11 +0200 Subject: [PATCH] nooo PARANOIA dont set our thinker next to NULL --- src/p_tick.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index 8fbdf8b6a..91f40c623 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -243,13 +243,19 @@ static thinker_t *currentthinker; void P_RemoveThinkerDelayed(thinker_t *thinker) { #ifdef PARANOIA - if (thinker->next) - thinker->next = NULL; - else if (thinker->references) // Usually gets cleared up in one frame; what's going on here, then? - CONS_Printf("Number of potentially faulty references: %d\n", thinker->references); -#endif - if (thinker->references) +#define BEENAROUNDBIT (0x40000000) // has to be sufficiently high that it's unlikely to happen in regular gameplay. If you change this, pay attention to the bit pattern of INT32_MIN. + if (thinker->references & ~BEENAROUNDBIT) + { + if (thinker->references & BEENAROUNDBIT) // Usually gets cleared up in one frame; what's going on here, then? + CONS_Printf("Number of potentially faulty references: %d\n", (thinker->references & ~BEENAROUNDBIT)); + thinker->references |= BEENAROUNDBIT; return; + } +#undef BEENAROUNDBIT +#else + if (thinker->references != 0) + return; +#endif /* Remove from main thinker list */ thinker_t *next = thinker->next;