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 #9008: Validate starting year given on the command line. #9014

Merged
merged 1 commit into from Apr 11, 2021

Conversation

rubidium42
Copy link
Contributor

Motivation / Problem

See #9008. The validation on settings should also apply on settings passed through the command line.

Description

The issue is solved by using IConsoleSetSetting, which performs validation and clamping if required, instead of writing the variable directly.

Limitations

It is now using a hard coded string, so any change to the setting name will not break the compilation of the code. It will break the -t command line functionality with an assertion even when the input value is valid, so it ought to be caught relatively quickly.

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.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')

…ting year

causing all sorts of weird behaviour and crashes in map generation.

Now just set the appropriate setting via IConsoleSetSetting so the validation
and, if needed, clamping is performed on the starting year value.
@LordAro LordAro added the backport requested This PR should be backport to current release (RC / stable) label Apr 11, 2021
Copy link
Member

@michicc michicc left a comment

Choose a reason for hiding this comment

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

Commit message to be shortened in post 😄

@michicc michicc changed the title Fix #9008: no validation is performed on the command line starting year causing all sorts of weird behaviour and crashes in map generation. Fix #9008: Validate starting year given on the command line. Apr 11, 2021
@michicc michicc merged commit df045b9 into OpenTTD:master Apr 11, 2021
@rubidium42 rubidium42 deleted the issue-9008 branch April 11, 2021 12:11
LordAro pushed a commit to LordAro/OpenTTD that referenced this pull request Apr 17, 2021
…penTTD#9014)

An invalid starting year causes all sorts of weird behaviour and crashes in map generation.

Now just set the appropriate setting via IConsoleSetSetting so the validation
and, if needed, clamping is performed on the starting year value.
LordAro pushed a commit that referenced this pull request Apr 18, 2021
An invalid starting year causes all sorts of weird behaviour and crashes in map generation.

Now just set the appropriate setting via IConsoleSetSetting so the validation
and, if needed, clamping is performed on the starting year value.
@LordAro LordAro added backported This PR is backported to a current release (RC / stable) and removed backport requested This PR should be backport to current release (RC / stable) labels Apr 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backported This PR is backported to a current release (RC / stable)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants