Prevent infinite loops in device linking (#16856)

This commit is contained in:
Julian Giebel
2023-05-28 18:14:06 +02:00
committed by GitHub
parent 9c1fe530c1
commit 49cb9d0e1e
11 changed files with 185 additions and 14 deletions

View File

@@ -315,6 +315,20 @@ public abstract class SharedDeviceLinkSystem : EntitySystem
sinkComponent.LinkedSources.Add(sourceUid);
}
/// <summary>
/// Removes every link from the given sink
/// </summary>
public void RemoveAllFromSink(EntityUid sinkUid, DeviceLinkSinkComponent? sinkComponent = null)
{
if (!Resolve(sinkUid, ref sinkComponent))
return;
foreach (var sourceUid in sinkComponent.LinkedSources)
{
RemoveSinkFromSource(sourceUid, sinkUid, null, sinkComponent);
}
}
/// <summary>
/// Removes all links between a source and a sink
/// </summary>
@@ -332,7 +346,7 @@ public abstract class SharedDeviceLinkSystem : EntitySystem
if (sourceComponent == null && sinkComponent == null)
{
// Both were delted?
// Both were deleted?
return;
}