From: Rudolf Polzer Date: Fri, 3 Jan 2025 23:27:04 +0000 (-0500) Subject: Fix OP_DIV_IF math. X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=bd0bccf314b4847234382e6308f38ce31fc780e4;p=xonotic%2Fdarkplaces.git Fix OP_DIV_IF math. 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. --- diff --git a/prvm_execprogram.h b/prvm_execprogram.h index c3e7ecfc..bf9100fe 100644 --- a/prvm_execprogram.h +++ b/prvm_execprogram.h @@ -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;