static void WADTest() { using (WADFile wad = new WADFile("Zed.wad.client")) { wad.RemoveEntry(wad.Entries[0]); wad.Write("Zed.wad.client"); } /*using (WADFile wad = new WADFile("Jinx.wad.client")) * { * Dictionary<ulong, byte[]> entries = new Dictionary<ulong, byte[]>(); * foreach(WADEntry entry in wad.Entries) * { * entries.Add(entry.XXHash, entry.GetContent(true)); * } * Parallel.ForEach(entries, (entry) => * { * File.WriteAllBytes("lol//" + entry.Key.ToString(), entry.Value); * }); * }*/ //string extractionFolder = "D:/Chewy/Desktop/WADTEST"; //Directory.CreateDirectory(extractionFolder); /*using (WADFile wad = new WADFile(@"C:\Riot Games\League of Legends\RADS\projects\league_client\managedfiles\0.0.0.93\Plugins\rcp-fe-viewport\assets.wad")) * { * wad.AddEntry(123456789, File.ReadAllBytes(@"C:\Riot Games\League of Legends\RADS\projects\league_client\managedfiles\0.0.0.93\Plugins\rcp-fe-viewport\description.json"), true); * wad.AddEntry(12345678, File.ReadAllBytes(@"C:\Riot Games\League of Legends\RADS\projects\league_client\managedfiles\0.0.0.93\Plugins\rcp-fe-viewport\description.json"), true); * wad.AddEntry(0, "wow"); * wad.Entries[0].FileRedirection = "It's like right now"; * wad.Write(@"C:\Riot Games\League of Legends\RADS\projects\league_client\managedfiles\0.0.0.93\Plugins\rcp-fe-viewport\assetsOHWOW.wad"); * }*/ }
public void UninstallMod(ModFile mod) { Log.Information("Uninstalling Mod: " + mod.GetID()); List <ulong> modFiles = new List <ulong>(this.Index.ModEntryMap[mod.GetID()]); Dictionary <string, WADFile> wadFiles = new Dictionary <string, WADFile>(); this.Index.StartEdit(); //In this loop we remove the installed WAD entries foreach (ulong modFile in modFiles) { List <string> modFileWadFiles = this.Index.Mod[modFile]; //Initialize WAD files for entry deletion foreach (string modFileWadFile in modFileWadFiles) { if (!wadFiles.ContainsKey(modFileWadFile)) { wadFiles.Add(modFileWadFile, new WADFile(string.Format(@"{0}\{1}", OVERLAY_FOLDER, modFileWadFile))); } WADFile wad = wadFiles[modFileWadFile]; wad.RemoveEntry(modFile); } this.Index.RemoveModFile(modFile, mod.GetID()); } //Now we need to either delete empty WAD files or fill the ones from which we removed the entries with original files //if the modified ones are the same as original then we need to delete those too foreach (KeyValuePair <string, WADFile> wadFile in wadFiles) { //If the WAD isn't being used by any other mod or is empty we can delete it if (!this.Index.WadModMap[wadFile.Key].Any(x => x != mod.GetID()) || wadFile.Value.Entries.Count == 0) { wadFile.Value.Dispose(); File.Delete(string.Format(@"{0}\{1}", OVERLAY_FOLDER, wadFile.Key)); } //If it's used by some other mods we need to merge it into the original WAD else { string gameWadPath = string.Format(@"{0}\{1}", this.LeagueFolder, wadFile.Key); string overlayWadPath = string.Format(@"{0}\{1}", OVERLAY_FOLDER, wadFile.Key); WADFile originalWad = new WADFile(gameWadPath); using (WADFile mergedWad = WADMerger.Merge(originalWad, wadFile.Value)) { mergedWad.Write(overlayWadPath + ".temp"); } wadFile.Value.Dispose(); File.Delete(overlayWadPath); File.Move(overlayWadPath + ".temp", overlayWadPath); } } this.Database.ChangeModState(mod.GetID(), false); this.Index.RemoveMod(mod.GetID()); this.Index.EndEdit(); }