From: Martin Taibr Date: Fri, 27 Mar 2020 09:12:00 +0000 (+0100) Subject: update information about NaN bug (fixed in DP by f96918f0280) X-Git-Tag: xonotic-v0.8.5~1144^2~4 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=82d2e1efe3030237a3a589111cf3d430cd2ea6cf;p=xonotic%2Fxonotic-data.pk3dir.git update information about NaN bug (fixed in DP by f96918f0280) --- diff --git a/qcsrc/lib/warpzone/mathlib.qc b/qcsrc/lib/warpzone/mathlib.qc index cf86d97f9..2b1d00c2c 100644 --- a/qcsrc/lib/warpzone/mathlib.qc +++ b/qcsrc/lib/warpzone/mathlib.qc @@ -24,11 +24,12 @@ bool isinf(float e) } bool isnan(float e) { - // the sane way to detect NaN is broken because of a compiler bug - // (works with constants but breaks when assigned to variables) - // use conversion to string instead - //float f = e; - //return (e != f); + // The sane way to detect NaN is this: + // float f = e; + // return (e != f); + // but darkplaces used to be compiled with -ffinite-math-only which broke it. + // DP is fixed now but until all clients update (so after 0.8.3) we have to use the following workaround + // or they'd have issues when connecting to newer servers. // Negative NaN ("-nan") is much more common but plain "nan" can be created by negating *some* -nans so we need to check both. // DP's QCVM and GMQCC's QCVM behave differently - one needs ftos(-(0.0 / 0.0)), the other ftos(-sqrt(-1)). @@ -225,7 +226,7 @@ float copysign(float e, float f) { return fabs(e) * ((f>0) ? 1 : -1); } -/// Always use `isnan` function to compare because `float x = nan(); x == x;` gives true + float nan(string tag) { return sqrt(-1);