Skip to content

Fix bikes breaking when their steering lock is set to zero - #5152

Open
TheCrazy17 wants to merge 2 commits into
multitheftauto:masterfrom
TheCrazy17:bikes-steeringlock
Open

Fix bikes breaking when their steering lock is set to zero#5152
TheCrazy17 wants to merge 2 commits into
multitheftauto:masterfrom
TheCrazy17:bikes-steeringlock

Conversation

@TheCrazy17

Copy link
Copy Markdown
Contributor

Summary

Sets the bike steer and lean ratios to zero when a vehicle's steeringLock handling is zero, instead of dividing by it.

Motivation

Resolves #494. CBike::ProcessControl divides the steer angle by the steering lock in radians to get a ratio. The steer angle is itself the steering lock times the input, so a lock of zero makes this 0 / 0, a NaN rather than an infinity. Cars survive the same division because an infinity trips their "greater than 1" clamp, while a NaN compares false against every clamp and passes straight through. It reaches the rider lean angle, and CBike::CalculateLeanMatrix builds the bike and rider matrices from it, stretching the ped until respawn.

Test plan

Repro from the issue:

setVehicleHandling(getRandomPlayer().vehicle, "steeringLock", 0)

Get an NRG-500, set its steeringLock to 0, and crash into something. Before this change the ped stretches out and stays broken until respawn. After it, the bike behaves like a normal collision.

Also checked that bikes with a normal steering lock still steer and lean correctly, since only the zero case takes the new path.

Checklist

@FileEX FileEX added the bugfix Solution to a bug of any kind label Aug 9, 2026
@FileEX

FileEX commented Aug 14, 2026

Copy link
Copy Markdown
Member

Please resolve conflicts & fix build

@TheCrazy17

Copy link
Copy Markdown
Contributor Author

Please resolve conflicts & fix build

Done ✅

// clang-format off
__asm
{
push eax

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you don't need to preserve this register, since it's modified at 0x6BAC22 anyway

// clang-format off
__asm
{
push eax

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you don't need to preserve this register, since it's modified at 0x6BBAE2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Solution to a bug of any kind

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Setting steeringlock to 0 on bikes will mess up the game

2 participants