public Record() { Name = "NEW_"; this.SubRecords = new AdvancedList<SubRecord>(); this.descNameOverride = this.DefaultDescriptiveName; this.UpdateShortDescription(); this.FixSubrecordOwner(); }
private Record(SerializationInfo info, StreamingContext context) : base(info, context) { if (serializationItems == null) serializationItems = new Dictionary<Record, SubRecord[]>(); serializationItems[this] = info.GetValue("SubRecords", typeof (SubRecord[])) as SubRecord[]; SubRecords = new AdvancedList<SubRecord>(1); descNameOverride = DefaultDescriptiveName; UpdateShortDescription(); }
private Record(SerializationInfo info, StreamingContext context) : base(info, context) { if (serializationItems == null) { serializationItems = new Dictionary <Record, SubRecord[]>(); } serializationItems[this] = info.GetValue("SubRecords", typeof(SubRecord[])) as SubRecord[]; SubRecords = new AdvancedList <SubRecord>(1); descNameOverride = DefaultDescriptiveName; UpdateShortDescription(); }
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)); } }
private LocalizedStringDict GetStringDict(Plugin plugin, LocalizedStringFormat format) { LocalizedStringDict strings = null; switch (format) { case LocalizedStringFormat.Base: strings = plugin.Strings; break; case LocalizedStringFormat.DL: strings = plugin.DLStrings; break; case LocalizedStringFormat.IL: strings = plugin.ILStrings; break; } return(strings); }
private Record(Record r) { SubRecords = new AdvancedList <SubRecord>(r.SubRecords.Count); SubRecords.AllowSorting = false; foreach (var sr in r.SubRecords.OfType <SubRecord>()) { SubRecords.Add((SubRecord)sr.Clone()); } Flags1 = r.Flags1; Flags2 = r.Flags2; Flags3 = r.Flags3; FormID = r.FormID; Name = r.Name; descNameOverride = DefaultDescriptiveName; UpdateShortDescription(); FixSubrecordOwner(); }
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; }
public AdvancedList<SheetDTO> GetSheetDTOByDate(DateTime date) { AdvancedList<SheetDTO> sheetsDTO = new AdvancedList<SheetDTO>(); foreach (var sheet in sheets.Where(s => s.start.Date.Equals(date.Date) && s.job != null)) { SheetDTO sheetDTO = new SheetDTO(); sheetDTO.JobName = sheet.job.name; sheetDTO.JobNum = sheet.job.number.ToString(); sheetDTO.TaskNum = sheet.job.task.number.ToString(); sheetDTO.TaskName = sheet.job.task.name; sheetDTO.ProjectNum = sheet.job.task.project.number.ToString(); sheetDTO.ProjectName = sheet.job.task.project.name; sheetDTO.Start = sheet.start.ToLongTimeString(); sheetDTO.End = sheet.end.ToLongTimeString(); sheetDTO.Duration = sheet.end.Subtract(sheet.start).ToString(); sheetDTO.Note = sheet.note; sheetsDTO.Add(sheetDTO); } if (actualSheet != null && actualSheet.start.Date.Equals(date.Date)) { SheetDTO sheetDTO = new SheetDTO(); sheetDTO.JobNum = actualSheet.job.number.ToString(); sheetDTO.JobName = actualSheet.job.name; sheetDTO.TaskNum = actualSheet.job.task.number.ToString(); sheetDTO.TaskName = actualSheet.job.task.name; sheetDTO.ProjectNum = actualSheet.job.task.project.number.ToString(); sheetDTO.ProjectName = actualSheet.job.task.project.name; sheetDTO.Start = actualSheet.start.ToLongTimeString(); sheetsDTO.Add(sheetDTO); } return sheetsDTO; }
private Record(Record r) { this.SubRecords = new AdvancedList<SubRecord>(r.SubRecords.Count); this.SubRecords.AllowSorting = false; foreach (var sr in r.SubRecords.OfType<SubRecord>()) { this.SubRecords.Add((SubRecord) sr.Clone()); } this.Flags1 = r.Flags1; this.Flags2 = r.Flags2; this.Flags3 = r.Flags3; this.FormID = r.FormID; Name = r.Name; this.descNameOverride = this.DefaultDescriptiveName; this.UpdateShortDescription(); this.FixSubrecordOwner(); }
internal Record(string name, uint dataSize, BinaryReader recordReader, FalloutSnip.Domain.Data.DomainDefinition define) { this.dataSize = dataSize; int estimatedCount = Math.Max( Math.Min(16, (int)dataSize/10), 0 ); SubRecords = new AdvancedList<SubRecord>(estimatedCount) { AllowSorting = false }; Name = name; Flags1 = recordReader.ReadUInt32(); FormID = recordReader.ReadUInt32(); if (define.RecSize >= 12) Flags2 = recordReader.ReadUInt32(); if (define.RecSize >= 16) Flags3 = recordReader.ReadUInt32(); bool compressed = (Flags1 & 0x00040000) != 0; uint amountRead = 0; uint realSize = dataSize; if (compressed) { realSize = recordReader.ReadUInt32(); dataSize -= 4; } using (var stream = new MemoryStream(recordReader.ReadBytes((int)dataSize),false)) using (var br = new BinaryReader(stream)) { var dataReader = compressed ? Decompressor.Decompress(br, (int)dataSize, (int)realSize, out compressLevel) : br; { while (true) { long left = dataReader.BaseStream.Length - dataReader.BaseStream.Position; if (left < 4) { break; } string type = ReadRecName(dataReader); uint size; if (type == "XXXX") { dataReader.ReadUInt16(); size = dataReader.ReadUInt32(); type = ReadRecName(dataReader); dataReader.ReadUInt16(); } else { size = define.HEDRRecSize == 2 ? dataReader.ReadUInt16() : dataReader.ReadUInt32(); } var record = new SubRecord(this, type, dataReader, size); SubRecords.Add(record); amountRead += (uint)record.Size2; } } } if (amountRead > realSize) { Debug.Print( " * ERROR: SUB-RECORD {0} DATA DOESN'T MATCH THE SIZE SPECIFIED IN THE HEADER: DATA-SIZE={1} REAL-SIZE={2} AMOUNT-READ={3}", name, dataSize, realSize, amountRead); throw new TESParserException( string.Format( "Subrecord block did not match the size specified in the record header: ExpectedSize={0} ReadSize={1} DataSize={2}", realSize, amountRead, dataSize)); } descNameOverride = DefaultDescriptiveName; UpdateShortDescription(); // br.BaseStream.Position+=Size; }
private LocalizedStringDict GetStringDict(Plugin plugin, LocalizedStringFormat format) { LocalizedStringDict strings = null; switch (format) { case LocalizedStringFormat.Base: strings = plugin.Strings; break; case LocalizedStringFormat.DL: strings = plugin.DLStrings; break; case LocalizedStringFormat.IL: strings = plugin.ILStrings; break; } return strings; }
internal Record(string name, uint dataSize, BinaryReader recordReader, bool oblivion) { this.dataSize = dataSize; SubRecords = new AdvancedList<SubRecord>(1) { AllowSorting = false }; Name = name; Flags1 = recordReader.ReadUInt32(); FormID = recordReader.ReadUInt32(); Flags2 = recordReader.ReadUInt32(); if (!oblivion) { Flags3 = recordReader.ReadUInt32(); } var compressed = (Flags1 & 0x00040000) != 0; uint amountRead = 0; var realSize = dataSize; if (compressed) { realSize = recordReader.ReadUInt32(); dataSize -= 4; } using (var stream = new MemoryStream(recordReader.ReadBytes((int)dataSize))) { using (var dataReader = compressed ? ZLib.Decompress(stream, (int)realSize) : new BinaryReader(stream)) { while (dataReader.BaseStream.Position < dataReader.BaseStream.Length) { var type = ReadRecName(dataReader); uint size; if (type == "XXXX") { dataReader.ReadUInt16(); size = dataReader.ReadUInt32(); type = ReadRecName(dataReader); dataReader.ReadUInt16(); } else { size = dataReader.ReadUInt16(); } var record = new SubRecord(this, type, dataReader, size); SubRecords.Add(record); amountRead += (uint)record.Size2; } } } if (amountRead > realSize) { Debug.Print(" * ERROR: SUB-RECORD {0} DATA DOESN'T MATCH THE SIZE SPECIFIED IN THE HEADER: DATA-SIZE={1} REAL-SIZE={2} AMOUNT-READ={3}", name, dataSize, realSize, amountRead); throw new TESParserException(string.Format("Subrecord block did not match the size specified in the record header: ExpectedSize={0} ReadSize={1} DataSize={2}", realSize, amountRead, dataSize)); } descNameOverride = DefaultDescriptiveName; UpdateShortDescription(); //br.BaseStream.Position+=Size; }
public Record() { Name = "NEW_"; SubRecords = new AdvancedList<SubRecord>(); descNameOverride = DefaultDescriptiveName; UpdateShortDescription(); FixSubrecordOwner(); }
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; }
internal Record(string name, uint dataSize, BinaryReader recordReader, bool oblivion) { this.dataSize = dataSize; this.SubRecords = new AdvancedList <SubRecord>(1) { AllowSorting = false }; Name = name; this.Flags1 = recordReader.ReadUInt32(); this.FormID = recordReader.ReadUInt32(); this.Flags2 = recordReader.ReadUInt32(); if (!oblivion) { this.Flags3 = recordReader.ReadUInt32(); } var compressed = (this.Flags1 & 0x00040000) != 0; uint amountRead = 0; var realSize = dataSize; if (compressed) { realSize = recordReader.ReadUInt32(); dataSize -= 4; } using (var stream = new MemoryStream(recordReader.ReadBytes((int)dataSize))) { using (var dataReader = compressed ? ZLib.Decompress(stream, (int)realSize) : new BinaryReader(stream)) { while (dataReader.BaseStream.Position < dataReader.BaseStream.Length) { var type = ReadRecName(dataReader); uint size; if (type == "XXXX") { dataReader.ReadUInt16(); size = dataReader.ReadUInt32(); type = ReadRecName(dataReader); dataReader.ReadUInt16(); } else { size = dataReader.ReadUInt16(); } var record = new SubRecord(this, type, dataReader, size); this.SubRecords.Add(record); amountRead += (uint)record.Size2; } } } if (amountRead > realSize) { Debug.Print(" * ERROR: SUB-RECORD {0} DATA DOESN'T MATCH THE SIZE SPECIFIED IN THE HEADER: DATA-SIZE={1} REAL-SIZE={2} AMOUNT-READ={3}", name, dataSize, realSize, amountRead); throw new TESParserException( string.Format("Subrecord block did not match the size specified in the record header: ExpectedSize={0} ReadSize={1} DataSize={2}", realSize, amountRead, dataSize)); } this.descNameOverride = this.DefaultDescriptiveName; this.UpdateShortDescription(); // br.BaseStream.Position+=Size; }
internal Record(string name, uint dataSizeParam, SnipStreamWrapper snipStreamWrapper, bool oblivion) //internal Record(string name, uint dataSize, BinaryReader recordReader, bool oblivion) { bool compressed = false; uint amountRead = 0; uint realSize = 0; //MemoryStream stream = null; //BinaryReader dataReader = null; SubRecord record = null; //long ws; try { this.dataSize = dataSizeParam; this.SubRecords = new AdvancedList<SubRecord>(1) {AllowSorting = false}; //if (snipStreamWrapper.SnipStream.Position >= 1330432) // Name = name; Name = name; RecordsTace.AddRecordToRecordsList(Name); this.Flags1 = snipStreamWrapper.ReadUInt32(); //recordReader.ReadUInt32(); this.FormID = snipStreamWrapper.ReadUInt32(); //recordReader.ReadUInt32(); this.Flags2 = snipStreamWrapper.ReadUInt32(); //recordReader.ReadUInt32(); if (!oblivion) { this.Flags3 = snipStreamWrapper.ReadUInt32(); //recordReader.ReadUInt32(); } //if (this.FormID == 496431) // Name = name; compressed = (this.Flags1 & 0x00040000) != 0; amountRead = 0; realSize = dataSizeParam; if (!compressed) realSize = dataSizeParam; if (compressed) { realSize = snipStreamWrapper.ReadUInt32(); // recordReader.ReadUInt32(); // snipStreamWrapper.JumpTo(-4,SeekOrigin.Current); //if (realSize > 0) dataSizeParam -= 4; RecordsTace.AddRecordToCompressedRecordsList(Name); } #if DEBUGCOMPRESSREALSIZE if (compressed & realSize == 0) { Clipboard.SetText(name + " - " + this.FormID.ToString(CultureInfo.InvariantCulture)); } #endif //using (var stream = new MemoryStream(recordReader.ReadBytes((int) dataSize))) //{ //using (var dataReader = compressed ? ZLib.Decompress(stream, (int) realSize) : new BinaryReader(stream)) //{. try { //if (dataSize == 0) // throw new TESParserException("Record.Record: ZLib inflate error. Output buffer is empty."); if (dataSizeParam > 0) //dawnguard.esm at position 6.812.369 at a dataSize == 0 - Record=NAVM { ZLibWrapper.CopyStreamToInputBuffer(snipStreamWrapper.SnipStream, dataSizeParam); //stream = new MemoryStream(recordReader.ReadBytes((int) dataSize)); //dataReader = compressed ? ZLib.Decompress(stream, out compressLevel, (int)realSize) : new BinaryReader(stream); if (compressed & realSize > 0) { //Clipboard.SetText(Name + realSize.ToString(CultureInfo.InvariantCulture)); ZLib.Decompress(compressLevel: out compressLevel, expectedSize: (int) realSize); //Array.Copy(); } else { ZLibWrapper.CopyInputBufferToOutputBuffer(dataSizeParam); } } else { ZLibWrapper.ResetBufferSizeAndPosition(); } } catch (Exception ex) { throw new TESParserException("Record.Record: ZLib error" + Environment.NewLine + "Message: " + ex.Message + Environment.NewLine + "StackTrace: " + ex.StackTrace); } if (compressed & dataSizeParam > 0) //dawnguard.esm at position 6.812.369 at a dataSize == 0 - Record=NAVM if (ZLibWrapper.OutputBufferLength <= 0) //if (dataReader == null) { throw new TESParserException("Record.Record: ZLib inflate error. Output buffer is empty."); } while (ZLibWrapper.OutputBufferPosition < ZLibWrapper.OutputBufferLength) //while (dataReader.BaseStream.Position < dataReader.BaseStream.Length) { var type = "XXXX"; uint size = 0; if (realSize == 0) //compressed & { type = "????"; //ReadRecName(ZLibWrapper.Read4Bytes()); size = dataSizeParam; //realSize = dataSizeParam; //this.dataSize = dataSizeParam; } else { type = ReadRecName(ZLibWrapper.Read4Bytes()); //var type = ReadRecName(dataReader); if (type == "XXXX") { ZLibWrapper.ReadUInt16(); //dataReader.ReadUInt16(); size = ZLibWrapper.ReadUInt32(); //dataReader.ReadUInt32(); type = ReadRecName(ZLibWrapper.Read4Bytes()); //ReadRecName(dataReader); ZLibWrapper.ReadUInt16(); //dataReader.ReadUInt16(); } else { size = ZLibWrapper.ReadUInt16(); //dataReader.ReadUInt16(); } } record = new SubRecord(this, type, snipStreamWrapper, size); //record = new SubRecord(this, type, dataReader, size); //var record = new SubRecord(this, type, dataReader, size); this.SubRecords.Add(record); amountRead += (uint) record.Size2; } //} //using (var dataReader = compressed ? ZLib.Decompress(stream, (int) realSize) : new BinaryReader(stream)) //if (dataReader != null) //{ // dataReader.Close(); // dataReader.Dispose(); // dataReader = null; //} if ((compressed & realSize != 0) | (!compressed)) if (amountRead > realSize) { Debug.Print( " * ERROR: SUB-RECORD {0} DATA DOESN'T MATCH THE SIZE SPECIFIED IN THE HEADER: DATA-SIZE={1} REAL-SIZE={2} AMOUNT-READ={3}", name, dataSizeParam, realSize, amountRead); throw new TESParserException( string.Format( "Subrecord block did not match the size specified in the record header: ExpectedSize={0} ReadSize={1} DataSize={2}", realSize, amountRead, dataSizeParam)); } this.descNameOverride = this.DefaultDescriptiveName; this.UpdateShortDescription(); // br.BaseStream.Position+=Size; //} //using (var stream = new MemoryStream(recordReader.ReadBytes((int) dataSize))) } catch (Exception ex) { string errMsg = "Message: " + ex.Message + Environment.NewLine + Environment.NewLine + "StackTrace: " + ex.StackTrace + Environment.NewLine + Environment.NewLine + "Source: " + ex.Source + Environment.NewLine + Environment.NewLine + "GetType: " + ex.GetType().ToString(); System.Windows.Forms.Clipboard.SetDataObject(errMsg, true); // Create an EventLog instance and assign its source. EventLog myLog = new EventLog(); myLog.Source = "ThreadException"; myLog.WriteEntry(errMsg); MessageBox.Show(errMsg, "Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); } finally { //if (stream != null) //{ // stream.Close(); // stream.Dispose(); //} } }
public AdvancedComboBox() { this.OnChangeHandler = new OnChangeDelegate(this.OnChangeSafe); this.OnItemRemovedHandler = new OnItemRemovedDelegate(this.OnItemRemovedSafe); base.AutoScroll = false; base.Size = new Size(100, 0x12); this.m_dbConnector = new Resco.Controls.AdvancedComboBox.DataConnector(); this.m_connector = this.m_dbConnector; this.m_bKeyNavigation = true; this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.m_list = new AdvancedList(this); this.m_list.Capture = false; this.m_list.Visible = false; this.m_list.TouchScrolling = false; this.m_list.BorderStyle = this.BorderStyle;//.set_BorderStyle(this.BorderStyle); this.m_list.Size = new Size(0, 0); this.m_list.ItemSelect += new ItemEventHandler(this.OnItemSelect); this.m_list.Changed += new ComboBoxEventHandler(this.OnChange); this.SelectedIndexChanged = null; this.SelectedValueChanged = null; this.ValueMemberChanged = null; this.DisplayMemberChanged = null; this.m_items = new ItemCollection(this); this.m_items.Changed += new ComboBoxEventHandler(this.OnChange); this.m_iExpectedItems = -1; this.m_nItemsLoaded = 0; this.m_nItemsInserted = 0; this.m_selectedItemIndex = -1; this.m_iSelectedCellIndex = -1; this.m_valueMember = ""; this.m_displayMember = ""; this.m_tsCurrent = new TemplateSet(); this.m_tsCurrent.Parent = this; this.m_tsCurrent.Changed += new ComboBoxEventHandler(this.OnChange); this.m_textBoxTemplateIndex = 0; this.m_templateIndex = 0; this.m_selectedTemplateIndex = 0; this.m_alternateTemplateIndex = -1; this.m_grBackBuffer = null; this.m_backBuffer = null; this.m_colorKey = Color.FromArgb(0xff, 0, 0xff); this.m_brushKey = new SolidBrush(this.m_colorKey); this.m_imgAttr = new ImageAttributes(); this.m_imgAttr.SetColorKey(this.m_colorKey, this.m_colorKey); this.UpdateDoubleBuffering(); base.BackColor = SystemColors.ControlLight; this.m_BackColor = new SolidBrush(this.BackColor); this.m_Timer = new Timer(); this.m_Timer.Enabled = false; this.m_Timer.Interval = 500; this.m_Timer.Tick += new EventHandler(this.OnTimerTick); this.m_bShowingToolTip = false; point1 = new Point(0, 0); point2 = new Point(0, -TooltipWidth); point3 = new Point(-TooltipWidth, 0); this.CalculateTextBoxArea(); }
protected override void Dispose(bool disposing) { if (sBrushes != null) { sBrushes.Clear(); } sBrushes = null; if (disposing && (this.m_list != null)) { this.m_list.Dispose(); this.m_list = null; } this.m_items = null; this.m_tsCurrent = null; if (this.m_alLinks != null) { this.m_alLinks.Clear(); } this.m_alLinks = null; if (this.m_alTooltips != null) { this.m_alTooltips.Clear(); } this.m_alTooltips = null; if (this.m_alButtons != null) { this.m_alButtons.Clear(); } this.m_alButtons = null; if (this.m_dbConnector != null) { this.m_dbConnector.Dispose(); this.m_dbConnector = null; } this.ButtonClick = null; this.CellClick = null; this.LinkClick = null; this.DropDown = null; this.DropDownClosed = null; this.SelectedIndexChanged = null; this.SelectedValueChanged = null; this.ValueMemberChanged = null; this.DisplayMemberChanged = null; Utility.Dispose(); Links.Dispose(); Resco.Controls.AdvancedComboBox.Mapping.DisposeEmptyMapping(); ImageCache.GlobalCache.Clear(); GC.Collect(); base.Dispose(disposing); }
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 dataSizeParam, SnipStreamWrapper snipStreamWrapper, bool oblivion) //internal Record(string name, uint dataSize, BinaryReader recordReader, bool oblivion) { bool compressed = false; uint amountRead = 0; uint realSize = 0; //MemoryStream stream = null; //BinaryReader dataReader = null; SubRecord record = null; //long ws; try { this.dataSize = dataSizeParam; this.SubRecords = new AdvancedList <SubRecord>(1) { AllowSorting = false }; //if (snipStreamWrapper.SnipStream.Position >= 1330432) // Name = name; Name = name; RecordsTace.AddRecordToRecordsList(Name); this.Flags1 = snipStreamWrapper.ReadUInt32(); //recordReader.ReadUInt32(); this.FormID = snipStreamWrapper.ReadUInt32(); //recordReader.ReadUInt32(); this.Flags2 = snipStreamWrapper.ReadUInt32(); //recordReader.ReadUInt32(); if (!oblivion) { this.Flags3 = snipStreamWrapper.ReadUInt32(); //recordReader.ReadUInt32(); } //if (this.FormID == 496431) // Name = name; compressed = (this.Flags1 & 0x00040000) != 0; amountRead = 0; realSize = dataSizeParam; if (!compressed) { realSize = dataSizeParam; } if (compressed) { realSize = snipStreamWrapper.ReadUInt32(); // recordReader.ReadUInt32(); // snipStreamWrapper.JumpTo(-4,SeekOrigin.Current); //if (realSize > 0) dataSizeParam -= 4; RecordsTace.AddRecordToCompressedRecordsList(Name); } #if DEBUGCOMPRESSREALSIZE if (compressed & realSize == 0) { Clipboard.SetText(name + " - " + this.FormID.ToString(CultureInfo.InvariantCulture)); } #endif //using (var stream = new MemoryStream(recordReader.ReadBytes((int) dataSize))) //{ //using (var dataReader = compressed ? ZLib.Decompress(stream, (int) realSize) : new BinaryReader(stream)) //{. try { //if (dataSize == 0) // throw new TESParserException("Record.Record: ZLib inflate error. Output buffer is empty."); if (dataSizeParam > 0) //dawnguard.esm at position 6.812.369 at a dataSize == 0 - Record=NAVM { ZLibWrapper.CopyStreamToInputBuffer(snipStreamWrapper.SnipStream, dataSizeParam); //stream = new MemoryStream(recordReader.ReadBytes((int) dataSize)); //dataReader = compressed ? ZLib.Decompress(stream, out compressLevel, (int)realSize) : new BinaryReader(stream); if (compressed & realSize > 0) { //Clipboard.SetText(Name + realSize.ToString(CultureInfo.InvariantCulture)); ZLib.Decompress(compressLevel: out compressLevel, expectedSize: (int)realSize); //Array.Copy(); } else { ZLibWrapper.CopyInputBufferToOutputBuffer(dataSizeParam); } } else { ZLibWrapper.ResetBufferSizeAndPosition(); } } catch (Exception ex) { throw new TESParserException("Record.Record: ZLib error" + Environment.NewLine + "Message: " + ex.Message + Environment.NewLine + "StackTrace: " + ex.StackTrace); } if (compressed & dataSizeParam > 0) //dawnguard.esm at position 6.812.369 at a dataSize == 0 - Record=NAVM { if (ZLibWrapper.OutputBufferLength <= 0) //if (dataReader == null) { throw new TESParserException("Record.Record: ZLib inflate error. Output buffer is empty."); } } while (ZLibWrapper.OutputBufferPosition < ZLibWrapper.OutputBufferLength) //while (dataReader.BaseStream.Position < dataReader.BaseStream.Length) { var type = "XXXX"; uint size = 0; if (realSize == 0) //compressed & { type = "????"; //ReadRecName(ZLibWrapper.Read4Bytes()); size = dataSizeParam; //realSize = dataSizeParam; //this.dataSize = dataSizeParam; } else { type = ReadRecName(ZLibWrapper.Read4Bytes()); //var type = ReadRecName(dataReader); if (type == "XXXX") { ZLibWrapper.ReadUInt16(); //dataReader.ReadUInt16(); size = ZLibWrapper.ReadUInt32(); //dataReader.ReadUInt32(); type = ReadRecName(ZLibWrapper.Read4Bytes()); //ReadRecName(dataReader); ZLibWrapper.ReadUInt16(); //dataReader.ReadUInt16(); } else { size = ZLibWrapper.ReadUInt16(); //dataReader.ReadUInt16(); } } record = new SubRecord(this, type, snipStreamWrapper, size); //record = new SubRecord(this, type, dataReader, size); //var record = new SubRecord(this, type, dataReader, size); this.SubRecords.Add(record); amountRead += (uint)record.Size2; } //} //using (var dataReader = compressed ? ZLib.Decompress(stream, (int) realSize) : new BinaryReader(stream)) //if (dataReader != null) //{ // dataReader.Close(); // dataReader.Dispose(); // dataReader = null; //} if ((compressed & realSize != 0) | (!compressed)) { if (amountRead > realSize) { Debug.Print( " * ERROR: SUB-RECORD {0} DATA DOESN'T MATCH THE SIZE SPECIFIED IN THE HEADER: DATA-SIZE={1} REAL-SIZE={2} AMOUNT-READ={3}", name, dataSizeParam, realSize, amountRead); throw new TESParserException( string.Format( "Subrecord block did not match the size specified in the record header: ExpectedSize={0} ReadSize={1} DataSize={2}", realSize, amountRead, dataSizeParam)); } } this.descNameOverride = this.DefaultDescriptiveName; this.UpdateShortDescription(); // br.BaseStream.Position+=Size; //} //using (var stream = new MemoryStream(recordReader.ReadBytes((int) dataSize))) } catch (Exception ex) { string errMsg = "Message: " + ex.Message + Environment.NewLine + Environment.NewLine + "StackTrace: " + ex.StackTrace + Environment.NewLine + Environment.NewLine + "Source: " + ex.Source + Environment.NewLine + Environment.NewLine + "GetType: " + ex.GetType().ToString(); System.Windows.Forms.Clipboard.SetDataObject(errMsg, true); // Create an EventLog instance and assign its source. EventLog myLog = new EventLog(); myLog.Source = "ThreadException"; myLog.WriteEntry(errMsg); MessageBox.Show(errMsg, "Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); } finally { //if (stream != null) //{ // stream.Close(); // stream.Dispose(); //} } }
internal Record(string name, uint dataSize, BinaryReader recordReader, TESVSnip.Domain.Data.DomainDefinition define) { this.dataSize = dataSize; int estimatedCount = Math.Max( Math.Min(16, (int)dataSize/10), 0 ); SubRecords = new AdvancedList<SubRecord>(estimatedCount) { AllowSorting = false }; Name = name; Flags1 = recordReader.ReadUInt32(); FormID = recordReader.ReadUInt32(); if (define.RecSize >= 12) Flags2 = recordReader.ReadUInt32(); if (define.RecSize >= 16) Flags3 = recordReader.ReadUInt32(); bool compressed = (Flags1 & 0x00040000) != 0; uint amountRead = 0; uint realSize = dataSize; if (compressed) { realSize = recordReader.ReadUInt32(); dataSize -= 4; } using (var stream = new MemoryStream(recordReader.ReadBytes((int)dataSize),false)) using (var br = new BinaryReader(stream)) { var dataReader = compressed ? Decompressor.Decompress(br, (int)dataSize, (int)realSize, out compressLevel) : br; { while (true) { long left = dataReader.BaseStream.Length - dataReader.BaseStream.Position; if (left < 4) { break; } string type = ReadRecName(dataReader); uint size; if (type == "XXXX") { dataReader.ReadUInt16(); size = dataReader.ReadUInt32(); type = ReadRecName(dataReader); dataReader.ReadUInt16(); } else { size = define.HEDRRecSize == 2 ? dataReader.ReadUInt16() : dataReader.ReadUInt32(); } var record = new SubRecord(this, type, dataReader, size); SubRecords.Add(record); amountRead += (uint)record.Size2; } } } if (amountRead > realSize) { Debug.Print( " * ERROR: SUB-RECORD {0} DATA DOESN'T MATCH THE SIZE SPECIFIED IN THE HEADER: DATA-SIZE={1} REAL-SIZE={2} AMOUNT-READ={3}", name, dataSize, realSize, amountRead); throw new TESParserException( string.Format( "Subrecord block did not match the size specified in the record header: ExpectedSize={0} ReadSize={1} DataSize={2}", realSize, amountRead, dataSize)); } descNameOverride = DefaultDescriptiveName; UpdateShortDescription(); // br.BaseStream.Position+=Size; }
private void LoadFormData() { List<CharacterSheet> emptyEveCharactersList = new List<CharacterSheet>(); List<CorpData> emptyCorporationDataList = new List<CorpData>(); List<SkillSheet> emptyEveSkillList = new List<SkillSheet>(); List<ImportedData> emptyCSVList = new List<ImportedData>(); List<ListItem> emptyCorpDropDownList = new List<ListItem>(); List<UserData> emptyUserInfoList = new List<UserData>(); AdvancedList<CharacterView> emptyCharacterDataGrid = new AdvancedList<CharacterView>(); EveCharactersList = emptyEveCharactersList; CorporationDataList = emptyCorporationDataList; EveSkillList = emptyEveSkillList; CSVList = emptyCSVList; CorpDropDownList = emptyCorpDropDownList; UserInfoList = emptyUserInfoList; CharacterDataGrid = emptyCharacterDataGrid; cbRemoveCorp.Items.Clear(); listCharacters.Items.Clear(); if (File.Exists(EveSkillsLocalXML)) { EveSkillList = EveSkillObject.GetSkills(EveSkillsLocalXML); listMainView.Items.Add("Loading Skill List."); } else { listMainView.Items.Add("Updating Skill List."); UpdateLocalEveSkillsXML(); } if (File.Exists(UserDataLocalXML)) { XElement xUserData; xUserData = XElement.Load(UserDataLocalXML); foreach (XElement usersettings in xUserData.Elements("settings")) { foreach (XElement xe in usersettings.Elements("user")) { UserInfoList.Add(new UserData( xe.Attribute("corp_keyID").Value, xe.Attribute("corp_vCode").Value, xe.Attribute("corpdataxml").Value)); } listMainView.Items.Add("Loading User Data."); } if (UserInfoList.Count > 0) { foreach (UserData user in UserInfoList) { LoadCorpData(user.corp_corpdata_xml); } int i = 0; foreach (CorpData corp in CorporationDataList) { CorpDropDownList.Add(new ListItem(corp.corporationName.ToString(), UserInfoList[i].corp_KeyID.ToString())); listMainView.Items.Add("Loading corporation data for: " + corp.corporationName); i++; } } foreach (ListItem item in CorpDropDownList) { cbRemoveCorp.Items.Add(item); cbRemoveCorp.SelectedIndex = 0; } if (cbRemoveCorp.Items.Count == 0) { cbRemoveCorp.Text = ""; } } else { listMainView.Items.Add("No user data loaded, please add your corp API information."); } if (File.Exists(CharacterDataXML)) { LoadLocalDataSheet(); listMainView.Items.Add("Loading all character data."); } else { XDocument CreateDatasheetXML = new XDocument(); XElement DatasheetRoot = new XElement("characters"); CreateDatasheetXML.Add(DatasheetRoot); CreateDatasheetXML.Save(CharacterDataXML); listMainView.Items.Add("No character data currently available."); } foreach (CharacterSheet pilot in EveCharactersList) { StringBuilder pilot_titles_build = new StringBuilder(); foreach (CharacterSheet.CharacterTitles title in pilot.titles) { pilot_titles_build.Append(title.titleName).Append(", "); } string str_pilot_titles = pilot_titles_build.ToString(); CorpData this_pilots_corp = CorporationDataList.Find(delegate(CorpData s) { return s.corporationID == pilot.corporationID; }); if (this_pilots_corp != null) { CorpData.Member this_pilots_corp_name = this_pilots_corp.memberList.Find(delegate(CorpData.Member s) { return s.characterID == pilot.characterID; }); CharacterDataGrid.Add(new CharacterView(pilot.name, pilot.corporationName, pilot.forumName, this_pilots_corp_name.startDateTime, this_pilots_corp_name.logoffDateTime, pilot.skills, str_pilot_titles, pilot.titles)); } else { CharacterDataGrid.Add(new CharacterView(pilot.name, pilot.corporationName, pilot.forumName, Convert.ToDateTime("1/1/1000"), Convert.ToDateTime("1/1/1000"), pilot.skills, str_pilot_titles, pilot.titles)); } } BindingSource charsource = new BindingSource(); charsource.DataSource = CharacterDataGrid; _dgMainView.DataSource = charsource; foreach (CharacterView item in CharacterDataGrid) { listCharacters.Items.Add(item.forumName + "\t\t" + item.name); } listMainView.Items.Add("Total characters loaded: " + CharacterDataGrid.Count); }