More fixes

This commit is contained in:
Bandwidth
2026-04-27 22:36:06 +02:00
parent 53a10f9196
commit 19242d51ae
2 changed files with 30 additions and 0 deletions

View File

@@ -332,6 +332,15 @@ public class Program
static async Task HandleCreateLobbyAsync(ConnectedClient client, CreateLobby message)
{
// If the client supplied a fresh display name on the create call,
// adopt it as the connection's authoritative name. ClientHello-time
// names are stale because the handshake fires before the user has
// had a chance to type into the nickname field; without this
// override the server records the user as the prefab default
// ("Hrac") even when they typed a real name.
if (!string.IsNullOrWhiteSpace(message.DisplayName))
client.DisplayName = message.DisplayName.Trim();
var (lobby, joinCode, error) = await _lobbyManager.CreateLobbyAsync(
client.ClientUuid, client.DisplayName, message);
@@ -360,6 +369,11 @@ public class Program
static async Task HandleJoinLobbyAsync(ConnectedClient client, JoinLobby message)
{
// Mirror of HandleCreateLobbyAsync: adopt the freshly-typed name if
// the client supplied one. See that method's comment for rationale.
if (!string.IsNullOrWhiteSpace(message.DisplayName))
client.DisplayName = message.DisplayName.Trim();
var clientIp = client.Endpoint.Split(':')[0];
var (lobby, error) = await _lobbyManager.JoinLobbyAsync(
clientIp, client.ClientUuid, client.DisplayName, message.JoinCode, message.Password);