summaryrefslogtreecommitdiff
path: root/src/doom/p_tick.c
diff options
context:
space:
mode:
authorSimon Howard2015-06-03 20:20:37 -0400
committerSimon Howard2015-06-03 20:20:37 -0400
commitf28d798073e571cb3114208cfa81653b9b502f6c (patch)
treec007c4286e983d00658c0c2c7526af2bb293b401 /src/doom/p_tick.c
parentd6556ee4b4d9d2c4c9ac48f998bd387f5416b75d (diff)
downloadchocolate-doom-f28d798073e571cb3114208cfa81653b9b502f6c.tar.gz
chocolate-doom-f28d798073e571cb3114208cfa81653b9b502f6c.tar.bz2
chocolate-doom-f28d798073e571cb3114208cfa81653b9b502f6c.zip
Fix demo desyncs caused by P_RunThinkers() change.
1bcff874c52a changed the behavior of P_RunThinkers() to avoid dereferencing thinker pointers after they had been freed, but the modified version of the function was not logically equivalent to Vanilla version, because the 'next' pointer can be changed by the thinker function if one is invoked. This fixes a desync in tnt-speed-movie-0443131.lmp. Thanks to Zvonimir Bužanić for the bug report and Fabian Greffrath for reporting. Fixes #547.
Diffstat (limited to 'src/doom/p_tick.c')
-rw-r--r--src/doom/p_tick.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/doom/p_tick.c b/src/doom/p_tick.c
index c933cfe9..5a93b80f 100644
--- a/src/doom/p_tick.c
+++ b/src/doom/p_tick.c
@@ -98,11 +98,10 @@ void P_RunThinkers (void)
currentthinker = thinkercap.next;
while (currentthinker != &thinkercap)
{
- nextthinker = currentthinker->next;
-
if ( currentthinker->function.acv == (actionf_v)(-1) )
{
// time to remove it
+ nextthinker = currentthinker->next;
currentthinker->next->prev = currentthinker->prev;
currentthinker->prev->next = currentthinker->next;
Z_Free(currentthinker);
@@ -111,6 +110,7 @@ void P_RunThinkers (void)
{
if (currentthinker->function.acp1)
currentthinker->function.acp1 (currentthinker);
+ nextthinker = currentthinker->next;
}
currentthinker = nextthinker;
}