Skip to content

Commit

Permalink
Don't release clamps if an engine is in current stage but not ignited
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanKell committed Apr 19, 2022
1 parent 4a27b45 commit b505f92
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions MechJeb2/MechJebModuleStagingController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -358,6 +358,18 @@ public bool InverseStageHasEngines(int inverseStage)
return result;
}

public bool AnyFailedEngines(List<ModuleEngines> 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<ModuleEngines> allEngines)
{
activeModuleEngines.Clear();
Expand Down

0 comments on commit b505f92

Please sign in to comment.