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

Lobby player count is not updated correctly when a player leaves #32926

Open
youtissoum opened this issue Oct 20, 2024 · 2 comments · May be fixed by space-wizards/RobustToolbox#5500
Open

Lobby player count is not updated correctly when a player leaves #32926

youtissoum opened this issue Oct 20, 2024 · 2 comments · May be fixed by space-wizards/RobustToolbox#5500
Labels
S: Untriaged Status: Indicates an item has not been triaged and doesn't have appropriate labels.

Comments

@youtissoum
Copy link
Contributor

Description

When a player leaves the server, the player count gets updated to the value from before the player disconnected.

Reproduction

  1. Start a server and two clients
  2. Join the server with both clients and go to the lobby
  3. Disconnect one of the clients
  4. Player count still shows 2 players online

Screenshots

2024-10-20.12-08-47.mp4

Additional context

@github-actions github-actions bot added the S: Untriaged Status: Indicates an item has not been triaged and doesn't have appropriate labels. label Oct 20, 2024
@benev0
Copy link
Contributor

benev0 commented Oct 21, 2024

Further findings with more clients I was able to find that the lobby count does update on DC, but lags behind by one count.

@benev0
Copy link
Contributor

benev0 commented Oct 21, 2024

RT:SharedPlayerManager:PlayerStatusChanged is invoked before RT:SharedPlayerManager:RemoveSession is called

From RT-Server:PlayerManager:

/// <summary>
///     Ends a clients session, and disconnects them.
/// </summary>
internal void EndSession(NetUserId user)
{
    if (!TryGetSessionById(user, out var session))
        return;

    SetStatus(session, SessionStatus.Disconnected); // invokes PlayerStatusChanged
    SetAttachedEntity(session, null, out _, true);

    var viewSys = EntManager.System<ViewSubscriberSystem>();
    foreach (var eye in session.ViewSubscriptions.ToArray())
    {
        viewSys.RemoveViewSubscriber(eye, session);
    }

    RemoveSession(session.UserId); // session is removed causing change in variable used
    PlayerCountMetric.Set(PlayerCount); // not relevant
    Dirty();
}

PlayerStatusChanged is the event (CS) which formats and updates the serverInfo message by calling the function UpdateInfoText() which fires the networked event (RT) TickerLobbyInfoEvent to clients.

the content of server info (player count) is defined by InternalSessions which is altered by SharedPlayerManager:RemoveSession which as seen here is updated after the player count is used thus lagging the count by 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S: Untriaged Status: Indicates an item has not been triaged and doesn't have appropriate labels.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants