Skip to content

Commit

Permalink
Fix intermittent issue with loop removal
Browse files Browse the repository at this point in the history
  • Loading branch information
ari-steas committed Apr 27, 2024
1 parent 864c93d commit 0c47ab0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void DoConnectionCheck(bool cascadingUpdate = false, HashSet<AssemblyPart
if (visited == null)
visited = new HashSet<AssemblyPart>();

if (!visited.Add(this))
if (!visited.Add(this)) // I don't think this is actually doing a ton but it doesn't hurt really either?
return;

ConnectedParts = GetValidNeighborParts();
Expand Down Expand Up @@ -115,11 +115,13 @@ public void DoConnectionCheck(bool cascadingUpdate = false, HashSet<AssemblyPart

// Trigger cascading update
if (IsBaseBlock || cascadingUpdate)
{
//debug notification begone
//MyAPIGateway.Utilities.ShowNotification("" + GetValidNeighborParts().Count);
foreach (var neighbor in GetValidNeighborParts())
if (neighbor.MemberAssembly == null)
neighbor.DoConnectionCheck(true, visited);
}
}

public void PartRemoved(bool notifyMods = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ public void AddPart(AssemblyPart part)

public void RemovePart(AssemblyPart part)
{
if (part == null || _componentParts == null)
if (!_componentParts?.Remove(part) ?? true)
return;

if (!_componentParts.Remove(part))
if (part == null)
return;

var neighbors = part.ConnectedParts;
Expand Down Expand Up @@ -107,7 +107,8 @@ public void RemovePart(AssemblyPart part)
{
if (!largestLoop.Contains(componentPart))
{
RemovePart(componentPart);
if (_componentParts?.Remove(componentPart) ?? false)
AssemblyPartManager.I.QueueConnectionCheck(componentPart);
}
}
}
Expand Down

0 comments on commit 0c47ab0

Please sign in to comment.