]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Intercoms and Radios both pick up proximate speech (#32737)
authorCentronias <me@centronias.com>
Sat, 2 Nov 2024 15:04:22 +0000 (08:04 -0700)
committerGitHub <noreply@github.com>
Sat, 2 Nov 2024 15:04:22 +0000 (16:04 +0100)
* Deduping of recent messages should consider the channel it's being sent to

* rerun actions

Content.Server/Radio/EntitySystems/RadioDeviceSystem.cs

index c8867744a40b6b9fd33eb71defc03810d7e86873..3829fc34d20870b8bfcb848bf57a56b242c4f013 100644 (file)
@@ -30,7 +30,7 @@ public sealed class RadioDeviceSystem : EntitySystem
     [Dependency] private readonly SharedAppearanceSystem _appearance = default!;
 
     // Used to prevent a shitter from using a bunch of radios to spam chat.
-    private HashSet<(string, EntityUid)> _recentlySent = new();
+    private HashSet<(string, EntityUid, RadioChannelPrototype)> _recentlySent = new();
 
     public override void Initialize()
     {
@@ -114,7 +114,7 @@ public sealed class RadioDeviceSystem : EntitySystem
     {
         if (args.Powered)
             return;
-        SetMicrophoneEnabled(uid, null, false,  true, component);
+        SetMicrophoneEnabled(uid, null, false, true, component);
     }
 
     public void SetMicrophoneEnabled(EntityUid uid, EntityUid? user, bool enabled, bool quiet = false, RadioMicrophoneComponent? component = null)
@@ -191,8 +191,9 @@ public sealed class RadioDeviceSystem : EntitySystem
         if (HasComp<RadioSpeakerComponent>(args.Source))
             return; // no feedback loops please.
 
-        if (_recentlySent.Add((args.Message, args.Source)))
-            _radio.SendRadioMessage(args.Source, args.Message, _protoMan.Index<RadioChannelPrototype>(component.BroadcastChannel), uid);
+        var channel = _protoMan.Index<RadioChannelPrototype>(component.BroadcastChannel)!;
+        if (_recentlySent.Add((args.Message, args.Source, channel)))
+            _radio.SendRadioMessage(args.Source, args.Message, channel, uid);
     }
 
     private void OnAttemptListen(EntityUid uid, RadioMicrophoneComponent component, ListenAttemptEvent args)
@@ -279,7 +280,7 @@ public sealed class RadioDeviceSystem : EntitySystem
         if (TryComp<RadioMicrophoneComponent>(ent, out var mic))
             mic.BroadcastChannel = channel;
         if (TryComp<RadioSpeakerComponent>(ent, out var speaker))
-            speaker.Channels = new(){ channel };
+            speaker.Channels = new() { channel };
         Dirty(ent);
     }
 }