/// <summary> /// Initializes a new instance of the <see cref="DBC"/> class. /// </summary> /// <param name="inVersion">In version.</param> /// <param name="data">Data.</param> public DBC(WarcraftVersion inVersion, byte[] data) { this.Version = inVersion; using (MemoryStream ms = new MemoryStream(data)) { using (BinaryReader br = new BinaryReader(ms)) { this.Header = new DBCHeader(br.ReadBytes(DBCHeader.GetSize())); for (int i = 0; i < this.Header.RecordCount; ++i) { byte[] rawRecord = br.ReadBytes((int)this.Header.RecordSize); T record = Activator.CreateInstance <T>(); record.SetVersion(inVersion); // If the record is of the UnknownRecord type, // this DBC file will just load the data without sanity checking it. if (!(record is UnknownRecord)) { // Make sure the provided record type is valid for this database file if (record.GetRecordSize() != this.Header.RecordSize) { throw new ArgumentException("The provided record type is not valid for this database file."); } if (record.GetFieldCount() != this.Header.FieldCount) { throw new ArgumentException("The provided record type is not valid for this database file."); } } record.PostLoad(rawRecord); this.Records.Add(record); } while (br.BaseStream.Position != br.BaseStream.Length) { this.Strings.Add(br.ReadNullTerminatedString()); } } } }
/// <inheritdoc /> public void Reset() { _databaseReader.BaseStream.Seek(DBCHeader.GetSize(), SeekOrigin.Begin); _recordIndex = 0; Current = null; }
/// <inheritdoc /> public void Reset() { this.DatabaseReader.BaseStream.Seek(DBCHeader.GetSize(), SeekOrigin.Begin); this.RecordIndex = 0; this.Current = null; }