From 66114bdecb3850c7b55b06b8349c413bd6b6a626 Mon Sep 17 00:00:00 2001 From: Sanae <32604996+Sanae6@users.noreply.github.com> Date: Wed, 27 Jul 2022 14:00:58 -0600 Subject: [PATCH] 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. --- Server/Server.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Server/Server.cs b/Server/Server.cs index dfe19cd..f312ea3 100644 --- a/Server/Server.cs +++ b/Server/Server.cs @@ -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; } -} \ No newline at end of file +}