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: [Network] clients leaving because of broken connections was not broadcasted #9238

Merged
merged 1 commit into from May 11, 2021

Conversation

TrueBrain
Copy link
Member

@TrueBrain TrueBrain commented May 11, 2021

During play-testing we found that if a client crashes (looking at your client @LordAro :P), only the server knew the client left. When he returned, there were two people with the same name, triggering a panic that our code is buggy.

In a sense, it is, but not in the way people were thinking :P

Motivation / Problem

The code mixed up "client has quit but we already told everyone"
with "client lost connection, handle this".

Split up those two signals:
- CLIENT_QUIT means we told everyone and the connection is now dead
- CONNECTION_LIST means we should tell everyone we lost a client

To put it in different words:
https://github.com/OpenTTD/OpenTTD/blob/release/1.11/src/network/core/tcp_game.cpp#L54 is called when a connection is lost. It calls https://github.com/OpenTTD/OpenTTD/blob/release/1.11/src/network/network_server.cpp#L269 which said: owh, this status code? That means the clients were already informed! And didn't tell anyone about the loss of client.

Description

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

…broadcasted

The code mixed up "client has quit but we already told everyone"
with "client lost connection, handle this".

Split up those two signals:
- CLIENT_QUIT means we told everyone and the connection is now dead
- CONNECTION_LIST means we should tell everyone we lost a client
@TrueBrain TrueBrain merged commit 36e22f3 into OpenTTD:master May 11, 2021
@TrueBrain TrueBrain deleted the fix-connection-lost branch May 11, 2021 10:26
@LordAro LordAro mentioned this pull request Jul 12, 2021
@glx22 glx22 added the backport requested This PR should be backport to current release (RC / stable) label Jul 12, 2021
@TrueBrain TrueBrain removed the backport requested This PR should be backport to current release (RC / stable) label Oct 3, 2021
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