Merge pull request #14034 from Gymnasiast/fix/12939

Fix #12939: divide-by-0 in Vehicle::UpdateMotionDodgems()
This commit is contained in:
Michael Steenbeek 2021-02-09 22:18:49 +01:00 committed by GitHub
commit f75a48d8dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -6468,7 +6468,7 @@ int32_t Vehicle::UpdateMotionDodgems()
return _vehicleMotionTrackFlags; return _vehicleMotionTrackFlags;
} }
int32_t ebx = (speed * mass) >> 2; int32_t momentum = (speed * mass) >> 2;
int32_t _eax = speed << 14; int32_t _eax = speed << 14;
if (HasUpdateFlag(VEHICLE_UPDATE_FLAG_REVERSING_SHUTTLE)) if (HasUpdateFlag(VEHICLE_UPDATE_FLAG_REVERSING_SHUTTLE))
{ {
@ -6476,7 +6476,8 @@ int32_t Vehicle::UpdateMotionDodgems()
} }
_eax -= velocity; _eax -= velocity;
_eax *= powered_acceleration * 2; _eax *= powered_acceleration * 2;
_eax /= ebx; if (momentum != 0)
_eax /= momentum;
acceleration = _eax - eax; acceleration = _eax - eax;
return _vehicleMotionTrackFlags; return _vehicleMotionTrackFlags;