mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-18 07:22: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
7d14796954
commit
27e084a827
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;
|
||||
INT32 deadzoneAppliedValue = 0;
|
||||
|
||||
if (jdeadzone > 0)
|
||||
{
|
||||
if (magnitude > jdeadzone)
|
||||
if (jdeadzone > 0 && magnitude > jdeadzone && deadZone < FRACUNIT)
|
||||
{
|
||||
INT32 adjustedMagnitude = abs(magnitude);
|
||||
adjustedMagnitude = min(adjustedMagnitude, JOYAXISRANGE);
|
||||
|
@ -1056,7 +1054,6 @@ static INT32 G_BasicDeadZoneCalculation(INT32 magnitude, fixed_t deadZone)
|
|||
|
||||
deadzoneAppliedValue = (adjustedMagnitude * JOYAXISRANGE) / (JOYAXISRANGE - jdeadzone);
|
||||
}
|
||||
}
|
||||
|
||||
return deadzoneAppliedValue;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue