From 984f3bc652de5c058ec0c44a14071ef20d9e355d Mon Sep 17 00:00:00 2001 From: Mhoram Kerbin Date: Sat, 20 Aug 2022 00:27:16 +0200 Subject: [PATCH] Fix an exception during connecting to depot with more complex ships This is done by deleting parts in the reverse order. --- Source/WOLF/WOLF/Poof.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/WOLF/WOLF/Poof.cs b/Source/WOLF/WOLF/Poof.cs index 8bb8079e9..e1cbcb443 100644 --- a/Source/WOLF/WOLF/Poof.cs +++ b/Source/WOLF/WOLF/Poof.cs @@ -27,11 +27,12 @@ public static void GoPoof(Vessel vessel) //https://kerbalspaceprogram.com/api/class_fine_print_1_1_utilities_1_1_system_utilities.html#afd1eea0118d0c37dacd3ea696b125ff2 SystemUtilities.ExpungeKerbal(kerbal); } - foreach (var part in vessel.parts.ToArray()) + + var parts = vessel.parts.ToArray(); + for (var i = parts.Length - 1; i >= 0; i--) { - part.Die(); + parts[i].Die(); } - vessel.Die(); if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER)