/// <summary> /// Load the RM2 chunk /// </summary> /// <param name="Path">Path to load from</param> public void LoadRM2(string Path) { if (System.IO.File.Exists(Path)) { System.IO.FileStream File = new System.IO.FileStream(Path, System.IO.FileMode.Open, System.IO.FileAccess.Read); System.IO.BinaryReader Reader = new System.IO.BinaryReader(File); Header = Reader.ReadUInt32(); Records = (int)Reader.ReadUInt32(); Size = Reader.ReadUInt32(); Array.Resize(ref Item, Records); for (int i = 0; i <= Records - 1; i++) { uint Offset = Reader.ReadUInt32(); uint Size = Reader.ReadUInt32(); uint ID = Reader.ReadUInt32(); uint Pos = (uint)File.Position; switch (ID) { case object _ when 0 <= ID && ID <= 7: { InstanceInfoSection InstInfo = new InstanceInfoSection(); InstInfo.Size = Size; InstInfo.Offset = Offset; InstInfo.Base = 0; InstInfo.ID = ID; InstInfo.Load(ref File, ref Reader); Item[i] = InstInfo; break; } case 10: { CodeSection Code = new CodeSection(); Code.Size = Size; Code.Offset = Offset; Code.Base = 0; Code.ID = ID; Code.Load(ref File, ref Reader); Item[i] = Code; break; } case 11: { GraphicsSection Graphics = new GraphicsSection(); Graphics.Size = Size; Graphics.Offset = Offset; Graphics.Base = 0; Graphics.ID = ID; Graphics.Load(ref File, ref Reader); Item[i] = Graphics; break; } case 9: { GeoData GD = new GeoData(); GD.Size = Size; GD.Offset = Offset; GD.Base = 0; GD.ID = ID; GD.Load(ref File, ref Reader); Item[i] = GD; break; } default: { BaseItem UItem = new BaseItem(); UItem.Size = Size; UItem.Offset = Offset; UItem.Base = 0; UItem.ID = ID; UItem.Load(ref File, ref Reader); Item[i] = UItem; break; } } File.Position = Pos; } Reader.Close(); File.Close(); } }
/// <summary> /// Load the SM2 chunk /// </summary> /// <param name="Path">Path to load from</param> public void LoadSM2(string Path) { if (System.IO.File.Exists(Path)) { System.IO.FileStream File = new System.IO.FileStream(Path, System.IO.FileMode.Open, System.IO.FileAccess.Read); System.IO.BinaryReader Reader = new System.IO.BinaryReader(File); Header = Reader.ReadUInt32(); Records = (int)Reader.ReadUInt32(); Size = Reader.ReadUInt32(); Array.Resize(ref Item, Records); for (int i = 0; i <= Records - 1; i++) { uint Offset = Reader.ReadUInt32(); uint Size = Reader.ReadUInt32(); uint ID = Reader.ReadUInt32(); uint Pos = (uint)File.Position; switch (ID) { case 6: { GraphicsSection Graphics = new GraphicsSection(); Graphics.Size = Size; Graphics.Offset = Offset; Graphics.Base = 0; Graphics.ID = ID; Graphics.Load(ref File, ref Reader); Item[i] = Graphics; break; } case 0: { Scenery SCEN = new Scenery(); SCEN.Size = Size; SCEN.Offset = Offset; SCEN.Base = 0; SCEN.ID = ID; SCEN.Load(ref File, ref Reader); Item[i] = SCEN; break; } case 5: { SubChunk SC = new SubChunk(); SC.Size = Size; SC.Offset = Offset; SC.Base = 0; SC.ID = ID; SC.Load(ref File, ref Reader); Item[i] = SC; break; } default: { BaseItem UItem = new BaseItem(); UItem.Size = Size; UItem.Offset = Offset; UItem.Base = 0; UItem.ID = ID; UItem.Load(ref File, ref Reader); Item[i] = UItem; break; } } File.Position = Pos; } Reader.Close(); File.Close(); } }