From 73123e19cbe796b7d70ccca9f712be1295cb557b Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Mon, 28 Aug 2017 02:15:02 +0000 Subject: [PATCH] Revert "applied a better fix for the infamous "SV_TouchLinks: next != l->next" problem." This reverts r359 git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@1483 af15c1b1-3010-417e-b628-4374ebc0bcbd --- Quake/world.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/Quake/world.c b/Quake/world.c index 32f04229..045b4993 100644 --- a/Quake/world.c +++ b/Quake/world.c @@ -265,18 +265,11 @@ SV_UnlinkEdict =============== */ -static link_t **sv_link_next; -static link_t **sv_link_prev; - void SV_UnlinkEdict (edict_t *ent) { if (!ent->area.prev) return; // not linked in anywhere RemoveLink (&ent->area); - if (sv_link_next && *sv_link_next == &ent->area) - *sv_link_next = ent->area.next; - if (sv_link_prev && *sv_link_prev == &ent->area) - *sv_link_prev = ent->area.prev; ent->area.prev = ent->area.next = NULL; } @@ -293,15 +286,15 @@ void SV_TouchLinks ( edict_t *ent, areanode_t *node ) int old_self, old_other; // touch linked edicts - sv_link_next = &next; for (l = node->trigger_edicts.next ; l != &node->trigger_edicts ; l = next) { + //johnfitz -- fixes a crash when a touch function deletes an entity which comes later in the list if (!l) { - // my area got removed out from under me! - Con_Printf ("SV_TouchLinks: encountered NULL link!\n"); + Con_Printf ("SV_TouchLinks: null link\n"); break; } + //johnfitz next = l->next; touch = EDICT_FROM_AREA(l); @@ -324,12 +317,18 @@ void SV_TouchLinks ( edict_t *ent, areanode_t *node ) pr_global_struct->time = sv.time; PR_ExecuteProgram (touch->v.touch); + //johnfitz -- the PR_ExecuteProgram above can alter the linked edicts -- fix from tyrquake + if (next != l->next && l->next) + { + Con_Printf ("SV_TouchLinks: next != l->next\n"); + next = l->next; + } + //johnfitz + pr_global_struct->self = old_self; pr_global_struct->other = old_other; } - sv_link_next = NULL; - // recurse down both sides if (node->axis == -1) return;