]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Fix OP_DIV_IF math.
authorRudolf Polzer <divVerent@gmail.com>
Fri, 3 Jan 2025 23:27:04 +0000 (18:27 -0500)
committerRudolf Polzer <divVerent@gmail.com>
Fri, 3 Jan 2025 23:40:44 +0000 (18:40 -0500)
Previously 5 / 1.25 returned 5 due to rounding the 1.25 to int and
performing an integer division.

Now 5 / 1.25 will return 4 due to converting the 5 to floating point and
performing a floating division.

Which is a lot more what one would expect, and also matches FTEQW.

prvm_execprogram.h

index c3e7ecfc3760d9609613fee9365b4540b9018942..bf9100fe615b3bc12b3f8aec07adfbf81f341d2c 100644 (file)
@@ -875,7 +875,7 @@ prvm_eval_t *src;
                                OPC->_int = OPA->_int / OPB->_int;
                                DISPATCH_OPCODE();
                        HANDLE_OPCODE(OP_DIV_IF):
-                               OPC->_float = OPA->_int / (prvm_int_t) OPB->_float;
+                               OPC->_float = ((prvm_vec_t) OPA->_int) / OPB->_float;
                                DISPATCH_OPCODE();
                        HANDLE_OPCODE(OP_DIV_FI):
                                OPC->_float = OPA->_float / (prvm_vec_t) OPB->_int;