Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Talking Across Docked Grids #593

Merged
merged 2 commits into from
Jul 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions Content.Server/Chat/Systems/ChatSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -973,6 +980,19 @@ public string BuildGibberishString(IReadOnlyList<char> charOptions, int length)
return sb.ToString();
}

private bool CheckAttachedGrids(EntityUid source, EntityUid receiver)
{
if (!TryComp<JointComponent>(Transform(source).GridUid, out var sourceJoints)
|| !TryComp<JointComponent>(Transform(receiver).GridUid, out var receiverJoints))
return false;

foreach (var (id, _) in sourceJoints.GetJoints)
if (receiverJoints.GetJoints.ContainsKey(id))
return true;

return false;
}

#endregion
}

Expand Down
Loading