diff --git a/Content.Client/Medical/CrewMonitoring/CrewMonitoringWindow.xaml.cs b/Content.Client/Medical/CrewMonitoring/CrewMonitoringWindow.xaml.cs
index 46ad6a56bc..96a029603c 100644
--- a/Content.Client/Medical/CrewMonitoring/CrewMonitoringWindow.xaml.cs
+++ b/Content.Client/Medical/CrewMonitoring/CrewMonitoringWindow.xaml.cs
@@ -112,7 +112,7 @@ namespace Content.Client.Medical.CrewMonitoring
if (sensor.Coordinates != null && NavMap.Visible)
{
- NavMap.TrackedCoordinates.Add(sensor.Coordinates.Value, (true, Color.FromHex("#B02E26")));
+ NavMap.TrackedCoordinates.TryAdd(sensor.Coordinates.Value, (true, Color.FromHex("#B02E26")));
nameLabel.MouseFilter = MouseFilterMode.Stop;
// Hide all others upon mouseover.
diff --git a/Content.Server/DeviceNetwork/Systems/StationLimitedNetworkSystem.cs b/Content.Server/DeviceNetwork/Systems/StationLimitedNetworkSystem.cs
index cdcc37e569..675cacc4d7 100644
--- a/Content.Server/DeviceNetwork/Systems/StationLimitedNetworkSystem.cs
+++ b/Content.Server/DeviceNetwork/Systems/StationLimitedNetworkSystem.cs
@@ -30,6 +30,18 @@ namespace Content.Server.DeviceNetwork.Systems
component.StationId = stationId;
}
+ ///
+ /// Tries to set the station id to the current station if the device is currently on a station
+ ///
+ public bool TrySetStationId(EntityUid uid, StationLimitedNetworkComponent? component = null)
+ {
+ if (!Resolve(uid, ref component) || !Transform(uid).GridUid.HasValue)
+ return false;
+
+ component.StationId = _stationSystem.GetOwningStation(uid);
+ return component.StationId.HasValue;
+ }
+
///
/// Set the station id to the one the entity is on when the station limited component is added
///
@@ -43,6 +55,9 @@ namespace Content.Server.DeviceNetwork.Systems
///
private void OnBeforePacketSent(EntityUid uid, StationLimitedNetworkComponent component, BeforePacketSentEvent args)
{
+ if (!component.StationId.HasValue)
+ TrySetStationId(uid, component);
+
if (!CheckStationId(args.Sender, component.AllowNonStationPackets, component.StationId))
{
args.Cancel();
@@ -62,6 +77,9 @@ namespace Content.Server.DeviceNetwork.Systems
if (!Resolve(senderUid, ref sender, false))
return allowNonStationPackets;
+ if (!sender.StationId.HasValue)
+ TrySetStationId(senderUid, sender);
+
return sender.StationId == receiverStationId;
}
}
diff --git a/Content.Server/Medical/SuitSensors/SuitSensorSystem.cs b/Content.Server/Medical/SuitSensors/SuitSensorSystem.cs
index 821a7065d4..5f8b5954b2 100644
--- a/Content.Server/Medical/SuitSensors/SuitSensorSystem.cs
+++ b/Content.Server/Medical/SuitSensors/SuitSensorSystem.cs
@@ -60,13 +60,16 @@ namespace Content.Server.Medical.SuitSensors
while (sensors.MoveNext(out var uid, out var sensor, out var device))
{
- if (device.TransmitFrequency is null || !sensor.StationId.HasValue)
+ if (device.TransmitFrequency is null)
continue;
// check if sensor is ready to update
if (curTime < sensor.NextUpdate)
continue;
+ if (!CheckSensorAssignedStation(uid, sensor))
+ continue;
+
// TODO: This would cause imprecision at different tick rates.
sensor.NextUpdate = curTime + sensor.UpdateRate;
@@ -78,7 +81,7 @@ namespace Content.Server.Medical.SuitSensors
//Retrieve active server address if the sensor isn't connected to a server
if (sensor.ConnectedServer == null)
{
- if (!_monitoringServerSystem.TryGetActiveServerAddress(sensor.StationId.Value, out var address))
+ if (!_monitoringServerSystem.TryGetActiveServerAddress(sensor.StationId!.Value, out var address))
continue;
sensor.ConnectedServer = address;
@@ -98,6 +101,20 @@ namespace Content.Server.Medical.SuitSensors
}
}
+ ///
+ /// Checks whether the sensor is assigned to a station or not
+ /// and tries to assign an unassigned sensor to a station if it's currently on a grid
+ ///
+ /// True if the sensor is assigned to a station or assigning it was successful. False otherwise.
+ private bool CheckSensorAssignedStation(EntityUid uid, SuitSensorComponent sensor)
+ {
+ if (!sensor.StationId.HasValue && Transform(uid).GridUid == null)
+ return false;
+
+ sensor.StationId = _stationSystem.GetOwningStation(uid);
+ return sensor.StationId.HasValue;
+ }
+
private void OnPlayerSpawn(PlayerSpawnCompleteEvent ev)
{
// If the player spawns in arrivals then the grid underneath them may not be appropriate.