diff --git a/src/CommNetConstellation/CommNetLayer/CNCCommNetScenario.cs b/src/CommNetConstellation/CommNetLayer/CNCCommNetScenario.cs index b13e637..a290e48 100644 --- a/src/CommNetConstellation/CommNetLayer/CNCCommNetScenario.cs +++ b/src/CommNetConstellation/CommNetLayer/CNCCommNetScenario.cs @@ -324,7 +324,7 @@ private void cacheCommNetVessels() List 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); diff --git a/src/CommNetConstellation/CommNetLayer/CNCCommNetVessel.cs b/src/CommNetConstellation/CommNetLayer/CNCCommNetVessel.cs index a881d99..7d6c4db 100644 --- a/src/CommNetConstellation/CommNetLayer/CNCCommNetVessel.cs +++ b/src/CommNetConstellation/CommNetLayer/CNCCommNetVessel.cs @@ -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(); } @@ -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; } diff --git a/src/CommNetConstellation/CommNetLayer/CNCCommNetwork.cs b/src/CommNetConstellation/CommNetLayer/CNCCommNetwork.cs index 90e4969..2ddcb18 100644 --- a/src/CommNetConstellation/CommNetLayer/CNCCommNetwork.cs +++ b/src/CommNetConstellation/CommNetLayer/CNCCommNetwork.cs @@ -31,38 +31,39 @@ public static bool AreSame(CommNode a, CommNode b) /// 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 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; } } }