Skip to content

Commit 8b5b71d

Browse files
committed
Remove dead network-model code superseded by NetworkState
The migration onto the Burst NetworkState left the old managed routing orphaned. Delete the A* NetworkPathfinder and the explicit-mode half of NetworkRoute it fed (the freestanding-path ctor, Empty, Contains, and the BidirectionalEdge it compared against), leaving the live value-type view into the Dijkstra forests. Drop the unused NetworkManager.FindNeighbors / ConnectionCache / Count, the NetworkState.GetRouteLength / GetRouteOrigin guid wrappers (callers use the internal index versions), the unused VesselSatellite.Connections seam, and the never-referenced Dish type.
1 parent ea5d572 commit 8b5b71d

8 files changed

Lines changed: 17 additions & 289 deletions

File tree

src/RemoteTech/Network/NetworkState.cs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -554,20 +554,6 @@ internal SatelliteMarkData ScheduleSatelliteMarks(in SatelliteMarkViewParams p)
554554
return new SatelliteMarkData { marks = marks, handle = h };
555555
}
556556

557-
/// <summary>
558-
/// Get the distance between the requested satellite and its control point.
559-
/// </summary>
560-
/// <param name="sat"></param>
561-
/// <param name="groundOnly">Only consider ground stations, not vessels.</param>
562-
/// <returns>The length of network route, in meters.</returns>
563-
public double GetRouteLength(ISatellite sat, bool groundOnly)
564-
{
565-
if (!satmap.TryGetValue(sat.Guid, out int index))
566-
return double.PositiveInfinity;
567-
568-
return RouteLength(index, groundOnly);
569-
}
570-
571557
internal double RouteLength(int node, bool groundOnly)
572558
{
573559
var origin = GetOrigin(node, groundOnly);
@@ -601,19 +587,6 @@ internal bool RouteExists(int node, bool groundOnly)
601587
return origin >= 0 && origin != node;
602588
}
603589

604-
/// <summary>
605-
/// Get the control station that is currently controlling this satellite.
606-
/// </summary>
607-
/// <param name="sat"></param>
608-
/// <param name="groundOnly">Only consider ground stations, not vessels.</param>
609-
public ISatellite GetRouteOrigin(ISatellite sat, bool groundOnly)
610-
{
611-
if (!satmap.TryGetValue(sat.Guid, out int index))
612-
return null;
613-
614-
return RouteGoalSat(index, groundOnly);
615-
}
616-
617590
internal ISatellite RouteGoalSat(int node, bool groundOnly)
618591
{
619592
var origin = GetOrigin(node, groundOnly);

src/RemoteTech/NetworkManager.cs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ public partial class NetworkManager : IEnumerable<ISatellite>
2121
public ArrayMap<Guid, CelestialBody> Planets { get; private set; } = new();
2222
public ArrayMap<Guid, ISatellite> GroundStations { get; private set; } = new();
2323

24-
public int Count => RTCore.Instance.Satellites.Count + GroundStations.Count;
25-
2624
public static Guid ActiveVesselGuid => RTSettings.Instance.ActiveVesselGuidParsed;
2725

2826
public ISatellite this[Guid guid]
@@ -111,8 +109,6 @@ public List<NetworkRoute<ISatellite>> this[ISatellite sat]
111109
internal IEnumerable<KeyValuePair<Guid, List<NetworkLink<ISatellite>>>> EnumerateLinks() =>
112110
current?.EnumerateLinks() ?? Enumerable.Empty<KeyValuePair<Guid, List<NetworkLink<ISatellite>>>>();
113111

114-
internal Dictionary<ISatellite, List<NetworkRoute<ISatellite>>> ConnectionCache => mConnectionCache;
115-
116112
/// <summary>
117113
/// This tick's state — freshest positions, but not yet completed; callers pay for <see cref="NetworkState.Complete"/> if it's still running.
118114
/// </summary>
@@ -162,20 +158,6 @@ public void Dispose()
162158
next?.Dispose();
163159
}
164160

165-
/// <summary>
166-
/// Powered (and, when signal relay is on, relay-capable) neighbours of
167-
/// <paramref name="s"/>, resolved from the current state's adjacency. Used
168-
/// by the on-demand A* path query exposed through the public API.
169-
/// </summary>
170-
public IEnumerable<NetworkLink<ISatellite>> FindNeighbors(ISatellite s)
171-
{
172-
if (s == null || !s.Powered || current == null) return Enumerable.Empty<NetworkLink<ISatellite>>();
173-
var links = current.GetLinks(s);
174-
if (RTSettings.Instance.SignalRelayEnabled)
175-
return links.Where(l => l.Target.Powered && l.Target.CanRelaySignal);
176-
return links.Where(l => l.Target.Powered);
177-
}
178-
179161
public static NetworkLink<ISatellite>? GetLink(ISatellite sat_a, ISatellite sat_b)
180162
{
181163
if (sat_a == null || sat_b == null || sat_a == sat_b) return null;

src/RemoteTech/NetworkPathfinder.cs

Lines changed: 0 additions & 101 deletions
This file was deleted.

src/RemoteTech/SimpleTypes/BidirectionalEdge.cs

Lines changed: 0 additions & 42 deletions
This file was deleted.

src/RemoteTech/SimpleTypes/Dish.cs

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace RemoteTech.SimpleTypes;
2+
3+
public enum LinkType : byte
4+
{
5+
None,
6+
Dish,
7+
Omni,
8+
}

src/RemoteTech/SimpleTypes/NetworkRoute.cs

Lines changed: 9 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -5,90 +5,39 @@
55
namespace RemoteTech.SimpleTypes
66
{
77
/// <summary>
8-
/// A connection route, as a value-type view. In <b>view mode</b> the route is
9-
/// a lightweight handle into the persistent <see cref="NetworkState"/>
10-
/// (<c>_state != null</c>): <see cref="Length"/>/<see cref="Goal"/>/
8+
/// A connection route, as a value-type view: a lightweight handle into the
9+
/// persistent <see cref="NetworkState"/>. <see cref="Length"/>/<see cref="Goal"/>/
1110
/// <see cref="Exists"/> are answered O(1) from the Dijkstra forests, and the
1211
/// hop list is materialized lazily — and cached per tick by the state — only
13-
/// when <see cref="Links"/> is actually read. In <b>explicit mode</b>
14-
/// (<c>_state == null</c>) it wraps a freestanding path, e.g. the result of the
15-
/// A* <see cref="NetworkPathfinder"/> or <see cref="NetworkRoute.Empty{T}"/>.
12+
/// when <see cref="Links"/> is actually read.
1613
/// </summary>
1714
public readonly struct NetworkRoute<T> : IComparable<NetworkRoute<T>>
1815
{
19-
// View mode.
2016
private readonly NetworkState _state;
2117
private readonly int _node;
2218
private readonly bool _groundOnly;
2319

24-
// Explicit mode.
25-
private readonly T _start;
26-
private readonly IReadOnlyList<NetworkLink<T>> _links;
27-
private readonly double _length;
28-
29-
private static readonly NetworkLink<T>[] NoLinks = new NetworkLink<T>[0];
30-
31-
public NetworkRoute(T start, IReadOnlyList<NetworkLink<T>> links, double dist)
32-
{
33-
if (start == null) throw new ArgumentNullException(nameof(start));
34-
_state = null;
35-
_node = -1;
36-
_groundOnly = false;
37-
_start = start;
38-
_links = links;
39-
_length = dist;
40-
}
41-
4220
internal NetworkRoute(NetworkState state, int node, bool groundOnly)
4321
{
4422
_state = state;
4523
_node = node;
4624
_groundOnly = groundOnly;
47-
_start = default;
48-
_links = null;
49-
_length = 0.0;
5025
}
5126

52-
public T Start => _state != null ? (T)(object)_state.SatAt(_node) : _start;
27+
public T Start => (T)(object)_state.SatAt(_node);
5328

54-
public double Length => _state != null ? _state.RouteLength(_node, _groundOnly) : _length;
29+
public double Length => _state.RouteLength(_node, _groundOnly);
5530

56-
public bool Exists => _state != null
57-
? _state.RouteExists(_node, _groundOnly)
58-
: _links != null && _links.Count > 0;
31+
public bool Exists => _state.RouteExists(_node, _groundOnly);
5932

6033
public double Delay => RTSettings.Instance.EnableSignalDelay
6134
? Length / RTSettings.Instance.SpeedOfLight
6235
: 0.0;
6336

64-
public IReadOnlyList<NetworkLink<T>> Links => _state != null
65-
? (IReadOnlyList<NetworkLink<T>>)(object)_state.RouteHops(_node, _groundOnly)
66-
: _links ?? NoLinks;
67-
68-
public T Goal
69-
{
70-
get
71-
{
72-
if (!Exists) return default;
73-
if (_state != null) return (T)(object)_state.RouteGoalSat(_node, _groundOnly);
74-
return _links[_links.Count - 1].Target;
75-
}
76-
}
37+
public IReadOnlyList<NetworkLink<T>> Links =>
38+
(IReadOnlyList<NetworkLink<T>>)(object)_state.RouteHops(_node, _groundOnly);
7739

78-
public bool Contains(BidirectionalEdge<T> edge)
79-
{
80-
var links = Links;
81-
if (links.Count == 0) return false;
82-
T start = Start;
83-
if ((start.Equals(edge.A) && links[0].Target.Equals(edge.B)) ||
84-
(start.Equals(edge.B) && links[0].Target.Equals(edge.A))) return true;
85-
for (int i = 0; i < links.Count - 1; i++)
86-
{
87-
if (links[i].Target.Equals(edge.A) && links[i + 1].Target.Equals(edge.B)) return true;
88-
if (links[i].Target.Equals(edge.B) && links[i + 1].Target.Equals(edge.A)) return true;
89-
}
90-
return false;
91-
}
40+
public T Goal => Exists ? (T)(object)_state.RouteGoalSat(_node, _groundOnly) : default;
9241

9342
public int CompareTo(NetworkRoute<T> other) => Length.CompareTo(other.Length);
9443

@@ -101,12 +50,4 @@ public override string ToString()
10150
String.Join("→", parts), Length.ToString("F2") + "m");
10251
}
10352
}
104-
105-
public class NetworkRoute
106-
{
107-
public static NetworkRoute<T> Empty<T>(T start)
108-
{
109-
return new NetworkRoute<T>(start, null, Single.PositiveInfinity);
110-
}
111-
}
11253
}

src/RemoteTech/VesselSatellite.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,6 @@ public bool HasLocalControl
189189
* Helpers
190190
*/
191191

192-
/// <summary>
193-
/// List of network routes for the satellite.
194-
/// </summary>
195-
public List<NetworkRoute<ISatellite>> Connections => RTCore.Instance.Network[this];
196-
197192
/// <summary>
198193
/// Called on connection refresh to update the connections.
199194
/// </summary>

0 commit comments

Comments
 (0)