public override void Read(BinaryReader file, uint size) { //Read the 8 unknown bytes. Unknown1.Read(file, 4); Unknown2.Read(file, 4); //Read the resources list. var numresources = file.ReadVLQInt32(); for (int i = 0; i < numresources; i++) { var temp = new CSectorDataResource(cr2w); temp.Read(file, 24); Resources.AddVariable(temp); } //Read the Objects list. var numobjects = file.ReadVLQInt32(); for (int i = 0; i < numobjects; i++) { var temp = new CSectorDataObject(cr2w); temp.Read(file, 32); Objects.AddVariable(temp); } //Read the data block. var datasize = file.ReadVLQInt32(); BlockData.Bytes = file.ReadBytes(datasize); }
public override void Read(BinaryReader file, uint size) { //Read the 8 unknown bytes. Unknown1.Read(file, 4); Unknown2.Read(file, 4); //Read the resources list. var numresources = file.ReadVLQInt32(); for (int i = 0; i < numresources; i++) { var temp = new CSectorDataResource(cr2w); temp.Read(file, 24); Resources.AddVariable(temp); } //Read the Objects list. var numobjects = file.ReadVLQInt32(); for (int i = 0; i < numobjects; i++) { var temp = new CSectorDataObject(cr2w); temp.Read(file, 32); Objects.AddVariable(temp); } // Read the data block. var datasize = file.ReadVLQInt32(); BlockData.Bytes = file.ReadBytes(datasize); // add blockdata per object instead of in the end of the file // we do it after we read the array for easier writing for (int i = 0; i < numobjects; i++) { CSectorDataObject curobj = (CSectorDataObject)Objects.GetEditableVariables()[i]; int curoffset = int.Parse(curobj.offset.ToString()); int nextoffset = datasize; if (i != numobjects - 1) { CSectorDataObject nextobj = (CSectorDataObject)Objects.GetEditableVariables()[i + 1]; nextoffset = int.Parse(nextobj.offset.ToString()); } int length = nextoffset - curoffset; byte[] cutoutdata = new byte[length]; Array.Copy(BlockData.Bytes, curoffset, cutoutdata, 0, length); curobj.blockdata.Bytes = cutoutdata; } }