Skip to content

Commit

Permalink
fix possible null exception
Browse files Browse the repository at this point in the history
  • Loading branch information
OliBomby committed Oct 14, 2022
1 parent 4bcad71 commit 19f43fa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Mapperator.ConsoleApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,12 @@ private static MapDataPoint[] TransferSpacing(MapDataPoint[] from, MapDataPoint[
o.NewCombo, o.SliderType, o.SliderLength.HasValue ? Transform(o.SliderLength.Value, o.BeatsSince, sliderSpacingData) : null,
o.SliderSegments, o.Repeats, o.HitObject)).ToArray();

double Transform(double spacing, double beats, double[][] data) {
double Transform(double spacing, double beats, double[]?[] data) {
var gap = MathHelper.Clamp((int)Math.Round(Math.Log2(beats) + 6), 0, 8);
var index = inputSpacingData.IndexOf(spacing);
if (data[gap].Length == 0)
if (data[gap] is null || data[gap]!.Length == 0)
return 0;
return data[gap][MathHelper.Clamp((int)Math.Round((double)index / inputSpacingData.Count * data[gap].Length), 0, data[gap].Length - 1)];
return data[gap]![MathHelper.Clamp((int)Math.Round((double)index / inputSpacingData.Count * data[gap]!.Length), 0, data[gap]!.Length - 1)];
}
}

Expand Down

0 comments on commit 19f43fa

Please sign in to comment.