Fix station limited devices station assignment (#16893)
Fix error in crew monitor window
This commit is contained in:
@@ -112,7 +112,7 @@ namespace Content.Client.Medical.CrewMonitoring
|
|||||||
|
|
||||||
if (sensor.Coordinates != null && NavMap.Visible)
|
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;
|
nameLabel.MouseFilter = MouseFilterMode.Stop;
|
||||||
|
|
||||||
// Hide all others upon mouseover.
|
// Hide all others upon mouseover.
|
||||||
|
|||||||
@@ -30,6 +30,18 @@ namespace Content.Server.DeviceNetwork.Systems
|
|||||||
component.StationId = stationId;
|
component.StationId = stationId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tries to set the station id to the current station if the device is currently on a station
|
||||||
|
/// </summary>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set the station id to the one the entity is on when the station limited component is added
|
/// Set the station id to the one the entity is on when the station limited component is added
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -43,6 +55,9 @@ namespace Content.Server.DeviceNetwork.Systems
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void OnBeforePacketSent(EntityUid uid, StationLimitedNetworkComponent component, BeforePacketSentEvent args)
|
private void OnBeforePacketSent(EntityUid uid, StationLimitedNetworkComponent component, BeforePacketSentEvent args)
|
||||||
{
|
{
|
||||||
|
if (!component.StationId.HasValue)
|
||||||
|
TrySetStationId(uid, component);
|
||||||
|
|
||||||
if (!CheckStationId(args.Sender, component.AllowNonStationPackets, component.StationId))
|
if (!CheckStationId(args.Sender, component.AllowNonStationPackets, component.StationId))
|
||||||
{
|
{
|
||||||
args.Cancel();
|
args.Cancel();
|
||||||
@@ -62,6 +77,9 @@ namespace Content.Server.DeviceNetwork.Systems
|
|||||||
if (!Resolve(senderUid, ref sender, false))
|
if (!Resolve(senderUid, ref sender, false))
|
||||||
return allowNonStationPackets;
|
return allowNonStationPackets;
|
||||||
|
|
||||||
|
if (!sender.StationId.HasValue)
|
||||||
|
TrySetStationId(senderUid, sender);
|
||||||
|
|
||||||
return sender.StationId == receiverStationId;
|
return sender.StationId == receiverStationId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,13 +60,16 @@ namespace Content.Server.Medical.SuitSensors
|
|||||||
|
|
||||||
while (sensors.MoveNext(out var uid, out var sensor, out var device))
|
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;
|
continue;
|
||||||
|
|
||||||
// check if sensor is ready to update
|
// check if sensor is ready to update
|
||||||
if (curTime < sensor.NextUpdate)
|
if (curTime < sensor.NextUpdate)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (!CheckSensorAssignedStation(uid, sensor))
|
||||||
|
continue;
|
||||||
|
|
||||||
// TODO: This would cause imprecision at different tick rates.
|
// TODO: This would cause imprecision at different tick rates.
|
||||||
sensor.NextUpdate = curTime + sensor.UpdateRate;
|
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
|
//Retrieve active server address if the sensor isn't connected to a server
|
||||||
if (sensor.ConnectedServer == null)
|
if (sensor.ConnectedServer == null)
|
||||||
{
|
{
|
||||||
if (!_monitoringServerSystem.TryGetActiveServerAddress(sensor.StationId.Value, out var address))
|
if (!_monitoringServerSystem.TryGetActiveServerAddress(sensor.StationId!.Value, out var address))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
sensor.ConnectedServer = address;
|
sensor.ConnectedServer = address;
|
||||||
@@ -98,6 +101,20 @@ namespace Content.Server.Medical.SuitSensors
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>True if the sensor is assigned to a station or assigning it was successful. False otherwise.</returns>
|
||||||
|
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)
|
private void OnPlayerSpawn(PlayerSpawnCompleteEvent ev)
|
||||||
{
|
{
|
||||||
// If the player spawns in arrivals then the grid underneath them may not be appropriate.
|
// If the player spawns in arrivals then the grid underneath them may not be appropriate.
|
||||||
|
|||||||
Reference in New Issue
Block a user