Always update client's name on connect

Since the client variable would be changed in a reconnect, the name is not set on the old client object.
This commit is contained in:
Sanae 2022-07-27 14:00:58 -06:00 committed by GitHub
parent db05586dd0
commit 66114bdecb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -170,7 +170,6 @@ public class Server {
ConnectPacket connect = new ConnectPacket();
connect.Deserialize(memory.Memory.Span[packetRange]);
lock (Clients) {
client.Name = connect.ClientName;
if (Clients.Count(x => x.Connected) == Settings.Instance.Server.MaxPlayers) {
client.Logger.Error($"Turned away as server is at max clients");
memory.Dispose();
@ -212,6 +211,7 @@ public class Server {
throw new Exception($"Invalid connection type {connect.ConnectionType}");
}
client.Name = connect.ClientName;
client.Connected = true;
if (firstConn) {
// do any cleanup required when it comes to new clients
@ -313,4 +313,4 @@ public class Server {
header.Deserialize(data[..Constants.HeaderSize]);
return header;
}
}
}