diff --git a/Content.Server/Chat/Systems/ChatSystem.cs b/Content.Server/Chat/Systems/ChatSystem.cs index 978fd206210..05342dbe3c0 100644 --- a/Content.Server/Chat/Systems/ChatSystem.cs +++ b/Content.Server/Chat/Systems/ChatSystem.cs @@ -33,11 +33,15 @@ using Robust.Shared.Configuration; using Robust.Shared.Console; using Robust.Shared.Network; +using Robust.Shared.Physics; using Robust.Shared.Player; using Robust.Shared.Prototypes; using Robust.Shared.Random; using Robust.Shared.Replays; using Robust.Shared.Utility; +using Content.Server.Shuttles.Components; +using Robust.Shared.Physics.Components; +using Robust.Shared.Physics.Dynamics.Joints; namespace Content.Server.Chat.Systems; @@ -510,7 +514,8 @@ private void SendEntityWhisper( if (session.AttachedEntity is not { Valid: true } listener) continue; - if (Transform(session.AttachedEntity.Value).GridUid != Transform(source).GridUid) + if (Transform(session.AttachedEntity.Value).GridUid != Transform(source).GridUid + && !CheckAttachedGrids(source, session.AttachedEntity.Value)) continue; if (MessageRangeCheck(session, data, range) != MessageRangeCheckResult.Full) @@ -743,7 +748,9 @@ private void SendInVoiceRange(ChatChannel channel, string name, string message, var language = languageOverride ?? _language.GetLanguage(source); foreach (var (session, data) in GetRecipients(source, Transform(source).GridUid == null ? 0.3f : VoiceRange)) { - if (session.AttachedEntity != null && Transform(session.AttachedEntity.Value).GridUid != Transform(source).GridUid) + if (session.AttachedEntity != null + && Transform(session.AttachedEntity.Value).GridUid != Transform(source).GridUid + && !CheckAttachedGrids(source, session.AttachedEntity.Value)) continue; var entRange = MessageRangeCheck(session, data, range); @@ -973,6 +980,19 @@ public string BuildGibberishString(IReadOnlyList charOptions, int length) return sb.ToString(); } + private bool CheckAttachedGrids(EntityUid source, EntityUid receiver) + { + if (!TryComp(Transform(source).GridUid, out var sourceJoints) + || !TryComp(Transform(receiver).GridUid, out var receiverJoints)) + return false; + + foreach (var (id, _) in sourceJoints.GetJoints) + if (receiverJoints.GetJoints.ContainsKey(id)) + return true; + + return false; + } + #endregion }