@@ -262,23 +262,11 @@ private record AllChartsEntry(string chartText, MaiChart simaiSharpChart);
262262
263263 [ GeneratedRegex ( @"^(MET\t\d+\t\d+\t\d+\t)(\d+\s*)$" , RegexOptions . Multiline ) ]
264264 private static partial Regex FirstMetLineRegex ( ) ;
265-
266- private static string replaceGroup2ByRegex ( string input , Match match , int value )
267- {
268- if ( ! match . Success ) return input ;
269- return string . Concat (
270- input . AsSpan ( 0 , match . Index ) ,
271- match . Groups [ 1 ] . ValueSpan ,
272- value . ToString ( CultureInfo . InvariantCulture ) ,
273- input . AsSpan ( match . Index + match . Length ) ) ;
274- }
275265
276266 private static string ApplyClockCountToFirstMetLine ( string ma2Content , int clockCount )
277267 {
278- var clockdefMatch = ClockDefRegex ( ) . Match ( ma2Content ) ;
279- ma2Content = replaceGroup2ByRegex ( ma2Content , clockdefMatch , 96 * clockCount ) ;
280- var metMatch = FirstMetLineRegex ( ) . Match ( ma2Content ) ;
281- ma2Content = replaceGroup2ByRegex ( ma2Content , metMatch , clockCount ) ;
268+ ma2Content = ClockDefRegex ( ) . Replace ( ma2Content , $ "${{1}}{ 96 * clockCount } ", 1 ) ;
269+ ma2Content = FirstMetLineRegex ( ) . Replace ( ma2Content , $ "${{1}}{ clockCount } ", 1 ) ;
282270 return ma2Content ;
283271 }
284272
@@ -439,7 +427,8 @@ public ImportChartResult ImportMaidata(
439427 // 如果maidata中声明了clock_count,应用之,修改CLOCK_DEF和MET
440428 if ( int . TryParse ( maiData . GetValueOrDefault ( "clock_count" ) , out var clockCount ) )
441429 {
442- shiftedConverted = ApplyClockCountToFirstMetLine ( shiftedConverted , clockCount ) ;
430+ if ( clockCount > 0 ) shiftedConverted = ApplyClockCountToFirstMetLine ( shiftedConverted , clockCount ) ;
431+ else errors . Add ( new ImportChartMessage ( "the \" &clock_count\" value in this maidata is invalid thus ignored." , MessageLevel . Warning ) ) ;
443432 }
444433
445434 // Just use T_NUM_ALL value in ma2 file
0 commit comments