Files
sbox-public/engine/Sandbox.Engine/Systems/Networking/PlayerInfo/UserInfo.cs
Matt Stevens ceaf03d2a7 Connection name fixes (#4950)
* Servers get the player's name through handshake again, clients resolve using Steam
* Connection.Name formalized and no longer a mismatch of virtual overrides
* Connection.DisplayName now filters text using Steam settings
* Local instances set random name outside of networking code
* Used Connection.Name instead of Connection.DisplayName where it makes sense throughout the engine
* Join / leave messages are pushed to chat at a platform level
* Removed some overly verbose connection logs
2026-05-28 14:39:37 +00:00

48 lines
1.2 KiB
C#

namespace Sandbox;
[Expose]
internal struct UserInfo
{
public SteamId SteamId { get; set; }
public string Name { get; set; }
public DateTimeOffset ConnectionTime { get; set; }
public Dictionary<string, string> UserData { get; set; }
public int EngineVersion { get; internal set; }
public SteamId PartyId { get; internal set; }
public byte[] AuthTicket { get; set; }
public Guid HandshakeId { get; set; }
public bool IsVr { get; set; }
public byte[] InventoryBlob { get; set; }
/// <summary>
/// Build info for the local user, which will then get sent to the server and possibly shared between all clients
/// </summary>
internal static UserInfo Local
{
get
{
var ui = new UserInfo
{
ConnectionTime = DateTime.UtcNow,
SteamId = Utility.Steam.SteamId,
Name = Utility.Steam.PersonaName,
EngineVersion = Engine.Protocol.Network,
UserData = new(),
PartyId = PartyRoom.Current?.Id ?? new( 0 ),
IsVr = VR.VRSystem.IsActive,
InventoryBlob = Services.Inventory.CurrentBlob
};
//
// Put all the userinfo vars in
//
foreach ( var convar in ConVarSystem.Members.Values.Where( x => x.IsUserInfo ) )
{
ui.UserData[convar.Name] = convar.Value;
}
return ui;
}
}
}