public void OverrideExistingFile_Simple() { // This is "simple" as I only have the Encoding, Root and configs downloaded - no CDN backup. // By using CDNClient all of this can be achieved without any source files on disk. string customfilepath = "Resources/ui_mainmenu_legion_27826.m2"; // local filename string targetfilename = "interface/glues/models/ui_mainmenu_battleforazeroth/ui_mainmenu_battleforazeroth.m2"; // root filename uint targetfileid = 2021650; // filedataid of the above TACTRepo tactRepo = new TACTRepo(@"C:\wamp64\www") { ConfigContainer = new ConfigContainer("wow", Locale.EU) }; // open the configs // note: the Patch file is removed since it isn't accessible (aka downloaded) tactRepo.ConfigContainer.OpenLocal(tactRepo.BaseDirectory); // update the cdns config to point to localhost var hosts = tactRepo.ConfigContainer.CDNsFile.GetValue("hosts", Locale.EU); if (!hosts.Contains("127.0.0.1")) { tactRepo.ConfigContainer.CDNsFile.SetValue("hosts", hosts.Insert(0, "127.0.0.1 "), Locale.EU); } var servers = tactRepo.ConfigContainer.CDNsFile.GetValue("servers", Locale.EU); if (!servers.Contains("http://127.0.0.1")) { tactRepo.ConfigContainer.CDNsFile.SetValue("servers", hosts.Insert(0, "http://127.0.0.1 "), Locale.EU); } // create an index container tactRepo.IndexContainer = new Indices.IndexContainer(); // open encoding tactRepo.EncodingFile = new Encoding.EncodingFile(tactRepo.BaseDirectory, tactRepo.ConfigContainer.EncodingEKey); // open root tactRepo.EncodingFile.TryGetCKeyEntry(tactRepo.ConfigContainer.RootCKey, out var rootCKeyEntry); tactRepo.RootFile = new Root.RootFile(tactRepo.BaseDirectory, rootCKeyEntry.EKey) { FileLookup = new MockFileLookup() { [targetfilename] = targetfileid // mock the custom file } }; // encode and export the "custom" file to a temp folder // - one must export otherwise the file won't be added to an archive var blte = BlockTable.BlockTableEncoder.EncodeAndExport(customfilepath, "test", targetfilename); // add the "custom" file to root, this will propagate via 'tactRepo' tactRepo.RootFile.AddOrUpdate(blte, tactRepo); // save the repo tactRepo.Save(tactRepo.BaseDirectory); }
public void CreateNewTactRepo() { if (Directory.Exists(@"C:\wamp64\www\tpr")) { Directory.Delete(@"C:\wamp64\www\tpr", true); } if (Directory.Exists(@"C:\wamp64\www\wow")) { Directory.Delete(@"C:\wamp64\www\wow", true); } string buildName = "WOW-15595patch4.3.4_Retail"; string buildId = "15595"; string versionName = "4.3.4.15595"; string tempPath = Path.Combine("test", "temp"); Directory.CreateDirectory(tempPath); // open a new tact instance TACTRepo tactRepo = new TACTRepo("test"); tactRepo.Create("wow", Locale.US, uint.Parse(buildId)); // update the configs // build info and server locations tactRepo.ManifestContainer.VersionsFile.SetValue("BuildId", buildId); tactRepo.ManifestContainer.VersionsFile.SetValue("VersionsName", versionName); tactRepo.ConfigContainer.BuildConfig.SetValue("Build-Name", buildName, 0); tactRepo.ConfigContainer.BuildConfig.SetValue("Build-UID", "wow", 0); tactRepo.ConfigContainer.BuildConfig.SetValue("Build-Product", "WoW", 0); tactRepo.ManifestContainer.CDNsFile.SetValue("Hosts", "localhost"); tactRepo.ManifestContainer.CDNsFile.SetValue("Servers", "http://127.0.0.1"); // set root variables tactRepo.RootFile.LocaleFlags = Root.LocaleFlags.enUS; tactRepo.RootFile.FileLookup = new MockFileLookup(); tactRepo.RootFile.AddBlock(Root.LocaleFlags.All_WoW, 0); var record = BlockTable.BlockTableEncoder.EncodeAndExport("Resources/seagiant2_27826.m2", tempPath, "creature/seagiant2/seagiant2.m2"); tactRepo.RootFile.AddOrUpdate(record, tactRepo); record.FileName = "WoW.exe"; tactRepo.InstallFile.AddOrUpdate(record, tactRepo); tactRepo.Save(tactRepo.BaseDirectory, tactRepo.BaseDirectory); }
public static string MANIFEST_PATH; // = CdnRootDir + @"\wow"; static void Main(string[] args) { string seetingsDir = Directory.GetCurrentDirectory() + "/AppSettings.json"; AppSettings settings = null; try { FileStream f = new FileStream(seetingsDir, FileMode.Open, FileAccess.Read, FileShare.Read); var streamReader = new StreamReader(f, Encoding.UTF8); settings = JsonConvert.DeserializeObject <AppSettings>(streamReader.ReadToEnd()); } catch (Exception e) { settings = new AppSettings { cdnRootDir = "", mysqlUser = "******", mysqlPassword = "******", dataFolderPath = Directory.GetCurrentDirectory() + "\\Data\\", exportFolderPath = Directory.GetCurrentDirectory() + "\\DataExport\\", databaseName = "tacthost", databaseAdress = "localhost" }; string json = JsonConvert.SerializeObject(settings, Formatting.Indented); File.WriteAllText(seetingsDir, json); } CDN_DATA_DIR = settings.cdnRootDir + @"tpr\wow"; MANIFEST_PATH = settings.cdnRootDir + @"wow"; var tactRepo = new TACTRepo(CDN_DATA_DIR) { ManifestContainer = new ManifestContainer("wow", Locale.EU), ConfigContainer = new ConfigContainer() }; tactRepo.ManifestContainer.OpenLocal(MANIFEST_PATH); tactRepo.ConfigContainer.OpenLocal(tactRepo.BaseDirectory, tactRepo.ManifestContainer); tactRepo.IndexContainer = new Net.Indices.IndexContainer(); tactRepo.IndexContainer.Open(tactRepo.BaseDirectory); tactRepo.EncodingFile = new Net.Encoding.EncodingFile(tactRepo.BaseDirectory, tactRepo.ConfigContainer.EncodingEKey); tactRepo.EncodingFile.TryGetCKeyEntry(tactRepo.ConfigContainer.RootCKey, out var rootCEntry); tactRepo.RootFile = new Net.Root.RootFile(tactRepo.BaseDirectory, rootCEntry.EKey); tactRepo.InstallFile = new InstallFile(tactRepo.BaseDirectory, tactRepo.ConfigContainer.InstallEKey); tactRepo.DownloadFile = new Net.Download.DownloadFile(tactRepo.BaseDirectory, tactRepo.ConfigContainer.DownloadEKey); tactRepo.PatchFile = new Net.Patch.PatchFile(tactRepo.BaseDirectory, tactRepo.ConfigContainer.PatchEKey); tactRepo.RootFile.FileLookup = new ListFileLookup(); string[] files = Directory.GetFiles(settings.dataFolderPath, "*", SearchOption.AllDirectories); for (int i = 0; i < files.Length; i++) { files[i] = files[i].Replace(settings.dataFolderPath, ""); } Console.WriteLine("Found " + files.Length + " Files to proccess in " + settings.dataFolderPath); foreach (string s in files) { string filename = s.Substring(s.LastIndexOf("\\") + 1); string path = s.Substring(0, s.LastIndexOf("\\") + 1); LocaleFlags locale = LocaleFlags.All_WoW; if (path.ToLower().Contains("dbfilesclient")) { var match = Regex.Match(path, @"(frFR)|(enUS)|(ptBR)|(ruRU)|(esES)|(esMX)|(itIT)|(deDE)|(enGB)|(ptPT)"); var pathSplit = path.Split("\\"); var localeString = ""; foreach (var split in pathSplit) { if (split.Contains(match.Value)) { locale = (LocaleFlags)Enum.Parse(typeof(LocaleFlags), split); localeString = split; path = path.Replace("\\" + localeString, ""); break; } } } CASRecord record = BlockTableEncoder.EncodeAndExport(settings.dataFolderPath + s, settings.exportFolderPath, (path + filename).Replace("\\", "/")); uint fId = tactRepo.RootFile.FileLookup.GetOrCreateFileId(record.FileName); Console.WriteLine("Added " + filename + " with ID: " + fId); tactRepo.RootFile.AddOrUpdate(record, tactRepo, locale); tactRepo.InstallFile.AddOrUpdate(record, tactRepo); } tactRepo.Save(tactRepo.BaseDirectory, settings.cdnRootDir); }