diff --git a/1.6/1.6/Assemblies/WulaFallenEmpire.dll b/1.6/1.6/Assemblies/WulaFallenEmpire.dll index 0bb87f64..c948018f 100644 Binary files a/1.6/1.6/Assemblies/WulaFallenEmpire.dll and b/1.6/1.6/Assemblies/WulaFallenEmpire.dll differ diff --git a/Source/WulaFallenEmpire/CompMaintenancePod.cs b/Source/WulaFallenEmpire/CompMaintenancePod.cs index 8de674bf..d8e38e93 100644 --- a/Source/WulaFallenEmpire/CompMaintenancePod.cs +++ b/Source/WulaFallenEmpire/CompMaintenancePod.cs @@ -199,18 +199,39 @@ namespace WulaFallenEmpire } } - // 2. Heal all other injuries + // 2. Heal all other injuries and missing parts int injuriesHealed = 0; + // Loop until no more health conditions can be fixed while (HealthUtility.TryGetWorstHealthCondition(occupant, out var hediffToFix, out var _)) { - // Ensure we don't try to "heal" the maintenance hediff itself - if (hediffToFix.def == Props.hediffToRemove) + // Ensure we don't try to "heal" the maintenance hediff itself, as it's handled separately. + if (hediffToFix != null && hediffToFix.def == Props.hediffToRemove) { break; } + // Store the state before attempting to fix + int initialHediffCount = occupant.health.hediffSet.hediffs.Count; + var hediffsBefore = new HashSet(occupant.health.hediffSet.hediffs); + + // Attempt to fix the worst condition HealthUtility.FixWorstHealthCondition(occupant); - injuriesHealed++; + + // Check if a change actually occurred + bool conditionFixed = initialHediffCount > occupant.health.hediffSet.hediffs.Count || + !hediffsBefore.SetEquals(occupant.health.hediffSet.hediffs); + + if (conditionFixed) + { + injuriesHealed++; + } + else + { + // If FixWorstHealthCondition did nothing, it means it can't handle + // the current worst condition. We must break to avoid an infinite loop. + Log.Warning($"[WulaPodDebug] Halting healing loop. FixWorstHealthCondition did not resolve: {hediffToFix?.LabelCap ?? "a missing part"}."); + break; + } } if (injuriesHealed > 0)