public void Serialize(SerializingContainer con, HeaderStruct header) { Header = header; MyOffset = (uint)con.GetPos(); if (con.isLoading) { Hash = new byte[16]; } for (int 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 { int numBlocks = (int)Math.Ceiling((double)UncompressedSize / (double)header.MaxBlockSize); if (con.isLoading) { BlockOffsets = new long[numBlocks]; BlockSizes = new ushort[numBlocks]; } BlockOffsets[0] = RealDataOffset; long pos = con.Memory.Position; con.Seek((int)getBlockOffset((int)BlockSizeIndex, header.EntryOffset, header.FileCount), SeekOrigin.Begin); BlockTableOffset = con.Memory.Position; BlockSizes[0] = con + BlockSizes[0]; for (int i = 1; i < numBlocks; i++) { BlockSizes[i] = con + BlockSizes[i]; BlockOffsets[i] = BlockOffsets[i - 1] + BlockSizes[i]; } con.Seek((int)pos, 0); } }
public void Serialize(SerializingContainer con, HeaderStruct header) { Header = header; MyOffset = (uint)con.GetPos(); if (con.isLoading) Hash = new byte[16]; for (int 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 { int numBlocks = (int)Math.Ceiling((double)UncompressedSize / (double)header.MaxBlockSize); if (con.isLoading) { BlockOffsets = new long[numBlocks]; BlockSizes = new ushort[numBlocks]; } BlockOffsets[0] = RealDataOffset; long pos = con.Memory.Position; con.Seek((int)getBlockOffset((int)BlockSizeIndex, header.EntryOffset, header.FileCount), SeekOrigin.Begin); BlockTableOffset = con.Memory.Position; BlockSizes[0] = con + BlockSizes[0]; for (int i = 1; i < numBlocks; i++) { BlockSizes[i] = con + BlockSizes[i]; BlockOffsets[i] = BlockOffsets[i - 1] + BlockSizes[i]; } con.Seek((int)pos, 0); } }