0
0
Fork 0
mirror of https://github.com/Sanae6/SmoOnlineServer.git synced 2024-11-21 18:55:17 +00:00

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

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;
}
}
}