]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
experimental change: do a float compare for OP_IF and OP_IFNOT, so negative
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 14 Aug 2009 19:39:24 +0000 (19:39 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 14 Aug 2009 19:39:24 +0000 (19:39 +0000)
zero float value counts as false. No other value in QC can have the bit pattern
0x80000000 as long as no int type is added.

I have verified that the only false floats on x86_64 and i386 are 0 and
0x80000000.  However, this may fail on other platforms! (but then, OR_F and
others would also fail in some cases, as fteqcc also uses it for "float ||
entity").

When an "int" type is introduced, we'll need a new IF_I and IFNOT_I instruction
as then this would REALLY have a bad impact.

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9113 d7cf8633-e32d-0410-b094-e92efae38249

prvm_execprogram.h

index 17ea2fccca4b341d4789c05840f0275938c9b0ce..19fc6bb3e428ca429e9bc1b2e9e7861c9674c4f2 100644 (file)
                //==================
 
                        case OP_IFNOT:
-                               if (!OPA->_int)
+                               if (!OPA->_float)
+                               // TODO add an "int-ifnot"
+                               // although mostly unneeded, thanks to the only float being false being 0x0 and 0x80000000 (negative zero)
+                               // and entity, string, field values can never have that value
                                {
                                        prog->xfunction->profile += (st - startst);
                                        st += st->b - 1;        // offset the s++
                                break;
 
                        case OP_IF:
-                               if (OPA->_int)
+                               if (OPA->_float)
+                               // TODO add an "int-if"
+                               // although mostly unneeded, thanks to the only float being false being 0x0 and 0x80000000 (negative zero)
+                               // and entity, string, field values can never have that value
                                {
                                        prog->xfunction->profile += (st - startst);
                                        st += st->b - 1;        // offset the s++