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.FormID.ToString("x8") + " : " + r2.SubRecords[0].GetStrData()); } } else { foreach (Rec r2 in r.Records) { this.DumpEdidsInternal(r2, sw); } } }
private static void StripEDIDsInternal(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 (int i = 0; i < r2.SubRecords.Count; i++) { if (r2.SubRecords[i].Name == "SCTX") { r2.SubRecords.RemoveAt(i--); } } } else { foreach (Rec r2 in r.Records) { StripEDIDsInternal(r2); } } }
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)) { Record 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 (int 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 (int j = 0; j < data1.Length; j++) { if (data1[j] != data2[j]) { return false; } } } return true; } } } else { var gr = (GroupRecord) r; for (int i = 0; i < gr.Records.Count; i++) { if (this.cleanRecurse2(gr.Records[i] as Rec, 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 (Rec r3 in r.Records) { this.cleanRecurse(r3, match, mask, lookup); } } }
private static void RecursePlugin(Rec r, Dictionary<uint, Record> records, List<Pair<uint, Record>> quests, List<Pair<uint, Record>> refs) { if (r is Record) { var 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 r.Records) { RecursePlugin(r2, records, quests, refs); } } }