mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Fix division-by-0 crash with gamepad deadzones
Fix division-by-0 crash with gamepad deadzones The problem was that it checked if A was more than B, then lowered A to a max value, then subtracted B from A, then divided something by that, without checking if A minus B was 0, allowing division by 0 if B was the same as that max value This fixes that by making sure that A is less than the max value
This commit is contained in:
parent
800d277dec
commit
04921ab484
1 changed files with 5 additions and 8 deletions
|
|
@ -1045,9 +1045,7 @@ static INT32 G_BasicDeadZoneCalculation(INT32 magnitude, fixed_t deadZone)
|
||||||
const INT32 jdeadzone = (JOYAXISRANGE * deadZone) / FRACUNIT;
|
const INT32 jdeadzone = (JOYAXISRANGE * deadZone) / FRACUNIT;
|
||||||
INT32 deadzoneAppliedValue = 0;
|
INT32 deadzoneAppliedValue = 0;
|
||||||
|
|
||||||
if (jdeadzone > 0)
|
if (jdeadzone > 0 && magnitude > jdeadzone && deadZone < FRACUNIT)
|
||||||
{
|
|
||||||
if (magnitude > jdeadzone)
|
|
||||||
{
|
{
|
||||||
INT32 adjustedMagnitude = abs(magnitude);
|
INT32 adjustedMagnitude = abs(magnitude);
|
||||||
adjustedMagnitude = min(adjustedMagnitude, JOYAXISRANGE);
|
adjustedMagnitude = min(adjustedMagnitude, JOYAXISRANGE);
|
||||||
|
|
@ -1056,7 +1054,6 @@ static INT32 G_BasicDeadZoneCalculation(INT32 magnitude, fixed_t deadZone)
|
||||||
|
|
||||||
deadzoneAppliedValue = (adjustedMagnitude * JOYAXISRANGE) / (JOYAXISRANGE - jdeadzone);
|
deadzoneAppliedValue = (adjustedMagnitude * JOYAXISRANGE) / (JOYAXISRANGE - jdeadzone);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return deadzoneAppliedValue;
|
return deadzoneAppliedValue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue