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

Fix weirdness of new stations. #10017

Merged
merged 3 commits into from Sep 11, 2022

Conversation

frosch123
Copy link
Member

Motivation / Problem

I just wanted to document NML stations a bit, but got lost in weird corners cases of NML and OpenTTD.

Description

  • Callback 14 has some bugs in the GUI (but not on map)
    • Result bit 0 is supposed to be ignored and replaced with the orientation, but instead the orientaion was just added.
    • Var10 contains no data for callback 14. The GUI code passed the value intended for callback 24.
  • If stations defined exactly one sprite layout, both in-GUI and on-map drawing code would out-of-bounds access a vector.
    • This PR enforces an even number of spritelayouts when loading the NewGRF.
    • It does this by dropping the last layout. That way any NewGRF using an odd number of layouts is now equally broken for X and Y direction.

Limitations

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, gs_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')

The value 0x2110000 probably originated from a mixup between callback 14 (sprite layout) and 24 (tile layout).
The latter does indeed use a var10 value like that.
…te layouts.

The drawing code has a special fallbacks for zero layouts, but fails hard for one layout.
(odd numbers >= 3 are weird, but do not fail as badly as 1)
@frosch123 frosch123 merged commit e2c46fd into OpenTTD:master Sep 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants