New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow NewGRF vehicles to query the track-type NewGRF about the current track-type #8554
Conversation
…le NewGRF using cargo-slots.
…queried cargo is valid.
e414fa5
to
2ed1349
Compare
…t tile against a given tracktype.
…nt tile has catenary.
2ed1349
to
7be2154
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good, a birdy tells me this is wanted functionality (from a NewGRF author perspective), and I doubt we have anyone active other than you who really understands this to review it properly. So yeah .. YOLO :D
(pretty sure if you screwed up somehow, you fix it too, so I am not worried :D)
This addition reflects part of OpenTTD/OpenTTD#8554.
This addition reflects part of OpenTTD/OpenTTD#8554.
This addition reflects part of OpenTTD/OpenTTD#8554.
This addition reflects part of OpenTTD/OpenTTD#8554.
This description uses "track-type" to refer to all 3 of "rail-type", "road-type" and "tram-type".
Motivation / Problem
Currently NewGRF vehicles can define a single track-type for their vehicles, which then decides what track-type they can drive on, and whether they are powered.
However, things are not always that binary. Dual-powered vehicles are compatible to multiple track-types and have different poweredness on them.
This extends from simple things like raising a pantograph when there is catenary, to changing vehicle power depending on whether there is electrification or whether the vehicle uses a secondary diesel engine.
Currently vehicle NewGRF can query the track-type of the current tile via var 4A. But this information is only usable when the NewGRF knows every track-type in existence.
This PR adds some variables to query some properties about the track-type on the current tile, so the vehicle NewGRF can essentially query the knowledge of the track-type NewGRF about track-type compatibility and poweredness.
Description
This PR adds two methods to solve above problems. A simple one for simple NewGRF, and a complex one for NewGRF which want to deal with the full complexity of track-type compatibility.
Notes:
Limitations
See description.
Checklist for review
Some things are not automated, and forgotten often. This list is a reminder for the reviewers.
The bug fix is important enough to be backported? (label: 'backport requested')This PR affects the save game format? (label 'savegame upgrade')This PR affects the GS/AI API? (label 'needs review: Script API')ai_changelog.hpp, gs_changelog.hpp need updating.The compatibility wrappers (compat_*.nut) need updating.