Merge branch 'fixedmul-c-fix' into 'master'

Correct C FixedMul() off-by-one errors

See merge request STJr/SRB2!245
This commit is contained in:
Monster Iestyn 2018-06-03 15:14:06 -04:00
commit 650e0eafce

View file

@ -33,7 +33,9 @@
*/ */
fixed_t FixedMul(fixed_t a, fixed_t b) fixed_t FixedMul(fixed_t a, fixed_t b)
{ {
return (fixed_t)((((INT64)a * b) ) / FRACUNIT); // Need to cast to unsigned before shifting to avoid undefined behaviour
// for negative integers
return (fixed_t)(((UINT64)((INT64)a * b)) >> FRACBITS);
} }
#endif //__USE_C_FIXEDMUL__ #endif //__USE_C_FIXEDMUL__