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: crash when not passing parameter for -n #11153

Merged
merged 2 commits into from
Aug 12, 2023

Conversation

rubidium42
Copy link
Contributor

@rubidium42 rubidium42 commented Jul 25, 2023

Motivation / Problem

Run openttd -n -> crash.

Description

The crash happens for at least two years. However, practically this command line parameter has been broken since its introduction. It proclaimed to have an optional parameter, but later checking for it to be nullptr or not. Actually, in the begin it also set a boolean, which it checked first before checking for nullptr at the later location. In other words, even though it said the parameter is optional, it has never been optional if you wanted to get into that functionality.

So, I made the parameter non-optional (line 475).

Also looking at the comment/help message, there is no requirement for passing an IP-address, just a hostname is good enough. So I took the 'host' labelling from the man page.
Since the man page needed to be updated anyhow, I added the other missing parameters to it, renamed player to company (a change from a decade or more ago) and updated the date.

Limitations

Not really. Unless you consider openttd -n now showing the help message and exiting as a deviation from the pre 12 behaviour. Since 12 it crashes to desktop though, so I do not think it's a real problem.

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

TrueBrain
TrueBrain previously approved these changes Aug 11, 2023
docs/openttd.6 Outdated Show resolved Hide resolved
@rubidium42 rubidium42 merged commit 40195e6 into OpenTTD:master Aug 12, 2023
20 checks passed
@rubidium42 rubidium42 deleted the _-n_crashes branch September 6, 2023 21: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

2 participants