From bd0bccf314b4847234382e6308f38ce31fc780e4 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Fri, 3 Jan 2025 18:27:04 -0500 Subject: [PATCH] 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. --- prvm_execprogram.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; -- 2.39.5