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

Codechange: remove unused strings #9516

Merged
merged 1 commit into from
Aug 28, 2021

Conversation

TrueBrain
Copy link
Member

@TrueBrain TrueBrain commented Aug 28, 2021

Motivation / Problem

I assumed we had strings that were no longer used in our language files, as it is pretty easy to miss this. We do not validate if strings are used.

After trying to write some scripting to figure out if this is the case, I ended up figuring out how poorly we name our strings, and the weird hacks we have to reference a string.

For example, the setting-flag "zero-is-special" uses the next string after the "value" string. In other words, this special string is not referenced directly, but you have to calculate that based on another.

And it is not always in the forward direction. You can say you want to draw a "tiny" variant of a string, which is "- 1" from the original string.

After fiddling a while with a script I wrote, I finally managed to get through all the strings, and detect which are unused. Another PR will upstream that script, so we can link it to the CI, but for now, first a bit of cleanup.

Description

Removing string is tricky, as it is hard to tell if they really aren't used. So I have been doing some digging, but please confirm my findings:

  • STR_GAME_OPTIONS_REFRESH_RATE_OTHER: introduced in 0464a50, but no reference to the string is being made.
  • STR_CONFIG_SETTING_DISABLE_UNSUITABLE_BUILDING: removed in 188bf0f.
  • STR_NETWORK_SERVER_LIST_LANGUAGE: removed in 05612d6.
  • STR_NETWORK_START_SERVER_LANGUAGE_SPOKEN and friend: removed in 05612d6.
  • STR_NETWORK_SERVER and STR_NETWORK_CLIENT: removed in 5266359.
  • STR_NETWORK_ERROR_NNN: no specific commits, but none of those are referenced indirectly from what I can tell, so it is fairly safe to assume they got removed "over time".
  • STR_CONTENT_ERROR_COULD_NOT_DOWNLOAD_CONNECTION_LOST: removed in eeb38a8.
  • STR_FRAMERATE_BYTES_WARN and friend: seems to be added to complete the list, but actually never used (see e7f6f07).
  • STR_NEWGRF_SETTINGS_PRESET_SAVE_QUERY: replaced with another window, never removed (see 8755c26).
  • STR_STATION_VIEW_EN_ROUTE_FROM: removed in 0fc198c.
  • STR_VEHICLE_NAME_BUTTON: removed in 589feba.
  • STR_ERROR_INCOMPATIBLE_TRAMWAY: introduced in c02ef3e, but no reference to the string is being made.

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

@glx22
Copy link
Contributor

glx22 commented Aug 28, 2021

Seems correct, but I prefer to wait for a third person confirmation :)

@TrueBrain TrueBrain merged commit 13b53e1 into OpenTTD:master Aug 28, 2021
@TrueBrain TrueBrain deleted the remove-unused-strings branch August 28, 2021 19:09
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

3 participants