public CMSN(byte[] Data) { Sections = new List <BaseSection>(); EndianBinaryReaderEx er = new EndianBinaryReaderEx(new MemoryStream(Data), Endianness.LittleEndian); Header = new CMSNHeader(er); er.BaseStream.Position = Header.SectionTableOffset; uint sections = er.ReadUInt32(); for (int i = 0; i < sections; i++) { uint sectionType = er.ReadUInt32(); uint sectionOffset = er.ReadUInt32(); long prevPos = er.BaseStream.Position; er.BaseStream.Position = sectionOffset + Header.SectionsOffset; switch ((BaseSection.SectionType)sectionType) { case BaseSection.SectionType.DriverOptions: Sections.Add(new DriverOptionsSection(er)); break; case BaseSection.SectionType.MissionFlags: Sections.Add(new MissionFlagsSection(er)); break; case BaseSection.SectionType.ItemOptions: Sections.Add(new ItemOptionsSection(er)); break; default: throw new NotImplementedException("Section " + sectionType + " not implemented!"); } er.BaseStream.Position = prevPos; } }
public CMSN() { Header = new CMSNHeader(); Sections = new List <BaseSection>(); Sections.Add(new DriverOptionsSection()); Sections.Add(new MissionFlagsSection()); Sections.Add(new ItemOptionsSection()); }