public long ParseLeaves(BSP bsp, BinaryReader reader, int count) { bsp.Leaves = new List <BSP.Leaf>(); var originalPos = reader.BaseStream.Position; for (uint i = 0; i < count; ++i) { reader.BaseStream.Position = originalPos + (i * LEAF_SIZE); var flags = BitConverter.ToInt16(reader.ReadBytes(2).Reverse().ToArray(), 0); var bsp2dRefCount = BitConverter.ToUInt16(reader.ReadBytes(2).Reverse().ToArray(), 0); var Unknown = BitConverter.ToInt32(reader.ReadBytes(4).Reverse().ToArray(), 0); var first2dRef = BitConverter.ToInt16(reader.ReadBytes(2).Reverse().ToArray(), 0); var leaf = new BSP.Leaf(); leaf.Flags = flags; leaf.Bsp2dReferenceCount = (short)bsp2dRefCount; leaf.Unknown = (short)Unknown; leaf.FirstBsp2dReference = first2dRef; bsp.Leaves.Add(leaf); } return(originalPos + (count * LEAF_SIZE)); }
public long ParseLeaves(BSP bsp, BinaryReader reader, int count) { bsp.Leaves = new List<BSP.Leaf>(); var originalPos = reader.BaseStream.Position; for (uint i = 0; i < count; ++i) { reader.BaseStream.Position = originalPos + (i * LEAF_SIZE); var flags = BitConverter.ToInt16(reader.ReadBytes(2).Reverse().ToArray(), 0); var bsp2dRefCount = BitConverter.ToUInt16(reader.ReadBytes(2).Reverse().ToArray(), 0); var Unknown = BitConverter.ToInt32(reader.ReadBytes(4).Reverse().ToArray(), 0); var first2dRef = BitConverter.ToInt16(reader.ReadBytes(2).Reverse().ToArray(), 0); var leaf = new BSP.Leaf(); leaf.Flags = flags; leaf.Bsp2dReferenceCount = (short)bsp2dRefCount; leaf.Unknown = (short)Unknown; leaf.FirstBsp2dReference = first2dRef; bsp.Leaves.Add(leaf); } return originalPos + (count * LEAF_SIZE); }