public void Serialize(SerializingFile con, DlcHeader dlcHeader) { DlcHeader = dlcHeader; MyOffset = (uint)con.GetPos(); if (con.IsLoading) { Hash = new byte[16]; } for (var i = 0; i < 16; i++) { Hash[i] = con + Hash[i]; } BlockSizeIndex = con + BlockSizeIndex; UncompressedSize = con + UncompressedSize; UncompressedSizeAdder = con + UncompressedSizeAdder; RealUncompressedSize = UncompressedSize + UncompressedSizeAdder << 32; DataOffset = con + DataOffset; DataOffsetAdder = con + DataOffsetAdder; RealDataOffset = DataOffset + DataOffsetAdder << 32; if (BlockSizeIndex == 0xFFFFFFFF) { BlockOffsets = new long[1]; BlockOffsets[0] = RealDataOffset; BlockSizes = new ushort[1]; BlockSizes[0] = (ushort)UncompressedSize; BlockTableOffset = 0; } else { var numBlocks = (int)Math.Ceiling(UncompressedSize / (double)dlcHeader.MaxBlockSize); if (con.IsLoading) { BlockOffsets = new long[numBlocks]; BlockSizes = new ushort[numBlocks]; } BlockOffsets[0] = RealDataOffset; var pos = con.Memory.Position; con.Seek((int)getBlockOffset((int)BlockSizeIndex, dlcHeader.EntryOffset, dlcHeader.FileCount), SeekOrigin.Begin); BlockTableOffset = con.Memory.Position; BlockSizes[0] = con + BlockSizes[0]; for (var i = 1; i < numBlocks; i++) { BlockSizes[i] = con + BlockSizes[i]; BlockOffsets[i] = BlockOffsets[i - 1] + BlockSizes[i]; } con.Seek((int)pos, SeekOrigin.Begin); } }
public void Serialize(SerializingFile con) { if (con.IsLoading) { _header = new DlcHeader(); } _header.Serialize(con); con.Seek((int)_header.EntryOffset, SeekOrigin.Begin); if (con.IsLoading) { DlcFiles = new DlcFileEntry[_header.FileCount]; } for (var i = 0; i < _header.FileCount; i++) { DlcFiles[i].Serialize(con, _header); } if (con.IsLoading) { ReadFileNames(con); } }