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 #11137: assertion failure due to interpreting string as number #11138

Merged
merged 2 commits into from Jul 15, 2023

Conversation

rubidium42
Copy link
Contributor

Motivation / Problem

Fixed #11137.
When searching for a setting only the first global string parameter is set with STR_EMPTY and then the string is resolved. However, there are two strings that, using {P 0:2 "" s}, attempt to access the second global string parameter. When that second global string parameter was last set as a string, then the assertion trigger that it attempts to interpret a string as a number.

Description

There is a STR_CONFIG_SETTING_ERRMSG_DURATION_VALUE which already has essentially the same content as what would be needed for the value for the two other settings. So rename it to a more generic STR_CONFIG_SETTING_SECONDS_VALUE and use that for the three settings that specifically mention a number of seconds in their setting, and remove the unit of seconds from the setting description.

Since it is the settingn description string that (also) refers to the second global string parameter, just solving it in english.txt will mean the bug can still be triggered for other languages. As such there is a second patch that removes those strings from the translations, as in this case an outdated string is worse than an untranslated string.

Limitations

There could be other instances of similar assertions. They were added to figure out such inconsistent use, and it seems to have worked. With release builds it will just return 0 instead of assert though.

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

@rubidium42 rubidium42 merged commit bfbdaf8 into OpenTTD:master Jul 15, 2023
19 checks passed
@rubidium42 rubidium42 deleted the fix-11137 branch July 15, 2023 04:33
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.

[Bug]: Assertion failure when using settings filter
3 participants