internal Category( byte category, int expansion, int chunk, PlatformId platform, SqPackIndex index, DirectoryInfo rootDir, GameData gameData) { _gameData = gameData; CategoryId = category; Expansion = expansion; Chunk = chunk; Platform = platform; Index = index; RootDir = rootDir; DatFiles = new Dictionary <byte, SqPack>(); // init dats for (byte id = 0; id < index.IndexHeader.number_of_data_file; id++) { var datName = Repository.BuildDatStr(CategoryId, Expansion, Chunk, Platform, $"dat{id}"); var path = Path.Combine(RootDir.FullName, datName); var fileInfo = new FileInfo(path); if (fileInfo.Exists) { DatFiles[id] = new SqPack(fileInfo, _gameData); } } // postprocess indexes into one hashlist IndexHashTableEntries = new Dictionary <ulong, IndexHashTableEntry>(); if (index.IsIndex2) { Index2HashTableEntries = index.HashTableEntries2; } else { IndexHashTableEntries = index.HashTableEntries; } }
/// <summary> /// Autodiscovers dats and a relevant index for them /// </summary> private void SetupIndexes() { Categories = new Dictionary <byte, List <Category> >(); foreach (var cat in CategoryNameToIdMap) { var catList = Categories[cat.Value] = new List <Category>(); // discover indexes first // once we find an index, that index will have an associated dat (or dats) too // so we don't need to discover those here for (int chunk = 0; chunk < 255; chunk++) { var indexFiles = FindIndexes(cat.Value, ExpansionId, chunk); if (indexFiles.Count == 0) { continue; } // grab first index from the discovered indexes, this should be index if you have both // otherwise it _should_ be index2 var file = indexFiles.FirstOrDefault(); if (file == null) { continue; } var index = new SqPackIndex(file, _Lumina); var dat = new Category( cat.Value, ExpansionId, chunk, _Lumina.Options.CurrentPlatform, index, RootDir, _Lumina); catList.Add(dat); } } }