From daea9eab7273cc1720244b64ef9e182d54f5fc87 Mon Sep 17 00:00:00 2001 From: AlexMorgan3817 <46600554+AlexMorgan3817@users.noreply.github.com> Date: Sun, 29 Jan 2023 18:32:08 +0000 Subject: [PATCH] Fix of PERSISTENT headsets (#13784) Closes https://github.com/space-wizards/space-station-14/issues/13783 --- .../Radio/EntitySystems/HeadsetSystem.cs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Content.Server/Radio/EntitySystems/HeadsetSystem.cs b/Content.Server/Radio/EntitySystems/HeadsetSystem.cs index f4b0585a30..de1fd66338 100644 --- a/Content.Server/Radio/EntitySystems/HeadsetSystem.cs +++ b/Content.Server/Radio/EntitySystems/HeadsetSystem.cs @@ -12,7 +12,6 @@ using Robust.Shared.Containers; using Robust.Shared.Network; using Robust.Shared.Prototypes; using System.Linq; -using Robust.Shared.Profiling; namespace Content.Server.Radio.EntitySystems; @@ -58,12 +57,13 @@ public sealed class HeadsetSystem : EntitySystem if (component.IsEquipped && component.Enabled) { EnsureComp(args.Equipee).Headset = uid; - PushRadioChannelsToOwner(uid, component, EnsureComp(uid)); + UpdateRadioChannelsInActiveRadio(uid, component, EnsureComp(uid)); } } - private void PushRadioChannelsToOwner(EntityUid uid, HeadsetComponent component, ActiveRadioComponent activeRadio) + private void UpdateRadioChannelsInActiveRadio(EntityUid uid, HeadsetComponent component, ActiveRadioComponent activeRadio) { + activeRadio.Channels.Clear(); activeRadio.Channels.UnionWith(component.Channels); } @@ -131,12 +131,7 @@ public sealed class HeadsetSystem : EntitySystem private bool InstallKey(HeadsetComponent component, EntityUid key, EncryptionKeyComponent keyComponent) { - if (component.KeyContainer.Insert(key)) - { - UploadChannelsFromKey(component, keyComponent); - return true; - } - return false; + return component.KeyContainer.Insert(key); } private void UploadChannelsFromKey(HeadsetComponent component, EncryptionKeyComponent key) @@ -225,7 +220,7 @@ public sealed class HeadsetSystem : EntitySystem { UpdateDefaultChannel(component); UploadChannelsFromKey(component, added); - PushRadioChannelsToOwner(uid, component, EnsureComp(uid)); + UpdateRadioChannelsInActiveRadio(uid, component, EnsureComp(uid)); } return; }