private static void ProcessNDB(Span <byte> buffer, DatabaseFlags flags) { var name = new NDB(buffer); foreach (var(entry, strings) in name.Entries) { var filename = name.NameMap[entry.KTID]; var text = $"{entry.KTID:x8},{RDB.Hash(strings[0]):x8},{strings.ElementAt(0)},{filename},{RDB.Hash(strings[1]):x8},{strings[1]}"; if (strings.Length > 2) { text += string.Join(string.Empty, strings.Skip(2)); } Console.WriteLine(text); } }
private static void HashNDB(Span <byte> buffer, Dictionary <KTIDReference, string> typeInfo, Dictionary <KTIDReference, string> extra, DatabaseFlags flags) { var name = new NDB(buffer); foreach (var(_, strings) in name.Entries) { typeInfo[RDB.Hash(strings[1])] = strings[1]; foreach (var str in strings.Skip(2)) { extra[RDB.Hash(str)] = str; } } }
private static void ProcessOBJDB(Span <byte> buffer, Dictionary <KTIDReference, string> ndbFiles, Dictionary <KTIDReference, string> filelist, Dictionary <KTIDReference, string> propertyList, HashSet <KTIDReference> filters, DatabaseFlags flags, HashSet <KTIDReference> missingProperties) { var db = new OBJDB(buffer); var ndb = new NDB(); if (ndbFiles.TryGetValue(db.Header.NameKTID, out var ndbPath)) { ndb = new NDB(File.ReadAllBytes(ndbPath)); } foreach (var(ktid, (entry, properties)) in db.Entries) { if (filters.Count != 0 && !filters.Contains(entry.TypeInfoKTID)) { continue; } var lines = new List <string> { $"KTID: {GetKTIDNameValue(ktid, flags.ShowKTIDs, ndb, filelist, propertyList)}", $"TypeInfo: {GetKTIDNameValue(entry.TypeInfoKTID, flags.ShowKTIDs, ndb, filelist, propertyList)}", $"Parent: {GetKTIDNameValue(entry.ParentKTID, flags.ShowKTIDs, ndb, filelist, propertyList)}" }; foreach (var(property, values) in properties) { if (flags.CreateMissingList && !HasKTIDNameValue(property.PropertyKTID, ndb, propertyList)) { missingProperties.Add(property.PropertyKTID); } lines.Add($"{property.TypeId} {GetKTIDNameValue(property.PropertyKTID, flags.ShowKTIDs, ndb, propertyList)}: {(values.Length == 0 ? "NULL" : string.Join(", ", values.Select(x => property.TypeId == OBJDBPropertyType.UInt32 && x != null ? GetKTIDNameValue((uint) x, flags.ShowKTIDs, ndb, filelist, propertyList) : x?.ToString() ?? "NULL")))}"); } foreach (var line in lines) { Console.Out.WriteLine(line); } Console.Out.WriteLine(); } }