@@ -250,11 +250,14 @@ public static void WritePAK(string path, FileIdentifiers type, List<PAKContent>
250250 writer . BaseStream . Position = contentOffset ;
251251 List < int > offsets = new List < int > ( ) ;
252252 List < int > lengths = new List < int > ( ) ;
253+ List < int > lengthsAligned = new List < int > ( ) ;
253254 for ( int i = 0 ; i < content . Count ; i ++ )
254255 {
255256 offsets . Add ( ( int ) writer . BaseStream . Position - contentOffset ) ;
256257 writer . Write ( content [ i ] . Data ) ;
257258 lengths . Add ( ( int ) writer . BaseStream . Position - contentOffset - offsets [ offsets . Count - 1 ] ) ;
259+ Align ( writer , 16 ) ;
260+ lengthsAligned . Add ( ( int ) writer . BaseStream . Position - contentOffset - offsets [ offsets . Count - 1 ] ) ;
258261 }
259262
260263 //Write model headers
@@ -263,11 +266,11 @@ public static void WritePAK(string path, FileIdentifiers type, List<PAKContent>
263266 {
264267 writer . Write ( new byte [ 8 ] ) ;
265268 writer . Write ( e ? BigEndianUtils . FlipEndian ( ( Int32 ) lengths [ i ] ) : BitConverter . GetBytes ( ( Int32 ) lengths [ i ] ) ) ;
266- writer . Write ( e ? BigEndianUtils . FlipEndian ( ( Int32 ) lengths [ i ] ) : BitConverter . GetBytes ( ( Int32 ) lengths [ i ] ) ) ;
269+ writer . Write ( e ? BigEndianUtils . FlipEndian ( ( Int32 ) lengthsAligned [ i ] ) : BitConverter . GetBytes ( ( Int32 ) lengthsAligned [ i ] ) ) ;
267270 writer . Write ( e ? BigEndianUtils . FlipEndian ( ( Int32 ) offsets [ i ] ) : BitConverter . GetBytes ( ( Int32 ) offsets [ i ] ) ) ;
268271
269272 writer . Write ( new byte [ 5 ] ) ;
270- writer . Write ( type == FileIdentifiers . MODEL_DATA ? new byte [ 2 ] { 0x01 , 0x01 } : new byte [ 2 ] ) ;
273+ writer . Write ( type == FileIdentifiers . MODEL_DATA ? new byte [ 2 ] { 0x01 , 0x01 } : new byte [ 2 ] { 0x00 , 0x01 } ) ;
271274 writer . Write ( new byte [ 5 ] ) ;
272275
273276 writer . Write ( e ? BigEndianUtils . FlipEndian ( ( Int32 ) content [ i ] . BinIndex ) : BitConverter . GetBytes ( ( Int32 ) content [ i ] . BinIndex ) ) ;
@@ -278,12 +281,14 @@ public static void WritePAK(string path, FileIdentifiers type, List<PAKContent>
278281 writer . BaseStream . Position = 0 ;
279282 writer . Write ( new byte [ 4 ] ) ;
280283 writer . Write ( e ? BigEndianUtils . FlipEndian ( ( Int32 ) FileIdentifiers . ASSET_FILE ) : BitConverter . GetBytes ( ( Int32 ) FileIdentifiers . ASSET_FILE ) ) ;
281- writer . Write ( e ? BigEndianUtils . FlipEndian ( ( Int32 ) FileIdentifiers . MODEL_DATA ) : BitConverter . GetBytes ( ( Int32 ) FileIdentifiers . MODEL_DATA ) ) ;
284+ writer . Write ( e ? BigEndianUtils . FlipEndian ( ( Int32 ) type ) : BitConverter . GetBytes ( ( Int32 ) type ) ) ;
282285 writer . Write ( e ? BigEndianUtils . FlipEndian ( ( Int32 ) content . Count ) : BitConverter . GetBytes ( ( Int32 ) content . Count ) ) ;
283286 writer . Write ( e ? BigEndianUtils . FlipEndian ( ( Int32 ) content . Count ) : BitConverter . GetBytes ( ( Int32 ) content . Count ) ) ;
284287 writer . Write ( e ? BigEndianUtils . FlipEndian ( ( Int32 ) 16 ) : BitConverter . GetBytes ( ( Int32 ) 16 ) ) ;
285288 writer . Write ( e ? BigEndianUtils . FlipEndian ( ( Int32 ) 1 ) : BitConverter . GetBytes ( ( Int32 ) 1 ) ) ;
286- writer . Write ( e ? BigEndianUtils . FlipEndian ( ( Int32 ) 1 ) : BitConverter . GetBytes ( ( Int32 ) 1 ) ) ;
289+
290+ int unk = type == FileIdentifiers . MODEL_DATA ? 1 : 0 ;
291+ writer . Write ( e ? BigEndianUtils . FlipEndian ( ( Int32 ) unk ) : BitConverter . GetBytes ( ( Int32 ) unk ) ) ;
287292 }
288293 }
289294
0 commit comments