diff --git a/OpenDreamRuntime/DreamConnection.cs b/OpenDreamRuntime/DreamConnection.cs index 760def1828..e92755f6fc 100644 --- a/OpenDreamRuntime/DreamConnection.cs +++ b/OpenDreamRuntime/DreamConnection.cs @@ -29,8 +29,9 @@ public sealed class DreamConnection { [ViewVariables] public ICommonSession? Session { get; private set; } [ViewVariables] public DreamObjectClient? Client { get; private set; } - [ViewVariables] - public DreamObjectMob? Mob { + [ViewVariables] public string Key { get; private set; } + + [ViewVariables] public DreamObjectMob? Mob { get => _mob; set { if (_mob != value) { @@ -61,8 +62,7 @@ public DreamObjectMob? Mob { } } - [ViewVariables] - public DreamObjectMovable? Eye { + [ViewVariables] public DreamObjectMovable? Eye { get => _eye; set { _eye = value; @@ -93,8 +93,9 @@ public string? SelectedStatPanel { } } - public DreamConnection() { + public DreamConnection(string key) { IoCManager.InjectDependencies(this); + Key = key; _entitySystemManager.TryGetEntitySystem(out _screenOverlaySystem); _entitySystemManager.TryGetEntitySystem(out _clientImagesSystem); diff --git a/OpenDreamRuntime/DreamManager.Connections.cs b/OpenDreamRuntime/DreamManager.Connections.cs index c3c6929016..0c79b2389b 100644 --- a/OpenDreamRuntime/DreamManager.Connections.cs +++ b/OpenDreamRuntime/DreamManager.Connections.cs @@ -256,7 +256,7 @@ private void OnPlayerStatusChanged(object? sender, SessionStatusEventArgs e) { case SessionStatus.InGame: { if (!_connections.TryGetValue(e.Session.UserId, out var connection)) { - connection = new DreamConnection(); + connection = new DreamConnection(e.Session.Name); _connections.Add(e.Session.UserId, connection); } diff --git a/OpenDreamRuntime/Objects/DreamObject.cs b/OpenDreamRuntime/Objects/DreamObject.cs index 14d030aa3b..cfa73be66b 100644 --- a/OpenDreamRuntime/Objects/DreamObject.cs +++ b/OpenDreamRuntime/Objects/DreamObject.cs @@ -344,7 +344,7 @@ public string GetDisplayName(StringFormatEncoder.FormatSuffix? suffix = null) { // /client is a little special and will return its key var // TODO: Maybe this should be an override to GetDisplayName()? if (this is DreamObjectClient client) - return client.Connection.Session!.Name; + return client.Connection.Key; var name = GetRawName(); bool isProper = StringIsProper(name); diff --git a/OpenDreamRuntime/Objects/Types/DreamObjectClient.cs b/OpenDreamRuntime/Objects/Types/DreamObjectClient.cs index 55b944f0fc..320c5d3b4a 100644 --- a/OpenDreamRuntime/Objects/Types/DreamObjectClient.cs +++ b/OpenDreamRuntime/Objects/Types/DreamObjectClient.cs @@ -41,10 +41,10 @@ protected override void HandleDeletion(bool possiblyThreaded) { protected override bool TryGetVar(string varName, out DreamValue value) { switch (varName) { case "ckey": - value = new(DreamProcNativeHelpers.Ckey(Connection.Session!.Name)); + value = new(DreamProcNativeHelpers.Ckey(Connection.Key)); return true; case "key": - value = new(Connection.Session!.Name); + value = new(Connection.Key); return true; case "mob": value = new(Connection.Mob); @@ -68,7 +68,7 @@ protected override bool TryGetVar(string varName, out DreamValue value) { MD5 md5 = MD5.Create(); // Check on Robust.Shared.Network.NetUserData.HWId" if you want to seed from how RT does user identification. // We don't use it here because it is probably not enough to ensure security, and (as of time of writing) only works on Windows machines. - byte[] brown = Encoding.UTF8.GetBytes(Connection.Session!.Name); + byte[] brown = Encoding.UTF8.GetBytes(Connection.Key); byte[] hash = md5.ComputeHash(brown); string hashStr = BitConverter.ToString(hash).Replace("-", "").ToLower().Substring(0,15); // Extracting the first 15 digits to ensure it'll fit in a 64-bit number diff --git a/OpenDreamRuntime/Objects/Types/DreamObjectMob.cs b/OpenDreamRuntime/Objects/Types/DreamObjectMob.cs index 30fc7e79bd..ae5d9876d3 100644 --- a/OpenDreamRuntime/Objects/Types/DreamObjectMob.cs +++ b/OpenDreamRuntime/Objects/Types/DreamObjectMob.cs @@ -82,13 +82,12 @@ protected override void SetVar(string varName, DreamValue value) { Key = DreamProcNativeHelpers.Ckey(Key); foreach (var connection in DreamManager.Connections) { - if (DreamProcNativeHelpers.Ckey(connection.Session!.Name) == Key) { + if (DreamProcNativeHelpers.Ckey(connection.Key) == Key) { connection.Mob = this; break; } } - break; case "see_invisible": value.TryGetValueAsInteger(out int seeVis);