Feature: [NewGRF] Maximum curve speed modifier for rail vehicles #9346
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation / Problem
Prior to 0f91cb0, rail type's
curve_speed
essentially worked as a vehicle property. A rail vehicle could set its curve speed advantage to an arbitrary value by choosing the proper "home" rail type and the advantage would apply when traveling on compatible rail types.Currently, the only way a rail vehicle can control its curve speed bonus is via the tilt property, which is a flat 20% bonus. There are no other ways in which the original behavior can be recovered. NUTS (and possibly other NewGRFs) relied on that behavior quite heavily.
Description
This PR fixes the stated problem by introducing a new rail vehicle property:
curve_speed_mod
(0x2E). A 16 bit signed fixed-point binary number with 8 fractional bits, ranging from -128 to 127.996. 0 represents no bonus (default behavior), positive numbers increase maximum curve speed, negative numbers decrease. As an example, the value 1.0 (0x0100) would double the vehicle's speed in curves.The way this property works is analogous to tilt. Each part of the consist has its own
curve_speed_mod
and the curve speed advantage of the entire consist is given by its weakest link.Moreover, NewGRFs can also affect
curve_speed_mod
via callback 0x36. The resulting 15 bits represent values from -64 to 63.996. To support negative modifiers,GetEngineProperty
andGetVehicleProperty
now optionally allow negative numbers (existing uses are unaffected).This change also expands the possible design space compared to the original behavior: NewGRFs can provide powerful trains that travel slowly in curves; wagons that, when refitted to fragile cargo, must travel slowly in curves; and so on.
NML support: OpenTTD/nml#222
Limitations
No known limitations.
Checklist for review
Some things are not automated, and forgotten often. This list is a reminder for the reviewers.