Fix an IndexOutOfRangeException in DragCube.Load() #232
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The name field in a
DRAG_CUBE
config node is supposed to be optional. However, when the name is not included in the list of values, anIndexOutOfRangeException
is thrown.Even when not loaded from a config file, when the name field on a
DragCube
object is the empty string (for example, when it is default-constructed in code) it is not included in the string returned byDragCube.SaveToString()
; this causes a problem when theFlightIntegrator.Setup()
method uses this string to clone drag cubes.The first instructions in
DragCube.Load(string[] data)
are:That last check should have been against a length of 24 instead; this patch replaces the first occurrence of
ldc.i4.s 12
in the code byldc.i4.s 24
.I've checked KSP version 1.0.5 (the oldest version available via Steam), and the bug was already present in that version; the code seems to be unchanged between then and version 1.12.5.