From a176609c275c7f213dcc0f0a2f3d457aa6c36e53 Mon Sep 17 00:00:00 2001 From: D4VID Date: Fri, 21 Feb 2025 20:46:07 +0100 Subject: [PATCH] Hightlight connected and draining clusters --- .../src/client/tool/PathHighLighter.cs | 3 +- .../src/server/ServerPathTracer.cs | 49 +++---------------- .../shared/packets/s2c/AnalyzePathResponse.cs | 21 +++----- 3 files changed, 16 insertions(+), 57 deletions(-) diff --git a/CriticalPathAnalyzer/CriticalPathAnalyzer/src/client/tool/PathHighLighter.cs b/CriticalPathAnalyzer/CriticalPathAnalyzer/src/client/tool/PathHighLighter.cs index e729f40..dbf930c 100644 --- a/CriticalPathAnalyzer/CriticalPathAnalyzer/src/client/tool/PathHighLighter.cs +++ b/CriticalPathAnalyzer/CriticalPathAnalyzer/src/client/tool/PathHighLighter.cs @@ -14,7 +14,7 @@ namespace CriticalPathAnalyzer.Client.Tool { private static List _highlightedWires = new List(); public static void HighlightWires(AnalyzePathResponse response) { - _clusters = response.SelectedClusters; + _clusters = response.Clusters; IWorldData world = Instances.MainWorld.Data; @@ -38,7 +38,6 @@ namespace CriticalPathAnalyzer.Client.Tool { foreach (PegAddress pegAddress in clusterDetails.Pegs) { if (!world.Contains(pegAddress.ComponentAddress)) { - CriticalPathAnalyzerClient.LoggerInstance.Warn("Peg's component doesn't exist in world"); continue; } diff --git a/CriticalPathAnalyzer/CriticalPathAnalyzer/src/server/ServerPathTracer.cs b/CriticalPathAnalyzer/CriticalPathAnalyzer/src/server/ServerPathTracer.cs index 3c5da03..48bcc44 100644 --- a/CriticalPathAnalyzer/CriticalPathAnalyzer/src/server/ServerPathTracer.cs +++ b/CriticalPathAnalyzer/CriticalPathAnalyzer/src/server/ServerPathTracer.cs @@ -13,7 +13,6 @@ namespace CriticalPathAnalyzer.Server { // Reflection/Delegate access helpers: private static readonly Func GetCluster; private static readonly Func GetLinker; - private static readonly Func> GetLeaders; private static readonly Func> GetFollowers; @@ -28,9 +27,6 @@ namespace CriticalPathAnalyzer.Server { GetLinker = Delegator.createFieldGetter( Fields.getPrivate(typeof(Cluster), "Linker") ); - GetLeaders = Delegator.createFieldGetter>( - Fields.getPrivate(typeof(ClusterLinker), "LinkedLeaders") - ); GetFollowers = Delegator.createFieldGetter>( Fields.getPrivate(typeof(ClusterLinker), "LinkedFollowers") ); @@ -62,55 +58,23 @@ namespace CriticalPathAnalyzer.Server { return false; // Whoops, cannot collect the primary clusters, probably probing an output peg. } - // Collect clusters that get powered by the original cluster or will power it. - var collectedSources = new HashSet(); + // Collect clusters that get powered by the original cluster by fast buffers var collectedDrains = new HashSet(); foreach (Cluster cluster in primaryClusters) { - CollectClusters(cluster, collectedSources, GetLeaders); CollectClusters(cluster, collectedDrains, GetFollowers); } foreach (Cluster cluster in primaryClusters) { - collectedSources.Remove(cluster); collectedDrains.Remove(cluster); } - // Collect and filter clusters that are both source and drain: - var collectedEquals = new HashSet(); - foreach (Cluster collectedSource in collectedSources) { - if (collectedDrains.Remove(collectedSource)) { - collectedEquals.Add(collectedSource); - } - } - - foreach (Cluster collectedEqual in collectedEquals) { - collectedSources.Remove(collectedEqual); - } - //Collect information about each cluster: response = new AnalyzePathResponse() { RequestGuid = requestGuid, - SelectedClusters = new List(), + Clusters = new List(), }; - foreach (Cluster cluster in primaryClusters) { - response.SelectedClusters.Add(CollectClusterInformation(cluster)); - } - - // response.sourcingClusters = new List(); - // foreach (var cluster in collectedSources) { - // response.sourcingClusters.Add(CollectClusterInformation(cluster)); - // } - // - // response.connectedClusters = new List(); - // foreach (var cluster in collectedEquals) { - // response.connectedClusters.Add(CollectClusterInformation(cluster)); - // } - // - // response.drainingClusters = new List(); - // foreach (var cluster in collectedDrains) { - // response.drainingClusters.Add(CollectClusterInformation(cluster)); - // } - + response.Clusters.AddRange(primaryClusters.Select(CollectClusterInformation)); + response.Clusters.AddRange(collectedDrains.Select(CollectClusterInformation)); return true; } @@ -189,7 +153,7 @@ namespace CriticalPathAnalyzer.Server { clustersToProcess.Enqueue(startingLinker); // While the starting cluster is no source, the algorithm needs to skip it when encountered. - collectedClusters.Add(startingPoint); + // collectedClusters.Add(startingPoint); while (clustersToProcess.TryDequeue(out ClusterLinker linkerToCheck)) { List listOfLinkedLinkers = linkedLinkerGetter(linkerToCheck); // Is never null. foreach (ClusterLinker linkedLinker in listOfLinkedLinkers) { @@ -216,7 +180,7 @@ namespace CriticalPathAnalyzer.Server { foreach (InputPeg peg in inputPegs) { details.Pegs.Add(peg.Address); if (peg.SecretLinks != null && peg.SecretLinks.Any()) { - // Highlight this component somehow. + // Socket details.ConnectingComponents.Add(peg.Address.ComponentAddress); } @@ -224,6 +188,7 @@ namespace CriticalPathAnalyzer.Server { || (peg.OneWayPhasicLinksFollowers != null && peg.OneWayPhasicLinksFollowers.Any()) || (peg.OneWayPhasicLinksLeaders != null && peg.OneWayPhasicLinksLeaders.Any()) ) { + // Relay / fast buffer details.LinkingComponents.Add(peg.Address.ComponentAddress); } } diff --git a/CriticalPathAnalyzer/CriticalPathAnalyzer/src/shared/packets/s2c/AnalyzePathResponse.cs b/CriticalPathAnalyzer/CriticalPathAnalyzer/src/shared/packets/s2c/AnalyzePathResponse.cs index 53be1af..2f58b05 100644 --- a/CriticalPathAnalyzer/CriticalPathAnalyzer/src/shared/packets/s2c/AnalyzePathResponse.cs +++ b/CriticalPathAnalyzer/CriticalPathAnalyzer/src/shared/packets/s2c/AnalyzePathResponse.cs @@ -8,18 +8,13 @@ namespace CriticalPathAnalyzer.Shared.Packets.S2C { [MessagePackObject] public class AnalyzePathResponse : Packet { [Key(0)] public Guid RequestGuid; - [Key(1)] - public List SelectedClusters; + [Key(1)] public List Clusters; + } + + [MessagePackObject] + public sealed class ClusterDetails { + [Key(0)] public List Pegs; + [Key(1)] public List ConnectingComponents; + [Key(2)] public List LinkingComponents; } - - [MessagePackObject] - public sealed class ClusterDetails - { - [Key(0)] - public List Pegs; - [Key(1)] - public List ConnectingComponents; - [Key(2)] - public List LinkingComponents; - } } \ No newline at end of file