Fix: server's client is shown incorrectly in some cases #12629
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
Create a save that has companies, but no company with id 0. Start a server from the GUI and load this save. The client will now play as company with id 1, but be shown as an invalid company in the client list. In other words
ci->client_playas
is incorrect.Tangentially related to this, if you load a scenario or save, the client list won't be opened. It will open the client list for a new game and heightmap though. Similarly when loading saves the restart timer won't be reset, so if you prepare saves for your server the restart times becomes non-functional.
Furthermore, new companies in network games get their company named by the client. Except for server games, where this does not happen.
Description
ci->client_playas
always as spectator.OnGameStart
call a new routine to properly initialise theci->client_playas
to the actually loaded company.NetworkServerNewCompany
when the company created for the server is still unnamed.Limitations
Checklist for review
Some things are not automated, and forgotten often. This list is a reminder for the reviewers.