Fix: crash when not passing parameter for -n #11153
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 fornullptr
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.