From 711c8715bc68e1098cf8ee7fab8351f8157094e0 Mon Sep 17 00:00:00 2001 From: VMSolidus Date: Wed, 24 Jul 2024 20:34:34 -0400 Subject: [PATCH 1/2] Fix Talking To Attached Shuttles --- Content.Server/Chat/Systems/ChatSystem.cs | 24 +++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/Content.Server/Chat/Systems/ChatSystem.cs b/Content.Server/Chat/Systems/ChatSystem.cs index 978fd206210..0854276d0b7 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,8 @@ 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 +979,20 @@ 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 } From 1cc4b13eab261a60fc5ef16144104aea9b5953b3 Mon Sep 17 00:00:00 2001 From: VMSolidus Date: Wed, 24 Jul 2024 21:39:06 -0400 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: DEATHB4DEFEAT <77995199+DEATHB4DEFEAT@users.noreply.github.com> Signed-off-by: VMSolidus --- Content.Server/Chat/Systems/ChatSystem.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Content.Server/Chat/Systems/ChatSystem.cs b/Content.Server/Chat/Systems/ChatSystem.cs index 0854276d0b7..05342dbe3c0 100644 --- a/Content.Server/Chat/Systems/ChatSystem.cs +++ b/Content.Server/Chat/Systems/ChatSystem.cs @@ -748,7 +748,8 @@ 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; @@ -986,10 +987,9 @@ private bool CheckAttachedGrids(EntityUid source, EntityUid receiver) return false; foreach (var (id, _) in sourceJoints.GetJoints) - { if (receiverJoints.GetJoints.ContainsKey(id)) return true; - } + return false; }