internal Record(string name, uint Size, BinaryReader br, bool Oblivion) { bool compressedRecord = false; SubRecords = new AdvancedList <SubRecord>(1); SubRecords.AllowSorting = false; Name = name; Flags1 = br.ReadUInt32(); FormID = br.ReadUInt32(); Flags2 = br.ReadUInt32(); if (!Oblivion) { Flags3 = br.ReadUInt32(); } if ((Flags1 & 0x00040000) > 0) { //Flags1 ^= 0x00040000; uint newSize = br.ReadUInt32(); br = Decompressor.Decompress(br, (int)(Size - 4), (int)newSize); Size = newSize; compressedRecord = true; } uint AmountRead = 0; while (AmountRead < Size) { string s = ReadRecName(br); uint i = 0; if (s == "XXXX") { ushort xsize = br.ReadUInt16(); if (xsize != 4) { throw new TESParserException( String.Format("Unexpected Subrecord block XXXX size! Expected 4 but found {0:D}!", xsize)); } i = br.ReadUInt32(); s = ReadRecName(br); } var r = new SubRecord(this, s, br, i); AmountRead += (uint)(r.Size2); SubRecords.Add(r); } descNameOverride = DefaultDescriptiveName; UpdateShortDescription(); //br.BaseStream.Position+=Size; if (AmountRead != Size) { System.Windows.Forms.Application.Exit(); // throw new TESParserException( // String.Format("Subrecord block did not match the size specified in the record header. Name={3} Header size={0:D} Subrecord Size={1:D} CompressedRecord={2:G}", Size, AmountRead, compressedRecord, name)); } }
internal Record(string name, uint Size, BinaryReader br, bool Oblivion) { SubRecords = new AdvancedList <SubRecord>(1); SubRecords.AllowSorting = false; Name = name; Flags1 = br.ReadUInt32(); FormID = br.ReadUInt32(); Flags2 = br.ReadUInt32(); if (!Oblivion) { Flags3 = br.ReadUInt32(); } if ((Flags1 & 0x00040000) > 0) { //Flags1 ^= 0x00040000; uint newSize = br.ReadUInt32(); br = Decompressor.Decompress(br, (int)(Size - 4), (int)newSize); Size = newSize; } uint AmountRead = 0; while (AmountRead < Size) { string s = ReadRecName(br); uint i = 0; if (s == "XXXX") { br.ReadUInt16(); i = br.ReadUInt32(); s = ReadRecName(br); } var r = new SubRecord(this, s, br, i); AmountRead += (uint)(r.Size2); SubRecords.Add(r); } if (AmountRead > Size) { throw new TESParserException("Subrecord block did not match the size specified in the record header"); } descNameOverride = DefaultDescriptiveName; UpdateShortDescription(); //br.BaseStream.Position+=Size; }