コード例 #1
0
        private CASCHandler(BackgroundWorker worker, CASCConfig config) : base(config)
        {
            using (var fs = OpenEncodingFile(this))
                Encoding = new EncodingHandler(fs, worker);

            if ((CASCConfig.LoadFlags & LoadFlags.Download) != 0)
            {
                using (var fs = OpenDownloadFile(Encoding, this))
                    Download = new DownloadHandler(fs, worker);
            }

            KeyService.LoadKeys();

            using (var fs = OpenRootFile(Encoding, this))
            {
                if (config.GameType == CASCGameType.WoW)
                {
                    Root = new WowRootHandler(fs, worker);
                }
                else
                {
                    using (var ufs = new FileStream("unk_root", FileMode.Create))
                        fs.BaseStream.CopyTo(ufs);

                    throw new Exception("Unsupported game " + config.BuildUID);
                }
            }

            if ((CASCConfig.LoadFlags & LoadFlags.Install) != 0)
            {
                using (var fs = OpenInstallFile(Encoding, this))
                    Install = new InstallHandler(fs, worker);
            }

            worker.ReportProgress(0, "Done...");
        }
コード例 #2
0
ファイル: CASCHandler.cs プロジェクト: westerjn/CASCExplorer
        private CASCHandler(CASCConfig config, BackgroundWorkerEx worker) : base(config, worker)
        {
            Logger.WriteLine("CASCHandler: loading encoding data...");

            using (var _ = new PerfCounter("new EncodingHandler()"))
            {
                using (var fs = OpenEncodingFile(this))
                    EncodingHandler = new EncodingHandler(fs, worker);
            }

            Logger.WriteLine("CASCHandler: loaded {0} encoding data", EncodingHandler.Count);

            if ((CASCConfig.LoadFlags & LoadFlags.Download) != 0)
            {
                Logger.WriteLine("CASCHandler: loading download data...");

                using (var _ = new PerfCounter("new DownloadHandler()"))
                {
                    using (var fs = OpenDownloadFile(EncodingHandler, this))
                        DownloadHandler = new DownloadHandler(fs, worker);
                }

                Logger.WriteLine("CASCHandler: loaded {0} download data", EncodingHandler.Count);
            }

            Logger.WriteLine("CASCHandler: loading root data...");

            using (var _ = new PerfCounter("new RootHandler()"))
            {
                using (var fs = OpenRootFile(EncodingHandler, this))
                {
                    if (config.GameType == CASCGameType.S2 || config.GameType == CASCGameType.HotS)
                    {
                        RootHandler = new MNDXRootHandler(fs, worker);
                    }
                    else if (config.GameType == CASCGameType.D3)
                    {
                        RootHandler = new D3RootHandler(fs, worker, this);
                    }
                    else if (config.GameType == CASCGameType.WoW)
                    {
                        RootHandler = new WowRootHandler(fs, worker);
                    }
                    else if (config.GameType == CASCGameType.Agent || config.GameType == CASCGameType.Bna || config.GameType == CASCGameType.Client)
                    {
                        RootHandler = new AgentRootHandler(fs, worker);
                    }
                    else if (config.GameType == CASCGameType.S1)
                    {
                        RootHandler = new S1RootHandler(fs, worker);
                    }
                    else if (config.GameType == CASCGameType.WC3)
                    {
                        RootHandler = new WC3RootHandler(fs, worker);
                    }
                    else if (config.GameType == CASCGameType.Hearthstone)
                    {
                        RootHandler = new HSRootHandler(fs, worker);
                    }
                    else if (config.GameType == CASCGameType.Overwatch)
                    {
                        RootHandler = new OwRootHandler(fs, worker, this);
                    }
                    else if (config.GameType == CASCGameType.Destiny2)
                    {
                        RootHandler = new Destiny2RootHandler(fs, worker);
                    }
                    else
                    {
                        using (var ufs = new FileStream("unk_root", FileMode.Create))
                            fs.BaseStream.CopyTo(ufs);
                        throw new Exception("Unsupported game " + config.BuildUID);
                    }
                }
            }

            Logger.WriteLine("CASCHandler: loaded {0} root data", RootHandler.Count);

            if ((CASCConfig.LoadFlags & LoadFlags.Install) != 0)
            {
                Logger.WriteLine("CASCHandler: loading install data...");

                using (var _ = new PerfCounter("new InstallHandler()"))
                {
                    using (var fs = OpenInstallFile(EncodingHandler, this))
                        InstallHandler = new InstallHandler(fs, worker);

                    InstallHandler.Print();
                }

                Logger.WriteLine("CASCHandler: loaded {0} install data", InstallHandler.Count);
            }
        }
コード例 #3
0
        private CASCHandler(CASCConfig config, BackgroundWorkerEx worker) : base(config, worker)
        {
            Logger.WriteLine("CASCHandler: loading encoding data...");

            using (var _ = new PerfCounter("new EncodingHandler()"))
            {
                using (var fs = OpenEncodingFile(this))
                    EncodingHandler = new EncodingHandler(fs, worker);
            }

            Logger.WriteLine("CASCHandler: loaded {0} encoding data", EncodingHandler.Count);

            if ((CASCConfig.LoadFlags & LoadFlags.Download) != 0)
            {
                Logger.WriteLine("CASCHandler: loading download data...");

                using (var _ = new PerfCounter("new DownloadHandler()"))
                {
                    using (var fs = OpenDownloadFile(EncodingHandler, this))
                        DownloadHandler = new DownloadHandler(fs, worker);
                }

                Logger.WriteLine("CASCHandler: loaded {0} download data", EncodingHandler.Count);
            }

            KeyService.LoadKeys();

            Logger.WriteLine("CASCHandler: loading root data...");

            using (var _ = new PerfCounter("new RootHandler()"))
            {
                if (config.IsVfsRoot)
                {
                    RootHandler = new TVFSRootHandler(worker, this);
                }
                else
                {
                    using (var fs = OpenRootFile(EncodingHandler, this))
                    {
                        RootHandlerBase UnknownRootHandler()
                        {
                            using (var ufs = new FileStream("unk_root", FileMode.Create))
                                fs.BaseStream.CopyTo(ufs);
                            throw new Exception("Unsupported game " + config.BuildProduct);
                        }

                        RootHandler = config.GameType switch
                        {
                            CASCGameType.S2 => new MNDXRootHandler(fs, worker),
                            CASCGameType.HotS => new MNDXRootHandler(fs, worker),
                            CASCGameType.D3 => new D3RootHandler(fs, worker, this),
                            CASCGameType.WoW => new WowRootHandler(fs, worker),
                            CASCGameType.S1 => new S1RootHandler(fs, worker),
                            CASCGameType.Agent => new DummyRootHandler(fs, worker),
                            CASCGameType.Bna => new DummyRootHandler(fs, worker),
                            CASCGameType.Client => new DummyRootHandler(fs, worker),
                            CASCGameType.Hearthstone => new DummyRootHandler(fs, worker),
                            CASCGameType.Destiny2 => new DummyRootHandler(fs, worker),
                            CASCGameType.Wlby => new DummyRootHandler(fs, worker),
                            CASCGameType.Rtro => new DummyRootHandler(fs, worker),
                            _ => UnknownRootHandler()
                        };
                    }
                }
            }

            Logger.WriteLine("CASCHandler: loaded {0} root data", RootHandler.Count);

            if ((CASCConfig.LoadFlags & LoadFlags.Install) != 0)
            {
                Logger.WriteLine("CASCHandler: loading install data...");

                using (var _ = new PerfCounter("new InstallHandler()"))
                {
                    using (var fs = OpenInstallFile(EncodingHandler, this))
                        InstallHandler = new InstallHandler(fs, worker);

                    //InstallHandler.Print();
                }

                Logger.WriteLine("CASCHandler: loaded {0} install data", InstallHandler.Count);
            }
        }