public override void Read(CGameCtnMacroBlockInfo n, GameBoxReader r, GameBoxWriter unknownW) { n.Blocks = r.ReadArray(i => { Int3?coord = null; Direction?dir = null; Vec3?position = null; Vec3?pitchYawRoll = null; var ver = r.ReadInt32(); var ident = r.ReadIdent(); int flags = 0; if (ver >= 2) { if (ver < 5) { } flags = r.ReadInt32(); if (ver >= 4) { if ((flags & (1 << 26)) != 0) // free block { position = r.ReadVec3(); pitchYawRoll = r.ReadVec3(); } else { coord = (Int3)r.ReadByte3(); dir = (Direction)r.ReadByte(); } } } if (ver >= 3) { if (r.ReadNodeRef() != null) { throw new NotImplementedException(); } } if (ver >= 4) { if (r.ReadNodeRef() != null) { throw new NotImplementedException(); } } var correctFlags = flags & 15; if ((flags & 0x20000) != 0) // Fixes inner pillars of some blocks { correctFlags |= 0x400000; } if ((flags & 0x10000) != 0) // Fixes ghost blocks { correctFlags |= 0x10000000; } var block = new CGameCtnBlock() { BlockInfo = ident, Coord = coord.GetValueOrDefault(), Direction = dir.GetValueOrDefault(), Flags = correctFlags }; if ((flags & (1 << 26)) != 0) { block.IsFree = true; block.AbsolutePositionInMap += position.GetValueOrDefault(); block.PitchYawRoll += pitchYawRoll.GetValueOrDefault(); } return(block); }).Where(x => x != null).ToArray(); }