DRVeyl / RealAntennas

KSP Mod to add better antenna / link calculations to CommNet.
29 stars 22 forks source link

NRE when vessel is marked as DeployedScienceController but is not actually a science controller #68

Closed happz closed 2 years ago

happz commented 2 years ago

With Breaking Ground installed, it is possible to rename a vessel to become a "science" (DeployedScienceController) rather than a probe or relay, even when such a vessel is no actual "experiment control station". Then, when BG is uninstalled, existing vessels are not affected and keep their type. In this situation, RA starts logging the following exception:

[ERR 13:52:19.749] Timing0 threw during Update: System.NullReferenceException: Object reference not set to an instance of an object
  at RealAntennas.RACommNetVessel.GetDeployedScienceCluster (Vessel vessel) [0x00032] in <64eb50eae61a44a7b1338480914a19f9>:0 
  at RealAntennas.RACommNetVessel.OnNetworkPreUpdate () [0x00023] in <64eb50eae61a44a7b1338480914a19f9>:0 
  at CommNet.CommNode.NetworkPreUpdate () [0x00053] in <c1858a3f77504bd1aaa946fdccf84670>:0 
  at CommNet.Network.Net`4[_Net,_Data,_Link,_Path].PreUpdateNodes () [0x0001e] in <c1858a3f77504bd1aaa946fdccf84670>:0 
  at RealAntennas.RACommNetwork.StartRebuild (System.Boolean compute) [0x00028] in <64eb50eae61a44a7b1338480914a19f9>:0 
  at RealAntennas.Network.RACommNetNetwork.UpdateEarly () [0x00085] in <64eb50eae61a44a7b1338480914a19f9>:0 
  at Timing0.Update () [0x00023] in <c1858a3f77504bd1aaa946fdccf84670>:0

The most visible symptom is the loss of all connections between vessels and stations.

Changing the type of these vessels to e.g. Probe "fixes" the situation, and RA is able to process all connections as expected.

Note: this happened to me, and I did remove Breaking Ground sometime during my career game. But, maybe this issue manifests even with BG present - I'm not sure what RA would do when encountering a probe with no science yet marked as DeployedScienceController. The actual presence of BG may not have any other effect than letting me change the type of vessel to this one.