Skip to content

Commit 4dc4236

Browse files
committed
Fix a counter bug that could produce a crash in custom builds.
1 parent 07d0c41 commit 4dc4236

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

KSPCommunityFixes/BugFixes/ModuleIndexingMismatch.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -472,9 +472,17 @@ static IEnumerable<CodeInstruction> ShipConstruct_LoadShip_Transpiler(IEnumerabl
472472
Debug.LogError($"Error applying ModuleIndexingMismatch patch : couldn't find Part.LoadModule() call in ShipConstruct.LoadShip()");
473473
return instructions;
474474
}
475-
476-
// then, insert our own module loading call before the original part nodes parsing loop
477-
for (int i = 0; i < code.Count - 6; i++)
475+
uint minusCount;
476+
if (!KSPCommunityFixes.cleanedDll)
477+
{
478+
minusCount = 6;
479+
}
480+
else
481+
{
482+
minusCount = 5;
483+
}
484+
// then, insert our own module loading call before the original part nodes parsing loop
485+
for (int i = 0; i < code.Count - minusCount; i++)
478486
{
479487
//// int moduleIndex = 0;
480488
// ldc.i4.0 NULL

0 commit comments

Comments
 (0)