Correct signal linker removing (#13058)
This commit is contained in:
@@ -164,15 +164,19 @@ namespace Content.Server.MachineLinking.System
|
|||||||
// validate links
|
// validate links
|
||||||
Dictionary<EntityUid, SignalTransmitterComponent?> uidCache = new();
|
Dictionary<EntityUid, SignalTransmitterComponent?> uidCache = new();
|
||||||
foreach (var rport in receiver.Inputs)
|
foreach (var rport in receiver.Inputs)
|
||||||
|
{
|
||||||
|
var toRemove = new List<PortIdentifier>();
|
||||||
foreach (var tport in rport.Value)
|
foreach (var tport in rport.Value)
|
||||||
{
|
{
|
||||||
if (!uidCache.TryGetValue(tport.Uid, out var transmitter))
|
if (!uidCache.TryGetValue(tport.Uid, out var transmitter))
|
||||||
uidCache.Add(tport.Uid, transmitter = CompOrNull<SignalTransmitterComponent>(tport.Uid));
|
uidCache.Add(tport.Uid, transmitter = CompOrNull<SignalTransmitterComponent>(tport.Uid));
|
||||||
if (transmitter == null || !transmitter.Outputs.TryGetValue(tport.Port, out var tpv))
|
if (transmitter == null || !transmitter.Outputs.TryGetValue(tport.Port, out var tpv))
|
||||||
rport.Value.Remove(tport);
|
toRemove.Add(tport);
|
||||||
else if (!tpv.Contains(new(uid, rport.Key)))
|
else if (!tpv.Contains(new(uid, rport.Key)))
|
||||||
tpv.Add(new(uid, rport.Key));
|
tpv.Add(new(uid, rport.Key));
|
||||||
}
|
}
|
||||||
|
toRemove.ForEach(tport => rport.Value.Remove(tport));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnTransmitterRemoved(EntityUid uid, SignalTransmitterComponent transmitter, ComponentRemove args)
|
private void OnTransmitterRemoved(EntityUid uid, SignalTransmitterComponent transmitter, ComponentRemove args)
|
||||||
|
|||||||
Reference in New Issue
Block a user