Skip to content

Commit

Permalink
Persistent diagnostics
Browse files Browse the repository at this point in the history
Connection information is cached in a SignalRoutes object, which
loads and saves from the persistent.sfs and quicksave.sfs files.
  • Loading branch information
bk2w committed Sep 29, 2014
1 parent 1f8c5b2 commit dbd9366
Show file tree
Hide file tree
Showing 9 changed files with 374 additions and 10 deletions.
4 changes: 3 additions & 1 deletion src/RemoteTech2/FlightComputer/FlightComputer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ public bool InputAllowed
{
var satellite = RTCore.Instance.Network[SignalProcessor.Guid];
var connection = RTCore.Instance.Network[satellite];
return (satellite != null && satellite.HasLocalControl) || (SignalProcessor.Powered && connection.Any());
return (satellite != null && satellite.HasLocalControl) || (SignalProcessor.Powered && connection.Any()) || CheatOptions.InfiniteFuel;
}
}

public double Delay
{
get
{
if (CheatOptions.InfiniteFuel)

This comment has been minimized.

Copy link
@Starstrider42

Starstrider42 Oct 13, 2014

Infinite EVA fuel was chosen for the line of sight hack because it has no side effects while a vessel is active. Maybe it's better to use it here, too?

This comment has been minimized.

Copy link
@bk2w

bk2w Oct 13, 2014

Author Owner

I put this in so that I could regain control of out-of-range vessels, and just grabbed one of the flags that wasn't InfiniteEVAFuel without putting much thought into it.

Would it be better for InfiniteEVAFuel to hack line-of-sight, range and delay all at the same time? This would give users a way to recover a vessel no matter where it is (hidden, too far away, etc).

return 0.0;
var satellite = RTCore.Instance.Network[SignalProcessor.Guid];
if (satellite != null && satellite.HasLocalControl) return 0.0;
var connection = RTCore.Instance.Network[satellite];
Expand Down
1 change: 1 addition & 0 deletions src/RemoteTech2/IAntenna.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public interface IAntenna : IComparable<IAntenna>
double Radians { get; }
float Omni { get; }
float Consumption { get; }
uint PartId { get; }

void OnConnectionRefresh();
}
Expand Down
1 change: 1 addition & 0 deletions src/RemoteTech2/Modules/MissionControlAntenna.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public sealed class MissionControlAntenna : IAntenna
Guid IAntenna.Target { get { return Guid.Empty; } set { return; } }
float IAntenna.Dish { get { return 0.0f; } }
double IAntenna.Radians { get { return 1.0; } }
uint IAntenna.PartId { get { return 0; }}

public void OnConnectionRefresh() { }

Expand Down
1 change: 1 addition & 0 deletions src/RemoteTech2/Modules/ModuleRTAntenna.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public Guid Target
public float Omni { get { return IsRTBroken ? 0.0f : ((IsRTActive && IsRTPowered) ? Mode1OmniRange : Mode0OmniRange) * RangeMultiplier; } }
public float Consumption { get { return IsRTBroken ? 0.0f : IsRTActive ? EnergyCost * ConsumptionMultiplier : 0.0f; } }
public Vector3d Position { get { return vessel.GetWorldPos3D(); } }
public uint PartId { get { return part.flightID; } }

private float RangeMultiplier { get { return RTSettings.Instance.RangeMultiplier; } }
private float ConsumptionMultiplier { get { return RTSettings.Instance.ConsumptionMultiplier; } }
Expand Down
1 change: 1 addition & 0 deletions src/RemoteTech2/Modules/ModuleRTAntennaPassive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class ModuleRTAntennaPassive : PartModule, IAntenna
public float Omni { get { return Activated ? OmniRange * RangeMultiplier : 0.0f; } }
public float Consumption { get { return 0.0f; } }
public Vector3d Position { get { return vessel.GetWorldPos3D(); } }
public uint PartId { get { return part.flightID; } }

private float RangeMultiplier { get { return RTSettings.Instance.RangeMultiplier; } }
private bool Unlocked { get { return ResearchAndDevelopment.GetTechnologyState(TechRequired) == RDTech.State.Available || TechRequired.Equals("None"); } }
Expand Down
1 change: 1 addition & 0 deletions src/RemoteTech2/Modules/ProtoAntenna.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ internal class ProtoAntenna : IAntenna
public bool Powered { get; private set; }
public bool Activated { get; set; }
public float Consumption { get; private set; }
public uint PartId { get { return mProtoPart.flightID; } }

public bool CanTarget { get { return Dish != -1; } }

Expand Down
12 changes: 6 additions & 6 deletions src/RemoteTech2/NetworkManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ public partial class NetworkManager : IEnumerable<ISatellite>
}
}

private Dictionary<ISatellite, NetworkRoute<ISatellite>> mLastConnectionCache = new Dictionary<ISatellite, NetworkRoute<ISatellite>>();
public NetworkRoute<ISatellite> LastConnection(ISatellite sat) {

if (sat == null) return null;
return mLastConnectionCache.ContainsKey(sat) ? mLastConnectionCache[sat] : null;
if (SignalRoutes.Current == null)
return null;
else
return SignalRoutes.Current[sat].FirstOrDefault();
}


Expand Down Expand Up @@ -115,8 +115,8 @@ public void FindPath(ISatellite start, IEnumerable<ISatellite> commandStations)
// If theres a valid path, set it aside for diagnostics
if (mConnectionCache[start].Count > 0)
{
// Debug.Log(String.Format("Saving a connection from {0} to {1} of {2} links", start.Name, mConnectionCache[start][0].Links, mConnectionCache[start][0].Links.Count));
mLastConnectionCache[start] = mConnectionCache[start][0];
if(SignalRoutes.Current != null) // FindPath can get invoked before the SignalRoutes data is laoded from persistent.sfs
SignalRoutes.Current[start] = mConnectionCache[start];
}

start.OnConnectionRefresh(this[start]);
Expand Down
Loading

0 comments on commit dbd9366

Please sign in to comment.