mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-03-23 03:12:38 +00:00
Merge branch 'fix-pointtodist-negative-abs' into 'next'
Fix crash in R_PointToDist2 when passing -2147483648 See merge request STJr/SRB2!1964
This commit is contained in:
commit
03626bccfe
2 changed files with 3 additions and 2 deletions
|
@ -34,6 +34,7 @@
|
|||
*/
|
||||
|
||||
typedef INT32 fixed_t;
|
||||
typedef UINT32 ufixed_t;
|
||||
|
||||
/*!
|
||||
\brief convert fixed_t into floating number
|
||||
|
@ -106,7 +107,7 @@ FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedInt(fixed_t a)
|
|||
*/
|
||||
FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedDiv(fixed_t a, fixed_t b)
|
||||
{
|
||||
if ((abs(a) >> (FRACBITS-2)) >= abs(b))
|
||||
if (((ufixed_t)abs(a) >> (FRACBITS-2)) >= (ufixed_t)abs(b))
|
||||
return (a^b) < 0 ? INT32_MIN : INT32_MAX;
|
||||
|
||||
return FixedDiv2(a, b);
|
||||
|
|
|
@ -356,7 +356,7 @@ angle_t R_PointToAngle2(fixed_t pviewx, fixed_t pviewy, fixed_t x, fixed_t y)
|
|||
fixed_t R_PointToDist2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1)
|
||||
{
|
||||
angle_t angle;
|
||||
fixed_t dx, dy, dist;
|
||||
ufixed_t dx, dy, dist;
|
||||
|
||||
dx = abs(px1 - px2);
|
||||
dy = abs(py1 - py2);
|
||||
|
|
Loading…
Reference in a new issue