From b505f92c7aa3dcced04c0225e336900d7d7cc480 Mon Sep 17 00:00:00 2001 From: NathanKell Date: Tue, 5 Apr 2022 22:22:50 -0700 Subject: [PATCH] Don't release clamps if an engine is in current stage but not ignited --- MechJeb2/MechJebModuleStagingController.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/MechJeb2/MechJebModuleStagingController.cs b/MechJeb2/MechJebModuleStagingController.cs index b4a72dce6..a876793cf 100644 --- a/MechJeb2/MechJebModuleStagingController.cs +++ b/MechJeb2/MechJebModuleStagingController.cs @@ -268,8 +268,8 @@ public override void OnUpdate() HasFairing(vessel.currentStage - 1)) return; - //only release launch clamps if we're at nearly full thrust - if (vesselState.thrustCurrent / vesselState.thrustAvailable < clampAutoStageThrustPct && + //only release launch clamps if we're at nearly full thrust and no failed engines + if ((vesselState.thrustCurrent / vesselState.thrustAvailable < clampAutoStageThrustPct || AnyFailedEngines(allModuleEngines)) && InverseStageReleasesClamps(vessel.currentStage - 1)) return; } @@ -358,6 +358,18 @@ public bool InverseStageHasEngines(int inverseStage) return result; } + public bool AnyFailedEngines(List allEngines) + { + foreach (ModuleEngines engine in allEngines) + { + Part p = engine.part; + if (p.inverseStage >= vessel.currentStage && !p.IsDecoupledInStage(vessel.currentStage - 1) && engine.isEnabled && !engine.EngineIgnited && engine.allowShutdown) + return true; + } + + return false; + } + public void UpdateActiveModuleEngines(List allEngines) { activeModuleEngines.Clear();