When calling CommNet.CommNetVessel.InPlasma I get a StackOverflowException
in C# with just a simple if statement
variable v is a reference to a Vessel and all access to v.connection works as expected until the if (v.connection.InPlasma) statement.
// are we connected to DSN
if (v.connection.IsConnected)
{
return new ConnectionInfo(v.connection.ControlPath.First.hopType == HopType.Home ? LinkStatus.direct_link : LinkStatus.indirect_link,
ext_rate * v.connection.SignalStrength, v.connection.SignalStrength, ext_cost,
Lib.Ellipsis(Localizer.Format(v.connection.ControlPath.First.end.displayName).Replace("Kerbin", "DSN"), 20));
}
// is loss of connection due to plasma blackout
else if (v.connection.InPlasma) // calling InPlasma causes a StackOverflow :(
return new ConnectionInfo(LinkStatus.blackout);
Log output is:
[EXC 12:26:21.322] StackOverflowException: The requested operation caused a stack overflow. CommNet.CommNetVessel.get_InPlasma ()
with none of the usual debug info like the filename and line number etc you usually get with exceptions.
I suspect this is an error in KSP's code.
Using reflection to access the private field inPlasma gives a correct value.
Also posted here: