From 13cff53fd2769f4e8e76c2cb10969752ebd4ac03 Mon Sep 17 00:00:00 2001 From: Anton Kuzin Date: Sat, 7 Feb 2026 13:19:28 +0300 Subject: [PATCH 1/3] Small refactoring --- MechJeb2/MechJebModuleStagingController.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MechJeb2/MechJebModuleStagingController.cs b/MechJeb2/MechJebModuleStagingController.cs index 458de9cae..3e050004d 100644 --- a/MechJeb2/MechJebModuleStagingController.cs +++ b/MechJeb2/MechJebModuleStagingController.cs @@ -308,6 +308,7 @@ public override void OnUpdate() if (!InverseStageHasActiveEngines(Vessel.currentStage)) { Stage(); + return; } // prevent staging when the current stage has active engines and the next stage has any engines (but not decouplers or clamps) @@ -324,6 +325,7 @@ public override void OnUpdate() if (InverseStageDecouplesDeactivatedEngineOrTank(Vessel.currentStage - 1)) { Stage(); + return; } // only decouple fairings if the dynamic pressure, altitude, and aerothermal flux conditions are respected @@ -450,10 +452,10 @@ private double LastNonZeroDVStageBurnTime() } // allModuleEngines => IsEngine() && !IsSepratron() - private bool InverseStageHasActiveEngines(int inverseStage) + private bool InverseStageHasActiveEngines(int kspStage) { foreach (ModuleEngines engine in _allModuleEngines) - if (engine.part.inverseStage == inverseStage && engine.EngineHasFuel()) + if (engine.part.inverseStage >= kspStage && engine.EngineHasFuel()) return true; return false; } From 2c9280ac431048cc2329cf0108d9b0d1303f6327 Mon Sep 17 00:00:00 2001 From: Anton Kuzin Date: Sun, 8 Feb 2026 01:55:42 +0300 Subject: [PATCH 2/3] Don't check if there's a fairing twice. Revert the function argument rename as it makes no sence to do it only here. --- MechJeb2/MechJebModuleStagingController.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MechJeb2/MechJebModuleStagingController.cs b/MechJeb2/MechJebModuleStagingController.cs index 3e050004d..2b544fd59 100644 --- a/MechJeb2/MechJebModuleStagingController.cs +++ b/MechJeb2/MechJebModuleStagingController.cs @@ -277,7 +277,7 @@ public override void OnUpdate() if (Vessel.currentStage <= ActiveAutoStageModuleLimit()) { // force staging once if fairing conditions are met in the next stage - if (HasFairing(Vessel.currentStage - 1) && !WaitingForFairing()) + if (!WaitingForFairing()) { Stage(); } @@ -452,10 +452,10 @@ private double LastNonZeroDVStageBurnTime() } // allModuleEngines => IsEngine() && !IsSepratron() - private bool InverseStageHasActiveEngines(int kspStage) + private bool InverseStageHasActiveEngines(int inverseStage) { foreach (ModuleEngines engine in _allModuleEngines) - if (engine.part.inverseStage >= kspStage && engine.EngineHasFuel()) + if (engine.part.inverseStage >= inverseStage && engine.EngineHasFuel()) return true; return false; } From 02f5f2f1ce1b3b0761bbc78ddff009d01f42844f Mon Sep 17 00:00:00 2001 From: Anton Kuzin Date: Sun, 8 Feb 2026 11:25:51 +0300 Subject: [PATCH 3/3] Revert fairing check removal --- MechJeb2/MechJebModuleStagingController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MechJeb2/MechJebModuleStagingController.cs b/MechJeb2/MechJebModuleStagingController.cs index 2b544fd59..66531437d 100644 --- a/MechJeb2/MechJebModuleStagingController.cs +++ b/MechJeb2/MechJebModuleStagingController.cs @@ -277,7 +277,7 @@ public override void OnUpdate() if (Vessel.currentStage <= ActiveAutoStageModuleLimit()) { // force staging once if fairing conditions are met in the next stage - if (!WaitingForFairing()) + if (HasFairing(Vessel.currentStage - 1) && !WaitingForFairing()) { Stage(); }