Skip to content

Commit

Permalink
Fix Talking Across Docked Grids (#593)
Browse files Browse the repository at this point in the history
# Description

#574 introduced a
bug whereby people who are each on separate grids, but the grids were
attached, could not talk to each other. I have corrected this by making
it so that when the Cross-Grid check is handled, it also checks to see
if the two different grids are JOINTed to each other. Therefore allowing
sound to travel across the connection. This should also work from
Shuttle To Planet, since it's also handled via the same system. This
means that docked shuttles allow sound to travel across to the docked
station(or other shuttle), as well as shuttles docked to a planet's
surface will permit sound to travel to the planet.

# Changelog

:cl:
- fix: Fixed a bug where sound was not traveling over a Shuttle-Docking
connection. Attached grids now permit sound to travel through.

---------

Signed-off-by: VMSolidus <[email protected]>
Co-authored-by: DEATHB4DEFEAT <[email protected]>
  • Loading branch information
VMSolidus and DEATHB4DEFEAT authored Jul 26, 2024
1 parent 634e933 commit ec76fb9
Showing 1 changed file with 22 additions and 2 deletions.
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

0 comments on commit ec76fb9

Please sign in to comment.