Skip to content

Commit

Permalink
Change fix to Issue #6 due to side-effect of broken experiment popup …
Browse files Browse the repository at this point in the history
…on EVA
  • Loading branch information
KSP-TaxiService committed Jan 7, 2018
1 parent 951bc13 commit 6a8bb78
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ private void cacheCommNetVessels()
List<Vessel> allVessels = FlightGlobals.fetch.vessels;
for (int i = 0; i < allVessels.Count; i++)
{
if (allVessels[i].connection != null && allVessels[i].vesselType != VesselType.Unknown)// && allVessels[i].vesselType != VesselType.Debris) // debris could be spent stage with functional probes and antennas
if (allVessels[i].connection != null && allVessels[i].connection.ControlState != VesselControlState.None && allVessels[i].vesselType != VesselType.Unknown)// && allVessels[i].vesselType != VesselType.Debris) // debris could be spent stage with functional probes and antennas
{
CNCLog.Debug("Caching CommNetVessel '{0}'", allVessels[i].vesselName);
this.commVessels.Add(allVessels[i].connection as CNCCommNetVessel);
Expand Down
19 changes: 13 additions & 6 deletions src/CommNetConstellation/CommNetLayer/CNCCommNetVessel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ protected override void OnNetworkInitialized()
{
validateAndUpgrade(this.Vessel);

if(readCommandData().Count <= 0) //no probe core/command module to "process" signal
if (readCommandData().Count <= 0) //no probe core/command module to "process" signal
{
this.vessel.connection = null;
this.controlState = VesselControlState.None;
throw new Exception();
}

Expand Down Expand Up @@ -155,10 +155,17 @@ private void vesselModified(Vessel thisVessel)
{
CNCLog.Verbose("Active CommNet Vessel '{0}' is staged. Rebuilding the freq list on suriving antennas...", this.Vessel.vesselName);

//force-rebuild freq list to stop players from abusing LockList
this.vesselAntennas = this.readAntennaData();
this.FrequencyDict = buildFrequencyList(this.vesselAntennas);
this.strongestFreq = computeStrongestFrequency(this.FrequencyDict);
if (readCommandData().Count <= 0) //no probe core/command module to "process" signal
{
this.controlState = VesselControlState.None;
}
else
{
//force-rebuild freq list to stop players from abusing LockList
this.vesselAntennas = this.readAntennaData();
this.FrequencyDict = buildFrequencyList(this.vesselAntennas);
this.strongestFreq = computeStrongestFrequency(this.FrequencyDict);
}

this.stageActivated = false;
}
Expand Down
43 changes: 22 additions & 21 deletions src/CommNetConstellation/CommNetLayer/CNCCommNetwork.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,38 +31,39 @@ public static bool AreSame(CommNode a, CommNode b)
/// </summary>
protected override bool SetNodeConnection(CommNode a, CommNode b)
{
//stop links between ground stations
if (a.isHome && b.isHome)
{
this.Disconnect(a, b, true);
return false;
}

List<short> aFreqs, bFreqs;

//each CommNode has at least some frequencies?
try
{
//stop links between ground stations
if (a.isHome && b.isHome)
{
this.Disconnect(a, b, true);
return false;
}

//each CommNode has at least some frequencies?
aFreqs = CNCCommNetScenario.Instance.getFrequencies(a);
bFreqs = CNCCommNetScenario.Instance.getFrequencies(b);
}
catch (NullReferenceException e) // either CommNode could be a kerbal on EVA
{

//share same frequency?
for (int i = 0; i < aFreqs.Count; i++)
{
if (bFreqs.Contains(aFreqs[i])) // yes, it does
{
return base.SetNodeConnection(a, b);
}
}

this.Disconnect(a, b, true);
return false;
}

//share same frequency?
for (int i = 0; i < aFreqs.Count; i++)
catch (Exception e) // either CommNode could be a kerbal on EVA
{
if (bFreqs.Contains(aFreqs[i])) // yes, it does
{
return base.SetNodeConnection(a, b);
}
//CNCLog.Verbose("Error thrown when checking CommNodes '{0}' & '{1}' - {2}", a.name, b.name, e.Message);
this.Disconnect(a, b, true);
return false;
}

this.Disconnect(a, b, true);
return false;
}
}
}

0 comments on commit 6a8bb78

Please sign in to comment.