1- using Amicitia . IO . Binary ;
1+ using Amicitia . IO ;
2+ using Amicitia . IO . Binary ;
23using Amicitia . IO . Streams ;
34using J113D . Json ;
45using SA3D . Common ;
@@ -181,7 +182,7 @@ public virtual void Read(BinaryObjectReader reader)
181182 Attributes = ( byte ) ( header >> 8 ) ;
182183 }
183184
184- internal static LabeledArray < PolyChunk > ReadArray ( BinaryObjectReader reader )
185+ internal static LabeledArray < PolyChunk > ReadArray ( BinaryObjectReader reader , PointerLUT lut )
185186 {
186187 PolyChunkType peekType ( )
187188 {
@@ -194,6 +195,7 @@ PolyChunkType peekType()
194195 while ( true )
195196 {
196197 PolyChunk chunk ;
198+ long offset = reader . ReadOffsetValue ( ) ;
197199 switch ( peekType ( ) )
198200 {
199201 case PolyChunkType . BlendAlpha :
@@ -265,6 +267,7 @@ PolyChunkType peekType()
265267 }
266268
267269 chunks . Add ( chunk ) ;
270+ lut . PolyChunks . Add ( offset , chunk ) ;
268271 }
269272
270273 End :
@@ -282,10 +285,19 @@ public virtual void Write(BinaryObjectWriter writer)
282285 writer . WriteUInt16 ( ( ushort ) ( ( byte ) Type | ( Attributes << 8 ) ) ) ;
283286 }
284287
285- internal static void WriteArray ( BinaryObjectWriter writer , IEnumerable < PolyChunk > chunks )
288+ internal static void WriteArray ( BinaryObjectWriter writer , IEnumerable < PolyChunk > chunks , PointerLUT lut )
286289 {
287290 long start = writer . Position ;
288- writer . WriteObjectArray ( chunks ) ;
291+
292+ foreach ( PolyChunk chunk in chunks )
293+ {
294+ long offset = chunk . AlignWithFour
295+ ? AlignmentHelper . Align ( writer . Position , 4 )
296+ : writer . Position ;
297+
298+ writer . WriteObject ( chunk ) ;
299+ lut . PolyChunks . Add ( offset , chunk ) ;
300+ }
289301
290302 // End chunk
291303 writer . WriteUInt16 ( ( ushort ) PolyChunkType . End ) ;
0 commit comments