Skip to content

Commit ebcc131

Browse files
authored
#1 - Parse double types with InvariantCulture to avoid silent parsing errors
2 parents 9bbcbaf + 66a6674 commit ebcc131

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

AmpHelper.Library/Types/MoggSong.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using DtxCS;
55
using DtxCS.DataTypes;
66
using System.Collections.Generic;
7+
using System.Globalization;
78
using System.IO;
89
using System.Linq;
910
using System.Text.Json.Serialization;
@@ -343,11 +344,11 @@ public MoggSong(DataArray dtx) : base()
343344

344345
return tracks;
345346
}) ?? new List<Track>();
346-
Pans = dtxDict.GetValueOrDefault("/pans")?.GetChild<DataArray>(1)?.Children?.Select(e => e.ToString().Transform(o => double.Parse((string)o), 0)).ToList() ?? new List<double>();
347-
Volumes = dtxDict.GetValueOrDefault("/vols")?.GetChild<DataArray>(1)?.Children?.Select(e => e.ToString().Transform(o => double.Parse((string)o), 0)).ToList() ?? new List<double>();
348-
Attenuation = dtxDict.GetValueOrDefault("/active_track_db")?.Children.Skip(1).Select(e => e.ToString().Transform(o => double.Parse((string)o), 0))?.ToList() ?? new List<double>();
347+
Pans = dtxDict.GetValueOrDefault("/pans")?.GetChild<DataArray>(1)?.Children?.Select(e => e.ToString().Transform(o => double.Parse((string)o, provider: CultureInfo.InvariantCulture), 0)).ToList() ?? new List<double>();
348+
Volumes = dtxDict.GetValueOrDefault("/vols")?.GetChild<DataArray>(1)?.Children?.Select(e => e.ToString().Transform(o => double.Parse((string)o, provider: CultureInfo.InvariantCulture), 0)).ToList() ?? new List<double>();
349+
Attenuation = dtxDict.GetValueOrDefault("/active_track_db")?.Children.Skip(1).Select(e => e.ToString().Transform(o => double.Parse((string)o, provider: CultureInfo.InvariantCulture), 0))?.ToList() ?? new List<double>();
349350
ArenaPath = dtxDict.GetValueOrDefault("/arena_path")?.GetChild<string>(1);
350-
TunnelScale = dtxDict.GetValueOrDefault("/tunnel_scale")?.GetChild<double>(1, e => double.Parse(e.ToString()));
351+
TunnelScale = dtxDict.GetValueOrDefault("/tunnel_scale")?.GetChild<double>(1, e => double.Parse(e.ToString(), provider: CultureInfo.InvariantCulture));
351352
EnableOrder = dtxDict.GetValueOrDefault("/enable_order")?.GetChild<DataArray>(1)?.Children.Select(e => e.ToString().Transform(o => int.Parse((string)o), 0)).ToList() ?? new List<int>();
352353
SectionStartBars = dtxDict.GetValueOrDefault("/section_start_bars")?.Children.Skip(1)?.Select(e => e.ToString().Transform(o => int.Parse((string)o), 0))?.ToList() ?? new List<int>();
353354
Title = dtxDict.GetValueOrDefault("/title")?.GetChild<string>(1);
@@ -356,7 +357,7 @@ public MoggSong(DataArray dtx) : base()
356357
ShortArtist = dtxDict.GetValueOrDefault("/artist_short")?.GetChild<string>(1);
357358
Description = dtxDict.GetValueOrDefault("/desc")?.GetChild<string>(1);
358359
RawUnlockRequirement = dtxDict.GetValueOrDefault("/unlock_requirement")?.GetChild<string>(1);
359-
Bpm = dtxDict.GetValueOrDefault("/bpm")?.GetChild<double>(1, e => double.Parse(e.ToString()));
360+
Bpm = dtxDict.GetValueOrDefault("/bpm")?.GetChild<double>(1, e => double.Parse(e.ToString(), provider: CultureInfo.InvariantCulture));
360361
Charter = dtxDict.GetValueOrDefault("/charter")?.GetChild<string>(1)?.Trim();
361362
DemoVideo = dtxDict.GetValueOrDefault("/demo_video")?.GetChild<string>(1)?.Trim();
362363
PreviewStart = dtxDict.GetValueOrDefault("/preview_start_ms")?.GetChild<int>(1, e => int.Parse(e.ToString()));

0 commit comments

Comments
 (0)