Skip to content
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

Feature: [NewGRF] Allow fixed layout up to 256 tiles per NewGRF rail station. #12554

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

PeterN
Copy link
Member

@PeterN PeterN commented Apr 21, 2024

Motivation / Problem

Station layouts may contain more than 8 different tile types, but due to hysterical reasons, only 8 tiles can be used and stored in the map on build.

Callback 24 exists which allows to choose the fixed layout dynamically but this is still limited to 8.

Using more than this requires using callback 14, which allows more (more than 256 even) but also requires complex calculations for each station tile to be drawn.

The technical limit that originally prevented using more than 8 tile layouts on the map was removed in 2007, in commit 3dd6362.

Description

Allow using up to 256 tile layouts in property 0E or callback 24, which defines the layout to be saved into the map.

This was originally limited to 8, because station graphics above 8 referred to other station types but that was changed in 2007.

  1. More efficient than using callback 14, as that needs to be checked every time a station tile is rendered.
  2. The layout does not get changed when the station is changed (this may or may not be desirable!)

Using more than 256 layouts still requires callback 14.

Limitations

Not actually tested as this requires skill at creating NewGRF stations...

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 touches english.txt or translations? Check the guidelines
  • 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, game_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')

…AYOUT.

These callbacks both select rail station tile layouts, the difference is one happens when drawing, the other happens when building. Change the names to make this clearer.
Using std::span provides both the start and end of the list, which allows validating that the requested layout is in range.
@frosch123
Copy link
Member

My understanding of station tiles was, they are mostly used to control pylons, wires, blocked.
How are these 3 things defined now?

@PeterN
Copy link
Member Author

PeterN commented Apr 21, 2024

Oh yes. That was the bit I was going to add but forgot about. Whoops!

The only reason for that's what "they are mostly used to control" is because with only 8 layouts there isn't flexibility to do much else.

Added new property 1E to define per-tile flags as a list.

…station.

Allow using up to 256 tile layouts in property 0E or callback 24, which defines the layout to be saved into the map.

This was originally limited to 8, because station graphics above 8 referred to other station types but that was changed in 2007.

1) More efficient than using callback 14, as that needs to be checked every time a station tile is rendered.
2) The layout does not get changed when the station is changed (this may or may not be desirable!)

Using more than 256 layouts still requires callback 14.
@PeterN PeterN changed the title Feature: Allow fixed layout up to 256 tiles per NewGRF rail station. Feature: [NewGRF] Allow fixed layout up to 256 tiles per NewGRF rail station. Apr 21, 2024
@PeterN PeterN added the needs review: NewGRF Review requested from a NewGRF expert label Apr 21, 2024
Properties 11, 14 and 15 to set pylons/nowires/blocked intrinsically only support 8 station tiles.

Add new property to define all three flags for each station tile layout.
@PeterN
Copy link
Member Author

PeterN commented Apr 22, 2024

An additional (but out of scope) idea that may be desirable is to automatically "rebuild" the layout if parts are over-built or removed, so it could behave as a semi-dynamic layout.

@PeterN PeterN marked this pull request as ready for review April 29, 2024 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs review: NewGRF Review requested from a NewGRF expert
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants