Skip to content

Commit

Permalink
Removes per-frame caching of VesselSatellite.SignalProcessor
Browse files Browse the repository at this point in the history
This seems to fix the recent issues, although I'm not yet sure why.
  • Loading branch information
madadam committed Jan 9, 2014
1 parent 43c1696 commit 31400c4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/RemoteTech2/NetworkManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void FindPath(ISatellite start, IEnumerable<ISatellite> commandStations)

public IEnumerable<NetworkLink<ISatellite>> FindNeighbors(ISatellite s)
{
if (!s.Powered || !Graph.ContainsKey(s.Guid)) return Enumerable.Empty<NetworkLink<ISatellite>>();
if (!Graph.ContainsKey(s.Guid) || !s.Powered) return Enumerable.Empty<NetworkLink<ISatellite>>();
return Graph[s.Guid].Where(l => l.Target.Powered);
}

Expand Down
13 changes: 7 additions & 6 deletions src/RemoteTech2/VesselSatellite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace RemoteTech
public class VesselSatellite : ISatellite
{
public bool Visible {
get { return SignalProcessor != null ? SignalProcessor.Visible : false; }
get { return SignalProcessor.Visible; }
}

public String Name {
Expand Down Expand Up @@ -41,10 +41,11 @@ public class VesselSatellite : ISatellite
public ISignalProcessor SignalProcessor
{
get {
return RTUtil.CachePerFrame(ref mSignalProcessor, () =>
{
return SignalProcessors.FirstOrDefault(s => s.FlightComputer != null) ?? SignalProcessors.FirstOrDefault();
});
// return RTUtil.CachePerFrame(ref mSignalProcessor, () =>
// {
// return SignalProcessors.FirstOrDefault(s => s.FlightComputer != null) ?? SignalProcessors[0];
// });
return SignalProcessors.FirstOrDefault(s => s.FlightComputer != null) ?? SignalProcessors[0];
}
}

Expand Down Expand Up @@ -81,7 +82,7 @@ public void OnConnectionRefresh(List<NetworkRoute<ISatellite>> routes)
}
}

private CachedField<ISignalProcessor> mSignalProcessor;
// private CachedField<ISignalProcessor> mSignalProcessor;
private CachedField<bool> mLocalControl;

public VesselSatellite(List<ISignalProcessor> parts)
Expand Down

0 comments on commit 31400c4

Please sign in to comment.