public void LoadObject(RW4Model model, RW4Object o, Stream r) { if (obj != null) { throw new ModelFormatException(r, "Attempt to decode section twice.", Number); } long start = r.Position; obj = o; o.section = this; o.model = model; r.Seek(Pos, SeekOrigin.Begin); obj.Read(model, this, r); if (r.Position != Pos + Size) { throw new ModelFormatException(r, "Section incompletely read.", Number); } var cs = obj.ComputeSize(); if (cs != -1 && cs != Size) { throw new ModelFormatException(r, "Section Size doesn't match computed Size.", Number); } r.Seek(start, SeekOrigin.Begin); }
public void AddObject(RW4Object obj, UInt32 type_code) { obj.section = InsertSection(Header.Sections.Count); obj.section.type_code = type_code; obj.section.obj = obj; obj.section.Alignment = 0x10; // by default }