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: server's client is shown incorrectly in some cases #12629

Merged
merged 2 commits into from May 5, 2024

Conversation

rubidium42
Copy link
Contributor

@rubidium42 rubidium42 commented May 5, 2024

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.

Tester Transport, 2035-01-01

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

  • Initialise the client's ci->client_playas always as spectator.
  • In OnGameStart call a new routine to properly initialise the ci->client_playas to the actually loaded company.
  • Move any network related things that should happen for game starts to this new routine, like opening the client list.
  • Call 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.

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

@rubidium42 rubidium42 added the backport requested This PR should be backport to current release (RC / stable) label May 5, 2024
src/network/network.cpp Fixed Show fixed Hide fixed
@rubidium42 rubidium42 force-pushed the network-server-client-state branch from 7ff8978 to 4d169a6 Compare May 5, 2024 19:00
@rubidium42 rubidium42 merged commit b9c894b into OpenTTD:master May 5, 2024
15 checks passed
@rubidium42 rubidium42 deleted the network-server-client-state branch May 5, 2024 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport requested This PR should be backport to current release (RC / stable)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants