コード例 #1
0
        public void LoadEbls(UnpackGame game)
        {
            var archiveDict = new EblDictionary(File.ReadAllText($@"res\{game.Config.DictionaryPath}"));

            foreach (UnpackEbl ebl in game.Config.Ebls)
            {
                LoadEbl(ebl, game.Settings.GameDirectory, archiveDict, game.Config.BHD5Game);
            }
        }
コード例 #2
0
        private void LoadEbl(UnpackEbl ebl, string gameDirectory, EblDictionary eblDict, BHD5.Game game)
        {
            gameDirectory = gameDirectory.TrimEnd('\\');
            string bhdPath = $@"{gameDirectory}\{ebl.Name}.bhd";
            string bdtPath = $@"{gameDirectory}\{ebl.Name}.bdt";

            if (!ebl.Optional)
            {
                if (!File.Exists(bhdPath))
                {
                    throw new FileNotFoundException($"Mandatory header file not found:\n{bhdPath}");
                }
                else if (!File.Exists(bdtPath))
                {
                    throw new FileNotFoundException($"Mandatory data file not found:\n{bdtPath}");
                }
            }
            else if (!File.Exists(bhdPath) || !File.Exists(bdtPath))
            {
                return;
            }

            BHD5       bhd       = ReadBHD5(bhdPath, ebl.Key, game);
            FileStream bdtStream = File.OpenRead(bdtPath);

            DataStreams.Enqueue(bdtStream);

            foreach (BHD5.Bucket bucket in bhd.Buckets)
            {
                foreach (BHD5.FileHeader header in bucket)
                {
                    if (eblDict.GetPath(header.FileNameHash, out string path))
                    {
                        path = path.Replace('/', '\\').TrimStart('\\');
                        var file = new EblFile(path, header, bdtStream);
                        Files[path.ToLower()] = file;
                    }
                }
            }
        }