From 0926f39da25a742f5d6cfaececb4cc4d53535e8a Mon Sep 17 00:00:00 2001 From: sezero Date: Fri, 31 Dec 2010 07:55:43 +0000 Subject: [PATCH] applied a better fix for the infamous "SV_TouchLinks: next != l->next" problem. Fixes "whiteroom" (http://www.quaddicted.com/reviews/whiteroom.html) completely locking the engine. fix from the quakeforge sources. git-svn-id: http://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@359 af15c1b1-3010-417e-b628-4374ebc0bcbd --- Quake/world.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/Quake/world.c b/Quake/world.c index 3b369fa3..c6db6b5a 100644 --- a/Quake/world.c +++ b/Quake/world.c @@ -262,11 +262,18 @@ 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; } @@ -283,15 +290,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) { - Con_Printf ("SV_TouchLinks: null link\n"); + // my area got removed out from under me! + Con_Printf ("SV_TouchLinks: encountered NULL link!\n"); break; } - //johnfitz next = l->next; touch = EDICT_FROM_AREA(l); @@ -314,18 +321,12 @@ 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;