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 #8846: When upgrading NewGRF presets, copy NewGRF parameters only if the NewGRF are compatible. #11348

Merged
merged 2 commits into from Oct 2, 2023

Conversation

frosch123
Copy link
Member

Motivation / Problem

#8846

Description

When upgrading NewGRF the old parameters do not necessarily fit to the new version.

  • NewGRF specify a version and minimum-compatible-version for savegame-compatibility.
  • If a NewGRF changes or adds parameters with non-zero defaults, this is (currently) always a savegame-incompatible change. (parameters are not changed, when loading savegames/scenarios with compatible NewGRF)
  • However, there are other savegame-incompatible changes, which do not invalidate parameters.

As such, this PR is on the "annoying, but safe" side. When upgrading NewGRF:

  • parameters are only copied, if they are definitely compatible. (no false negatives)
  • parameters are reset to defaults, if they are potentially incompatible. (false positives exist)

Limitations

This PR does not implement #10549:

  • Upgrading NewGRFs in presets uses the same logic as finding compatible NewGRF for savegames/scenarios.
  • Detecting "new parameters" is not possible in all cases, if the original NewGRF is not present. (only if they use new registers at the end)

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

…rs only if the NewGRF are compatible. Otherwise reset to defaults.
Copy link
Member

@LordAro LordAro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems legit

@2TallTyler
Copy link
Member

Would this fix #10549 by refusing to upgrade those NewGRFs, assuming the NewGRF author has correctly marked the new version as incompatible? (I could be misunderstanding the use case involved in both that issue and this PR.)

@frosch123
Copy link
Member Author

frosch123 commented Oct 2, 2023

It would not "refuse" to upgrade them, but reset their configuration to "default parameters".

@frosch123 frosch123 merged commit 82c8720 into OpenTTD:master Oct 2, 2023
20 checks passed
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

4 participants