sswelm / KSP-Interstellar-Extended

continuation of KSP Interstellar
Other
98 stars 101 forks source link

Fix Magnetohydrodynamic Electric Generator not using MHD mode #700

Closed Cholerix closed 2 years ago

Cholerix commented 2 years ago

Issue

Right now the MHD generator does not work properly. This is caused by one or two lines in FNGenerator.cs

When calculating the hot bath temperature the following condition is evaluated:

if (_appliesBalance || !isMHD)

FNGenerator.cs#L769.

And _appliesBalance is set by

_appliesBalance = isMHD || _attachedPowerSource.ShouldApplyBalance(chargedParticleMode ? ElectricGeneratorType.charged_particle : ElectricGeneratorType.thermal);

FNGenerator.cs#L958

Which means the first condition always evaluates as true. The MHD generator always uses the hot bath temperature of the power source, turning it into a worse version of the thermal generator.

Fix

If I understand it correctly, _appliesBalance is used when a nozzle and a generator are attached to the same reactor.


The code using _appliesBalance was commented out in many places. All it does is influence the megajoules buffer of the generator. When using a charged particle only mode such as Lithium6 cycle fusion, the buffer drops to zero. This seems rather odd, but it's another issue.