From 2eeced7210ad6e1c623308f88dd336d886e193d3 Mon Sep 17 00:00:00 2001 From: stevenaaus Date: Sat, 14 Aug 2010 03:59:29 +0000 Subject: [PATCH] PF_traceline causes program to die badly if given non-numeric (isnan) vectors. So we must check to not allow this happening. Additionally, stop program execution is developer cvar is set. Note: Compiling program with gcc option \'-ffast-math\' (and more specifically, -funsafe-math-optimizations) is an alternative fix than this patch. It performs FPU opts that gloss over the issue git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@268 af15c1b1-3010-417e-b628-4374ebc0bcbd --- quakespasm/Quake/pr_cmds.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/quakespasm/Quake/pr_cmds.c b/quakespasm/Quake/pr_cmds.c index 6f99b224..fc29343b 100644 --- a/quakespasm/Quake/pr_cmds.c +++ b/quakespasm/Quake/pr_cmds.c @@ -658,6 +658,19 @@ void PF_traceline (void) nomonsters = G_FLOAT(OFS_PARM2); ent = G_EDICT(OFS_PARM3); +if (developer.value) { + if (isnan(v1[0]) || isnan(v1[1]) || isnan(v1[2]) || + isnan(v2[0]) || isnan(v2[1]) || isnan(v2[2])) + { + Host_Error("NAN in traceline:\nv1(%f %f %f) v2(%f %f %f)\nentity %d", + v1[0], v1[1], v1[2], v2[0], v2[1], v2[2], EDICT_TO_PROG(ent)); + } +} else { + if (isnan(v1[0]) || isnan(v1[1]) || isnan(v1[2])) + v1[0] = v1[1] = v1[2] = 0; + if (isnan(v2[0]) || isnan(v2[1]) || isnan(v2[2])) + v2[0] = v2[1] = v2[2] = 0; +} trace = SV_Move (v1, vec3_origin, vec3_origin, v2, nomonsters, ent); pr_global_struct->trace_allsolid = trace.allsolid;