MOARdV / AvionicsSystems

MOARdV's Avionics Systems for Kerbal Space Program - a new generation of IVA enhancement.
Other
52 stars 26 forks source link

CurrentThrustkN() returns 0 when switching modes on multi-mode engines #341

Closed MOARdV closed 2 years ago

MOARdV commented 3 years ago

From forum user Manul:

Houston, we have a problem. Both fc.CurrentThrustkN() and engine.CurrentThrustkN() return 0 for multimode engines when they switch mode. Both functions calculate the thrust correctly when engines are switched to the mode that was used when the vessel was loaded and ignore multimode engine's thrust in another mode.

vulkans22 commented 2 years ago

Had some free time recently and did some digging around in the code, finally found the breakage point:

In MASVesselComputerModules.cs, function "TransferModules(List sourceList, ref T[] destArray)", the first if statement here "if (sourceList.Count != destArray.Length)" never returns true when a multimode engine toggle occurs as the engine count doesn't actually changes amount, therefore it never executes the list transfer and continues using a stale engine module list.

My quick bandaid fix was to pass a bool to bypass the if statement for this specific edge case, though I'm sure there's a more elegant way to do this.