static void Main(string[] args) { Console.WriteLine("BASEPATH: " + BASEPATH); if (!File.Exists(Path.Combine(BASEPATH, ".build.info"))) { Console.WriteLine("Error: Missing .build.info."); System.Threading.Thread.Sleep(1500); Environment.Exit(0); } var settings = new CASSettings() { BasePath = BASEPATH, Basic = true }; CASContainer.Open(settings); if (!CASContainer.ExtractSystemFiles(Path.Combine(BASEPATH, "_SystemFiles"))) { Console.WriteLine("Please ensure that you have a fully downloaded client."); System.Threading.Thread.Sleep(3000); } CASContainer.Close(); }
private void UpdateCASCDirectory(object obj) { if (RebuildInProgress) //Saving already wait for build to finish { timer.Change(30 * 1000, Timeout.Infinite); //30 second delay return; } RebuildInProgress = true; timer.Change(Timeout.Infinite, Timeout.Infinite); Startup.Logger.LogWarning($"CASC rebuild started [{DateTime.Now}] - {changes.Count} files to be amended."); Stopwatch sw = Stopwatch.StartNew(); //Open the CASC Container CASContainer.Open(settings); CASContainer.OpenCdnIndices(false); CASContainer.OpenEncoding(); CASContainer.OpenRoot(settings.Locale, Startup.Settings.MinimumFileDataId, Startup.Settings.OnlineListFile); if (Startup.Settings.BNetAppSupport) // these are only needed by the bnet app launcher { CASContainer.OpenDownload(); CASContainer.OpenInstall(); CASContainer.DownloadInstallAssets(); } //Remove Purged files foreach (var purge in Startup.Cache.ToPurge) { CASContainer.RootHandler.RemoveFile(purge); } //Apply file changes while (changes.Count > 0) { var key = changes.Keys.First(); if (changes.TryRemove(key, out FileSystemEventArgs change)) { string fullpath = change.FullPath; string cascpath = GetCASCPath(fullpath); string oldpath = GetCASCPath((change as RenamedEventArgs)?.OldFullPath + ""); switch (change.ChangeType) { case WatcherChangeTypes.Renamed: if (CASContainer.RootHandler.GetEntry(oldpath) == null) { CASContainer.RootHandler.AddFile(fullpath, cascpath); } else { CASContainer.RootHandler.RenameFile(oldpath, cascpath); } break; case WatcherChangeTypes.Deleted: CASContainer.RootHandler.RemoveFile(cascpath); break; default: CASContainer.RootHandler.AddFile(fullpath, cascpath); break; } } } //Save and Clean CASContainer.Save(); //Update directory hashes Startup.Settings.DirectoryHash = new[] { GetDirectoryHash(dataPath), GetDirectoryHash(outputPath) }; string GameVersion = new SingleConfig(Path.Combine(buildInfoPath, ".build.info"), "Active", "1", Startup.Settings.Product)["Version"]; Startup.Settings.GameVersion = GameVersion; Startup.Settings.Save(_env); sw.Stop(); Startup.Logger.LogWarning($"CASC rebuild finished [{DateTime.Now}] - {Math.Round(sw.Elapsed.TotalSeconds, 3)}s"); if (settings.StaticMode) { Environment.Exit(0); } RebuildInProgress = false; }
public static void Run(string host) { CASContainer.OpenInstall(); Parallel.ForEach(Files, file => Patch(file, host)); }