Fix suit sensors connecting to crew monitoring servers on grids without a station component (#16858)
This commit is contained in:
@@ -37,16 +37,16 @@ public sealed class CrewMonitoringServerSystem : EntitySystem
|
|||||||
return;
|
return;
|
||||||
_updateDiff -= UpdateRate;
|
_updateDiff -= UpdateRate;
|
||||||
|
|
||||||
var servers = EntityManager.EntityQuery<CrewMonitoringServerComponent>();
|
var servers = EntityQueryEnumerator<CrewMonitoringServerComponent>();
|
||||||
List<EntityUid> activeServers = new();
|
List<EntityUid> activeServers = new();
|
||||||
|
|
||||||
foreach (var server in servers)
|
while (servers.MoveNext(out var id, out var server))
|
||||||
{
|
{
|
||||||
//Make sure the server is disconnected when it becomes unavailable
|
//Make sure the server is disconnected when it becomes unavailable
|
||||||
if (!server.Available)
|
if (!server.Available)
|
||||||
{
|
{
|
||||||
if (server.Active)
|
if (server.Active)
|
||||||
DisconnectServer(server.Owner, server);
|
DisconnectServer(id, server);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -54,7 +54,7 @@ public sealed class CrewMonitoringServerSystem : EntitySystem
|
|||||||
if (!server.Active)
|
if (!server.Active)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
activeServers.Add(server.Owner);
|
activeServers.Add(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var activeServer in activeServers)
|
foreach (var activeServer in activeServers)
|
||||||
@@ -69,21 +69,21 @@ public sealed class CrewMonitoringServerSystem : EntitySystem
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool TryGetActiveServerAddress(EntityUid stationId, out string? address)
|
public bool TryGetActiveServerAddress(EntityUid stationId, out string? address)
|
||||||
{
|
{
|
||||||
var servers = EntityManager.EntityQuery<CrewMonitoringServerComponent, DeviceNetworkComponent>();
|
var servers = EntityQueryEnumerator<CrewMonitoringServerComponent, DeviceNetworkComponent>();
|
||||||
(CrewMonitoringServerComponent, DeviceNetworkComponent)? last = default;
|
(EntityUid id, CrewMonitoringServerComponent server, DeviceNetworkComponent device)? last = default;
|
||||||
|
|
||||||
foreach (var (server, device) in servers)
|
while (servers.MoveNext(out var uid, out var server, out var device))
|
||||||
{
|
{
|
||||||
if (!_stationSystem.GetOwningStation(server.Owner)?.Equals(stationId) ?? false)
|
if (!_stationSystem.GetOwningStation(uid)?.Equals(stationId) ?? true)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!server.Available)
|
if (!server.Available)
|
||||||
{
|
{
|
||||||
DisconnectServer(server.Owner,server, device);
|
DisconnectServer(uid,server, device);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
last = (server, device);
|
last = (uid, server, device);
|
||||||
|
|
||||||
if (server.Active)
|
if (server.Active)
|
||||||
{
|
{
|
||||||
@@ -95,8 +95,8 @@ public sealed class CrewMonitoringServerSystem : EntitySystem
|
|||||||
//If there was no active server for the station make the last available inactive one active
|
//If there was no active server for the station make the last available inactive one active
|
||||||
if (last.HasValue)
|
if (last.HasValue)
|
||||||
{
|
{
|
||||||
ConnectServer(last.Value.Item1.Owner, last.Value.Item1, last.Value.Item2);
|
ConnectServer(last.Value.id, last.Value.server, last.Value.device);
|
||||||
address = last.Value.Item2.Address;
|
address = last.Value.device.Address;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user