Fix signed integer overflow in GetCurrentMonitor distance calc
This commit is contained in:
parent
cf9f27db54
commit
e0083bc7fe
|
|
@ -839,7 +839,7 @@ int GetCurrentMonitor(void)
|
||||||
// this is probably an overengineered solution for a side case
|
// this is probably an overengineered solution for a side case
|
||||||
// trying to match SDL behaviour
|
// trying to match SDL behaviour
|
||||||
|
|
||||||
int closestDist = 0x7FFFFFFF;
|
long long closestDist = 0x7FFFFFFFFFFFFFFFLL;
|
||||||
|
|
||||||
// Window center position
|
// Window center position
|
||||||
int wcx = 0;
|
int wcx = 0;
|
||||||
|
|
@ -883,7 +883,7 @@ int GetCurrentMonitor(void)
|
||||||
|
|
||||||
int dx = wcx - xclosest;
|
int dx = wcx - xclosest;
|
||||||
int dy = wcy - yclosest;
|
int dy = wcy - yclosest;
|
||||||
int dist = (dx*dx) + (dy*dy);
|
long long dist = (long long)dx*dx + (long long)dy*dy;
|
||||||
if (dist < closestDist)
|
if (dist < closestDist)
|
||||||
{
|
{
|
||||||
index = i;
|
index = i;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user