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

Change: Use default NewGRF cargo translation table. #12646

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

PeterN
Copy link
Member

@PeterN PeterN commented May 8, 2024

Motivation / Problem

When loading NewGRFs without cargo translation table, we have to check to see if we need to perform a bitnum lookup or just treat the slot as a climate dependent cargo type.

This requires multiple special cases, and always assumes that cargo slots are in their original positions, which is not always the case.

Description

Instead of falling back to bitnum lookup or climate-dependent cargo types, install a default cargo translation table that performs either of these functions instead.

A NewGRF can still install its own translation table and there will be no change in this case.

This allows better mapping of climate-dependent or bitnum cargo slots, falling back to INVALID_CARGO if they are not defined, and reduces special-casing.

Because everything is now mapped via label, this should allow cargo types to be moved to different slots (as is permitted for default vehicles/houses/industries and anything that installs its own translation table.)

Limitations

Well...

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')

@PeterN PeterN added the preview This PR is receiving preview builds label May 8, 2024
src/newgrf.cpp Outdated Show resolved Hide resolved
src/newgrf.cpp Outdated Show resolved Hide resolved
Instead of falling back to bitnum lookup or climate-dependent cargo types, install a default cargo translation table that performs either of these functions instead.

This allows better mapping of climate-dependent or bitnum cargo slots, falling back to INVALID_CARGO if they are not defined, and reduces special-casing.
@PeterN
Copy link
Member Author

PeterN commented May 9, 2024

This goes against the spec when it comes to very old NewGRFs that deal with custom cargoes before labels were a thing.

Not sure how many of those exist, nor how many are still used, as compatibility is already hit & miss.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preview This PR is receiving preview builds
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants