@@ -13,6 +13,7 @@ namespace MuConvert.chu;
1313 */
1414public class C2sParser : IParser < C2sChart >
1515{
16+ private static int RSL = 384 ;
1617 private static readonly HashSet < string > HeadTags = new ( StringComparer . OrdinalIgnoreCase )
1718 { "VERSION" , "MUSIC" , "SEQUENCEID" , "DIFFICULT" , "LEVEL" , "CREATOR" , "BPM_DEF" , "MET_DEF" , "RESOLUTION" , "CLK_DEF" , "PROGJUDGE_BPM" , "PROGJUDGE_AER" , "TUTORIAL" } ;
1819 private static readonly HashSet < string > TimingTags = new ( StringComparer . OrdinalIgnoreCase )
@@ -61,26 +62,25 @@ private static void ParseHeader(string[] p, C2sChart chart)
6162 case "MUSIC" : chart . MusicId = Int ( p , 1 ) . ToString ( ) ; break ;
6263 case "DIFFICULT" : chart . Difficulty = Int ( p , 1 ) ; break ;
6364 case "CREATOR" : chart . Designer = Str ( p , 1 ) ; break ;
64- case "RESOLUTION" : chart . Resolution = Math . Max ( 1 , Int ( p , 1 , 384 ) ) ; break ;
65+ case "RESOLUTION" : RSL = Math . Max ( 1 , Int ( p , 1 , 384 ) ) ; break ;
6566 }
6667 }
6768
6869 private static void ParseTiming ( string [ ] p , C2sChart chart )
6970 {
7071 var tag = p [ 0 ] . ToUpperInvariant ( ) ;
71- var tpm = chart . Resolution ;
7272 switch ( tag )
7373 {
7474 case "BPM" :
75- chart . BpmList . Add ( new BPM ( Int ( p , 1 ) + new Rational ( Int ( p , 2 ) , tpm ) , decimal . Parse ( p [ 3 ] ) ) ) ;
75+ chart . BpmList . Add ( new BPM ( Int ( p , 1 ) + new Rational ( Int ( p , 2 ) , RSL ) , decimal . Parse ( p [ 3 ] ) ) ) ;
7676 break ;
7777 case "MET" :
78- chart . MetList . Add ( new MET ( Int ( p , 1 ) + new Rational ( Int ( p , 2 ) , tpm ) , Int ( p , 4 , 4 ) , Int ( p , 3 , 4 ) ) ) ;
78+ chart . MetList . Add ( new MET ( Int ( p , 1 ) + new Rational ( Int ( p , 2 ) , RSL ) , Int ( p , 4 , 4 ) , Int ( p , 3 , 4 ) ) ) ;
7979 break ;
8080 case "SFL" :
8181 chart . SflList . Add ( (
82- Int ( p , 1 ) + new Rational ( Int ( p , 2 ) , tpm ) ,
83- new Rational ( Int ( p , 3 ) , tpm ) ,
82+ Int ( p , 1 ) + new Rational ( Int ( p , 2 ) , RSL ) ,
83+ new Rational ( Int ( p , 3 ) , RSL ) ,
8484 decimal . Parse ( p [ 4 ] ) ) ) ;
8585 break ;
8686 }
@@ -89,8 +89,7 @@ private static void ParseTiming(string[] p, C2sChart chart)
8989 private static void ParseNote ( string [ ] p , C2sChart chart , List < Alert > alerts , int lineNum )
9090 {
9191 var tag = p [ 0 ] . ToUpperInvariant ( ) ;
92- var tpm = chart . Resolution ;
93- var note = new ChuNote { Type = tag , Time = Int ( p , 1 ) + new Rational ( Int ( p , 2 ) , tpm ) } ;
92+ var note = new ChuNote { Type = tag , Time = Int ( p , 1 ) + new Rational ( Int ( p , 2 ) , RSL ) } ;
9493
9594 switch ( tag )
9695 {
@@ -99,10 +98,10 @@ private static void ParseNote(string[] p, C2sChart chart, List<Alert> alerts, in
9998 case "CHR" :
10099 note . Cell = Int ( p , 3 ) ; note . Width = Math . Max ( 1 , Int ( p , 4 , 1 ) ) ; note . Tag = Str ( p , 5 ) ; break ;
101100 case "HLD" : case "HXD" :
102- note . Cell = Int ( p , 3 ) ; note . Width = Math . Max ( 1 , Int ( p , 4 , 1 ) ) ; note . Duration = new Rational ( Int ( p , 5 ) , tpm ) ; break ;
101+ note . Cell = Int ( p , 3 ) ; note . Width = Math . Max ( 1 , Int ( p , 4 , 1 ) ) ; note . Duration = new Rational ( Int ( p , 5 ) , RSL ) ; break ;
103102 case "SLD" : case "SLC" : case "SXD" : case "SXC" :
104103 note . Cell = Int ( p , 3 ) ; note . Width = Math . Max ( 1 , Int ( p , 4 , 1 ) ) ;
105- note . Duration = new Rational ( Int ( p , 5 ) , tpm ) ;
104+ note . Duration = new Rational ( Int ( p , 5 ) , RSL ) ;
106105 note . EndCell = Int ( p , 6 ) ; note . EndWidth = Math . Max ( 1 , Int ( p , 7 , 1 ) ) ;
107106 break ;
108107 case "FLK" :
@@ -113,7 +112,7 @@ private static void ParseNote(string[] p, C2sChart chart, List<Alert> alerts, in
113112 break ;
114113 case "AHD" : case "AHX" :
115114 note . Cell = Int ( p , 3 ) ; note . Width = Math . Max ( 1 , Int ( p , 4 , 1 ) ) ;
116- note . TargetNote = Str ( p , 5 ) ; note . Duration = new Rational ( Int ( p , 6 ) , tpm ) ;
115+ note . TargetNote = Str ( p , 5 ) ; note . Duration = new Rational ( Int ( p , 6 ) , RSL ) ;
117116 if ( p . Length >= 8 ) note . Tag = Str ( p , 7 ) ;
118117 break ;
119118 case "ASD" : case "ASC" :
@@ -126,7 +125,7 @@ private static void ParseNote(string[] p, C2sChart chart, List<Alert> alerts, in
126125 note . Cell = Int ( p , 3 ) ; note . Width = Math . Max ( 1 , Int ( p , 4 , 1 ) ) ;
127126 note . TargetNote = Str ( p , 5 ) ;
128127 note . ExtraData = [ Int ( p , 6 ) , Int ( p , 10 ) ] ;
129- note . Duration = new Rational ( Int ( p , 7 ) , tpm ) ;
128+ note . Duration = new Rational ( Int ( p , 7 ) , RSL ) ;
130129 note . EndCell = Int ( p , 8 ) ; note . EndWidth = Math . Max ( 1 , Int ( p , 9 , 1 ) ) ;
131130 note . Tag = Str ( p , 11 ) ;
132131 break ;
0 commit comments