@@ -202,6 +202,32 @@ static bool CreateBatchArchive(string file, string outZip)
202202 return true ;
203203 }
204204
205+
206+ static bool CreateBatchArchive2 ( string file , string outZip )
207+ {
208+ if ( File . Exists ( outZip ) )
209+ {
210+ return true ;
211+ }
212+ using var zip = new ZipArchive ( File . Create ( outZip ) , ZipArchiveMode . Create ) ;
213+ ReadOnlySpan < byte > data = File . ReadAllBytes ( file ) ;
214+ int entryCount = BitConverter . ToInt32 ( data ) ;
215+ var assets = MemoryMarshal . Cast < byte , ulong > ( data . Slice ( 4 , entryCount * sizeof ( ulong ) ) ) ;
216+ var remaining = data [ ( sizeof ( int ) + entryCount * sizeof ( ulong ) ) ..] ;
217+ foreach ( var ( id , fileSize ) in assets )
218+ {
219+ if ( ! LuaDict . TryGetValue ( id , out var name ) )
220+ {
221+ name = id . ToString ( ) ;
222+ Console . WriteLine ( $ "Unknown lua:{ id } ") ;
223+ }
224+ using var entry = zip . CreateEntry ( $ "{ name } .lua_bxml") . Open ( ) ;
225+ entry . Write ( remaining [ ..fileSize ] ) ;
226+ remaining = remaining [ fileSize ..] ;
227+ }
228+ return true ;
229+ }
230+
205231 static Dictionary < uint , uint > BuildParentDict ( )
206232 {
207233 using var zarchive = ZipFile . OpenRead ( @"..\..\..\simtypes_unpacked.zip" ) ;
@@ -223,6 +249,7 @@ static Dictionary<uint, uint> BuildParentDict()
223249 return dictionary ;
224250 }
225251 static readonly Dictionary < uint , string > SimtypeDict = BuildSimtypeDict ( ) ;
252+ static readonly Dictionary < uint , string > LuaDict = BuildSimtypeDict ( @"C:\e\symbol_table_luascript.bin" ) ;
226253 static readonly HashSet < string > Supers ;
227254 static readonly Dictionary < string , uint > ReverseSimtype = SimtypeDict . ToDictionary ( x => x . Value , x => x . Key ) ;
228255 static readonly bool WhoCares = CreateBatchArchive ( @"C:\e\134225858_ksmt.batch" , @"..\..\..\simtypes_unpacked.zip" ) ;
@@ -232,9 +259,9 @@ static Dictionary<uint, uint> BuildParentDict()
232259
233260 static readonly HashSet < uint > ScalingVariants = BuildVariants ( ) ;
234261
235- private static Dictionary < uint , string > BuildSimtypeDict ( )
262+ private static Dictionary < uint , string > BuildSimtypeDict ( string bin = @"C:\e\symbol_table_simtype.bin" )
236263 {
237- var data = File . ReadAllBytes ( @"C:\e\symbol_table_simtype. bin" ) ;
264+ var data = File . ReadAllBytes ( bin ) ;
238265 var elementCount = BitConverter . ToInt32 ( data , 0 ) ;
239266 var firstString = 8 + elementCount * 12 ;
240267 return Enumerable . Range ( 0 , elementCount ) . Select ( x => ( id : BitConverter . ToUInt32 ( data , 4 + x * 12 ) , s : BitConverter . ToInt32 ( data , 4 + x * 12 + 4 ) , e : BitConverter . ToInt32 ( data , 4 + x * 12 + 8 ) ) )
@@ -357,6 +384,7 @@ static HashSet<uint> BuildVariants()
357384 }
358385 static void Main ( )
359386 {
387+ CreateBatchArchive2 ( @"C:\e\134230570_klua.batch" , @"C:\e\o\klua.zip" ) ;
360388 ParseOutItemInformationTemplate ( ) ;
361389 //CreateSimTypeCsv(@"C:\e\symbol_table_globalobjectref.bin", @"..\..\..\gor.csv");
362390 ConvertSymbolsToLua ( @"C:\e\" , @"C:\Program Files (x86)\Steam\steamapps\common\Kingdoms of Amalur Re-Reckoning\mods\resources\" , "simtype" , "buff" ) ;
0 commit comments