1+ using System . Globalization ;
12using MuConvert . chart ;
23using MuConvert . parser ;
34using MuConvert . utils ;
@@ -90,7 +91,7 @@ private static void ParseHeaderLine(string line, UgcChart chart, List<Alert> ale
9091 break ;
9192
9293 case "@DIFF" :
93- if ( int . TryParse ( value , out var diff ) )
94+ if ( int . TryParse ( value , NumberStyles . Integer , CultureInfo . InvariantCulture , out var diff ) )
9495 {
9596 chart . Difficulty = diff switch
9697 {
@@ -109,14 +110,14 @@ private static void ParseHeaderLine(string line, UgcChart chart, List<Alert> ale
109110 break ;
110111
111112 case "@LEVEL" :
112- if ( int . TryParse ( value , out var level ) )
113+ if ( int . TryParse ( value , NumberStyles . Integer , CultureInfo . InvariantCulture , out var level ) )
113114 chart . Level = level ;
114115 else
115116 alerts . Add ( new Alert ( Warning , $ "@LEVEL 格式错误: { line } ") { Line = lineNum } ) ;
116117 break ;
117118
118119 case "@CONST" :
119- if ( double . TryParse ( value , out var constant ) )
120+ if ( double . TryParse ( value , NumberStyles . Float , CultureInfo . InvariantCulture , out var constant ) )
120121 chart . Constant = constant ;
121122 else
122123 alerts . Add ( new Alert ( Warning , $ "@CONST 格式错误: { line } ") { Line = lineNum } ) ;
@@ -127,7 +128,7 @@ private static void ParseHeaderLine(string line, UgcChart chart, List<Alert> ale
127128 break ;
128129
129130 case "@TICKS" :
130- if ( int . TryParse ( value , out var ticks ) )
131+ if ( int . TryParse ( value , NumberStyles . Integer , CultureInfo . InvariantCulture , out var ticks ) )
131132 chart . TicksPerBeat = ticks ;
132133 else
133134 alerts . Add ( new Alert ( Warning , $ "@TICKS 格式错误: { line } ") { Line = lineNum } ) ;
@@ -136,9 +137,9 @@ private static void ParseHeaderLine(string line, UgcChart chart, List<Alert> ale
136137 case "@BEAT" :
137138 var beatParts = value . Split ( ' ' ) ;
138139 if ( beatParts . Length >= 3
139- && int . TryParse ( beatParts [ 0 ] , out var beatMeasure )
140- && int . TryParse ( beatParts [ 1 ] , out var beatNum )
141- && int . TryParse ( beatParts [ 2 ] , out var beatDen ) )
140+ && int . TryParse ( beatParts [ 0 ] , NumberStyles . Integer , CultureInfo . InvariantCulture , out var beatMeasure )
141+ && int . TryParse ( beatParts [ 1 ] , NumberStyles . Integer , CultureInfo . InvariantCulture , out var beatNum )
142+ && int . TryParse ( beatParts [ 2 ] , NumberStyles . Integer , CultureInfo . InvariantCulture , out var beatDen ) )
142143 {
143144 chart . BeatEvents . Add ( ( beatMeasure , beatNum , beatDen ) ) ;
144145 }
@@ -157,9 +158,9 @@ private static void ParseHeaderLine(string line, UgcChart chart, List<Alert> ale
157158 var bpmValueStr = bpmPart [ ( bpmSpaceIdx + 1 ) ..] ;
158159 var apostropheIdx = measureOffset . IndexOf ( '\' ' ) ;
159160 if ( apostropheIdx > 0
160- && int . TryParse ( measureOffset [ ..apostropheIdx ] , out var bpmMeasure )
161- && int . TryParse ( measureOffset [ ( apostropheIdx + 1 ) ..] , out var bpmOffset )
162- && double . TryParse ( bpmValueStr , out var bpmValue ) )
161+ && int . TryParse ( measureOffset [ ..apostropheIdx ] , NumberStyles . Integer , CultureInfo . InvariantCulture , out var bpmMeasure )
162+ && int . TryParse ( measureOffset [ ( apostropheIdx + 1 ) ..] , NumberStyles . Integer , CultureInfo . InvariantCulture , out var bpmOffset )
163+ && double . TryParse ( bpmValueStr , NumberStyles . Float , CultureInfo . InvariantCulture , out var bpmValue ) )
163164 {
164165 chart . BpmEvents . Add ( ( bpmMeasure , bpmOffset , bpmValue ) ) ;
165166 }
@@ -202,12 +203,12 @@ private static int ParseNoteLine(string[] lines, int idx, UgcChart chart, List<A
202203 return idx ;
203204 }
204205
205- if ( ! int . TryParse ( prefix [ ( hashIdx + 1 ) ..apostropheIdx ] , out var measure ) )
206+ if ( ! int . TryParse ( prefix [ ( hashIdx + 1 ) ..apostropheIdx ] , NumberStyles . Integer , CultureInfo . InvariantCulture , out var measure ) )
206207 {
207208 alerts . Add ( new Alert ( Warning , $ "无法解析 measure: { line } ") { Line = lineNum } ) ;
208209 return idx ;
209210 }
210- if ( ! int . TryParse ( prefix [ ( apostropheIdx + 1 ) ..] , out var tick ) )
211+ if ( ! int . TryParse ( prefix [ ( apostropheIdx + 1 ) ..] , NumberStyles . Integer , CultureInfo . InvariantCulture , out var tick ) )
211212 {
212213 alerts . Add ( new Alert ( Warning , $ "无法解析 tick: { line } ") { Line = lineNum } ) ;
213214 return idx ;
@@ -322,7 +323,7 @@ private static bool TryParseFollowerLine(string line, out int duration, out int
322323 if ( gtSIdx < 1 ) return false ;
323324
324325 var durationStr = line [ 1 ..gtSIdx ] ;
325- if ( ! int . TryParse ( durationStr , out duration ) ) return false ;
326+ if ( ! int . TryParse ( durationStr , NumberStyles . Integer , CultureInfo . InvariantCulture , out duration ) ) return false ;
326327
327328 var afterMarker = line [ ( gtSIdx + 2 ) ..] ;
328329 if ( afterMarker . Length >= 2 )
@@ -386,7 +387,7 @@ private static void ParseAirNote(string code, ChuNote note, List<Alert> alerts,
386387 if ( underscoreIdx >= 0 && note . Type == "AHD" )
387388 {
388389 var durStr = remaining [ ( underscoreIdx + 1 ) ..] ;
389- if ( int . TryParse ( durStr , out var ahdDuration ) )
390+ if ( int . TryParse ( durStr , NumberStyles . Integer , CultureInfo . InvariantCulture , out var ahdDuration ) )
390391 note . AirHoldDuration = ahdDuration ;
391392 }
392393 }
@@ -428,3 +429,4 @@ private static string FormatNoteRef(ChuNote note)
428429 return $ "#{ note . Measure } '{ note . Offset } :{ note . Type } ";
429430 }
430431}
432+
0 commit comments