private void WalkPluginTree(Rec r, TreeNode tn) { var tn2 = new TreeNode(r.DescriptiveName); tn2.Tag = r; if (r is GroupRecord) { foreach (var r2 in ((GroupRecord) r).Records) { WalkPluginTree(r2, tn2); } } tn.Nodes.Add(tn2); }
/// <summary> /// Recursively builds the tree of records for the given record using the given node. /// </summary> /// <param name="p_plgPlugin">The <see cref="Plugin"/> for which to build a record tree.</param> /// <param name="p_recRecord">The <see cref="Rec"/> for which to build a record tree.</param> /// <param name="p_tndNode">The <see cref="TreeNode"/> at which to build the record tree.</param> private void WalkPluginTree(CriticalRecordPlugin p_crpPlugin, Rec p_recRecord, TreeNode p_tndNode) { if (p_recRecord.Name.Equals("TES4")) return; TreeNode tndSubNode = null; if (p_recRecord is Record) { tndSubNode = new TreeNode(String.Format("{0:x8}: {1}", ((Record)p_recRecord).FormID, p_recRecord.DescriptiveName)); if (p_crpPlugin.IsRecordCritical(((Record)p_recRecord).FormID)) tndSubNode.BackColor = Color.Red; } else tndSubNode = new TreeNode(p_recRecord.DescriptiveName); tndSubNode.Tag = p_recRecord; if (p_recRecord is GroupRecord) foreach (Rec recSubRecord in ((GroupRecord)p_recRecord).Records) WalkPluginTree(p_crpPlugin, recSubRecord, tndSubNode); p_tndNode.Nodes.Add(tndSubNode); }
private static void RecursePlugin(Rec r, Dictionary<uint, Record> records, List<Pair<uint, Record>> quests, List<Pair<uint, Record>> refs) { if(r is Record) { Record r2=(Record)r; if(r2.descriptiveName==null) return; records[r2.FormID]=r2; if(r2.Name=="QUST") { foreach(SubRecord sr in r2.SubRecords) { if(sr.Name=="SCRI") { byte[] bytes=sr.GetReadonlyData(); uint formid=(TypeConverter.h2i(bytes[0], bytes[1], bytes[2], bytes[3])); quests.Add(new Pair<uint, Record>(formid, r2)); } } } else if(r2.Name=="REFR"||r2.Name=="ACHR"||r2.Name=="ACRE") { if(r2.SubRecords.Count>0&&r2.SubRecords[1].Name=="NAME") { byte[] bytes=r2.SubRecords[1].GetReadonlyData(); uint formid=(TypeConverter.h2i(bytes[0], bytes[1], bytes[2], bytes[3])); refs.Add(new Pair<uint, Record>(formid, r2)); } } } else { foreach(Rec r2 in ((GroupRecord)r).Records) RecursePlugin(r2, records, quests, refs); } }
private int sanitizeCountRecords(Rec r) { if (r is Record) { return 1; } var i = 1; foreach (var r2 in ((GroupRecord) r).Records) { i += sanitizeCountRecords(r2); } return i; }
private void FormIDScanRecurse2(Rec r, Dictionary<uint, string> table, string type) { var r2 = r as Record; if (r2 != null) { if (r2.Name == type) { table[r2.FormID] = r2.DescriptiveName; } } else { var gr = (GroupRecord) r; if (gr.groupType == 0 && gr.ContentsType != type) { return; } foreach (var r3 in gr.Records) { FormIDScanRecurse2(r3, table, type); } } }
private bool RecurseFormIDSearch(Rec rec, uint FormID, ref string edid) { if (rec is Record) { if (((Record) rec).FormID == FormID) { edid = rec.DescriptiveName; return true; } } else { foreach (var r in ((GroupRecord) rec).Records) { if (RecurseFormIDSearch(r, FormID, ref edid)) { return true; } } } return false; }
private void FormIDScanRecurse(Rec r, uint match, uint mask, Dictionary<uint, string> table, string type) { var r2 = r as Record; if (r2 != null) { if (r2.Name == type && (r2.FormID & 0xff000000) == match) { table[(r2.FormID & 0xffffff) | mask] = r2.DescriptiveName; } } else { var gr = (GroupRecord) r; if (gr.groupType == 0 && gr.ContentsType != type) { return; } foreach (var r3 in gr.Records) { FormIDScanRecurse(r3, match, mask, table, type); } } }
private bool cleanRecurse2(Rec r, ref int count, Dictionary<uint, Record> lookup) { var r2 = r as Record; if (r2 != null) { if (lookup.ContainsKey(r2.FormID)) { var r3 = lookup[r2.FormID]; if (r2.Name == r3.Name && r2.Size == r3.Size && r2.SubRecords.Count == r3.SubRecords.Count && r2.Flags1 == r3.Flags1 && r2.Flags2 == r3.Flags2 && r2.Flags3 == r3.Flags3) { for (var i = 0; i < r2.SubRecords.Count; i++) { if (r2.SubRecords[i].Name != r3.SubRecords[i].Name || r2.SubRecords[i].Size != r3.SubRecords[i].Size) { return false; } byte[] data1 = r2.SubRecords[i].GetReadonlyData(), data2 = r3.SubRecords[i].GetReadonlyData(); for (var j = 0; j < data1.Length; j++) { if (data1[j] != data2[j]) { return false; } } } return true; } } } else { var gr = (GroupRecord) r; for (var i = 0; i < gr.Records.Count; i++) { if (cleanRecurse2(gr.Records[i], ref count, lookup)) { count++; gr.Records.RemoveAt(i--); } } } return false; }
private void cleanRecurse(Rec r, uint match, uint mask, Dictionary<uint, Record> lookup) { var r2 = r as Record; if (r2 != null) { if ((r2.FormID & 0xff000000) == match) { if (r2.Name != "REFR" && r2.Name != "ACHR" && r2.Name != "NAVM" && r2.Name != "INFO") { lookup[(r2.FormID & 0xffffff) | mask] = r2; } } } else { foreach (var r3 in ((GroupRecord) r).Records) { cleanRecurse(r3, match, mask, lookup); } } }
private void DumpEdidsInternal(Rec r, StreamWriter sw) { if (r is Record) { var r2 = (Record) r; if (r2.SubRecords.Count > 0 && r2.SubRecords[0].Name == "EDID") { sw.WriteLine(r2.SubRecords[0].GetStrData()); } } else { foreach (var r2 in ((GroupRecord) r).Records) { DumpEdidsInternal(r2, sw); } } }
private void StripEDIDspublic(Rec r) { if (r is Record) { var r2 = (Record) r; if (r2.Name != "GMST" && r2.SubRecords.Count > 0 && r2.SubRecords[0].Name == "EDID") { r2.DeleteRecord(r2.SubRecords[0]); } for (var i = 0; i < r2.SubRecords.Count; i++) { if (r2.SubRecords[i].Name == "SCTX") { r2.SubRecords.RemoveAt(i--); } } } else { foreach (var r2 in ((GroupRecord) r).Records) { StripEDIDspublic(r2); } } }
private int sanitizeCountRecords(Rec r) { if (r is Record) return 1; else { int i = 1; foreach (Rec r2 in ((GroupRecord)r).Records) i += sanitizeCountRecords(r2); return i; } }