@@ -18,19 +18,24 @@ static bool DecryptMaster(FileInfo inputFile, byte[] decrypted)
1818 var typeName = inputFile . Name . Replace ( ".msgpack.enc" , "" ) ;
1919 var targetType = MasterTypes . GetDeserializeType ( typeName ) ;
2020
21+ var options = MessagePackSerializerOptions . Standard . WithCompression ( MessagePackCompression . Lz4Block ) ;
22+
2123 if ( targetType == null )
2224 {
2325 Console . WriteLine ( $ "Not supported master { typeName } .") ;
24- return false ;
26+ File . WriteAllText (
27+ inputFile . FullName . Replace ( ".msgpack.enc" , ".json" ) ,
28+ MessagePackSerializer . ConvertToJson ( decrypted , options )
29+ ) ;
30+ }
31+ else
32+ {
33+ var result = MessagePackSerializer . Deserialize ( targetType , decrypted , options ) ;
34+ File . WriteAllText (
35+ inputFile . FullName . Replace ( ".msgpack.enc" , ".json" ) ,
36+ DumpToJson ( result )
37+ ) ;
2538 }
26-
27- var options = MessagePackSerializerOptions . Standard . WithCompression ( MessagePackCompression . Lz4Block ) ;
28- var result = MessagePackSerializer . Deserialize ( targetType , decrypted , options ) ;
29-
30- File . WriteAllText (
31- inputFile . FullName . Replace ( ".msgpack.enc" , ".json" ) ,
32- DumpToJson ( result )
33- ) ;
3439
3540 return true ;
3641 }
@@ -64,7 +69,7 @@ static void EncryptMaster(FileInfo inputFile)
6469 }
6570
6671 var options = MessagePackSerializerOptions . Standard . WithCompression ( MessagePackCompression . Lz4Block ) ;
67- var result = JsonConvert . DeserializeObject ( File . ReadAllText ( inputFile . FullName ) , targetType ) ;
72+ var result = JsonConvert . DeserializeObject ( File . ReadAllText ( inputFile . FullName ) , targetType , new SBConverterIntInt < ChartLessonMaster > ( ) ) ;
6873 var output = MessagePackSerializer . Serialize ( result , options ) ;
6974 var encrypted = AssetDecryptor . Encrypt ( output ) ;
7075
@@ -80,7 +85,7 @@ static void ProcessFileSystemEntry(FileSystemInfo fileSystemInfo)
8085 }
8186 else if ( fileSystemInfo is FileInfo fileInfo )
8287 {
83- if ( fileInfo . Extension == ".enc" )
88+ if ( fileInfo . Extension == ".enc" )
8489 {
8590 Console . WriteLine ( $ "Decrypting { fileInfo . Name } ...") ;
8691 var decrypted = AssetDecryptor . Decrypt ( fileInfo . OpenRead ( ) ) ;
@@ -100,24 +105,26 @@ static void ProcessFileSystemEntry(FileSystemInfo fileSystemInfo)
100105 object result = null ;
101106
102107 // Check if this is chart common data
103- if ( fileInfo . Name . EndsWith ( "0.enc" ) )
104- result = DeserializeMsgPack < ChartCommonData > ( decrypted ) ;
108+ if ( fileInfo . Name . EndsWith ( "0.enc" ) )
109+ result = DeserializeMsgPack < ChartCommonData > ( decrypted ) ;
105110 else
106111 result = DeserializeMsgPack < ChartData > ( decrypted ) ;
107-
112+
113+ var options = MessagePackSerializerOptions . Standard . WithCompression ( MessagePackCompression . Lz4Block ) ;
114+
108115 File . WriteAllText (
109116 fileInfo . FullName . Replace ( ".enc" , ".json" ) ,
110117 DumpToJson ( result )
111118 ) ;
112119
113120 success = true ;
114121 }
115- catch ( Exception ex )
122+ catch ( Exception ex )
116123 {
117124 Console . WriteLine ( $ "Failed to dump chart: { ex . Message } ") ;
118125 }
119126 }
120- else if ( fileInfo . Name . EndsWith ( "ResourceList.msgpack.enc" ) )
127+ else if ( fileInfo . Name . EndsWith ( "ResourceList.msgpack.enc" ) )
121128 {
122129 Console . WriteLine ( $ "Dumping ResourceList...") ;
123130
@@ -141,7 +148,7 @@ static void ProcessFileSystemEntry(FileSystemInfo fileSystemInfo)
141148 }
142149 else if ( fileInfo . Name . EndsWith ( "ResourceList.msgpack" ) )
143150 {
144-
151+
145152 try
146153 {
147154 var result = DeserializeMsgPack < Dictionary < string , int > > ( File . ReadAllBytes ( fileInfo . FullName ) ) ;
@@ -181,11 +188,37 @@ static void ProcessFileSystemEntry(FileSystemInfo fileSystemInfo)
181188 }
182189 }
183190 // Encrypt master back
184- else if ( fileInfo . Name . EndsWith ( "Master.json" ) )
191+ else if ( fileInfo . Name . EndsWith ( "Master.json" ) )
185192 {
186193 Console . WriteLine ( $ "Encrypting { fileInfo . Name } ...") ;
187194 EncryptMaster ( fileInfo ) ;
188195 }
196+ else if ( fileInfo . Name . StartsWith ( "chart" ) && fileInfo . Extension == ".json" )
197+ {
198+ Console . WriteLine ( "Encrypting chart..." ) ;
199+
200+ try
201+ {
202+ var json = File . ReadAllText ( fileInfo . FullName ) ;
203+
204+ object result = null ;
205+
206+ // Check if this is chart common data
207+ if ( fileInfo . Name . EndsWith ( "0.json" ) )
208+ result = JsonConvert . DeserializeObject < ChartCommonData > ( json ) ;
209+ else
210+ result = JsonConvert . DeserializeObject < ChartData > ( json ) ;
211+
212+ File . WriteAllBytes (
213+ fileInfo . FullName . Replace ( ".json" , ".enc" ) ,
214+ AssetDecryptor . Encrypt ( SerializeMsgPack ( result ) )
215+ ) ;
216+ }
217+ catch ( Exception ex )
218+ {
219+ Console . WriteLine ( $ "Failed to dump chart: { ex . Message } ") ;
220+ }
221+ }
189222 else
190223 {
191224 Console . WriteLine ( $ "Encrypting { fileInfo . Name } ...") ;
0 commit comments