Beispiel #1
0
        private static void ApplyPatch(PatchOptions options)
        {
            string[] paths = Settings.Default.Paths.Split(';');
            foreach (string directory in Directory.GetDirectories(options.LoLDirectory))
            {
                Parallel.ForEach(Directory.GetFiles(directory, "*.raf"), fileName =>
                {
                    RiotArchiveFile archive = RiotArchiveReader.Read(fileName);

                    bool hasPatched = false;
                    foreach (var file in archive.FileList)
                    {
                        RiotArchiveFileListEntry entry = file;
                        if (Path.GetExtension(entry.Path).ToLowerInvariant() != ".dds"
                            || !paths.Contains(x => entry.Path.StartsWith(x)))
                        {
                            continue;
                        }

                        byte[] decompressedData = ZLibHelper.Decompress(entry.Data);
                        using (var patcher = new TexturePatcher(decompressedData))
                        {
                            if (patcher.CanPatch())
                            {
                                patcher.Patch();
                                hasPatched = true;
                            }
                        }

                        file.Data = ZLibHelper.Compress(decompressedData);
                    }

                    if (!hasPatched)
                    {
                        return;
                    }

                    if (!options.NoBackup)
                    {
                        File.Copy(fileName, fileName + ".bak", true);
                        File.Copy(fileName + ".dat", fileName + ".dat.bak", true);
                    }

                    RiotArchiveWriter.Write(archive, fileName);
                    Console.WriteLine("Patched {0}!", Path.GetFileName(fileName));
                });
            }
        }
Beispiel #2
0
        private static bool ValidatePatchOptions(PatchOptions patchOptions)
        {
            if (!Directory.Exists(patchOptions.LoLDirectory))
            {
                Console.WriteLine("The specified directory is invalid.");
                return false;
            }

            return true;
        }
Beispiel #3
0
        private static void Patch(PatchOptions patchOptions)
        {
            patchOptions.LoLDirectory = SetLoLDirectory(patchOptions.LoLDirectory);
            if (!ValidatePatchOptions(patchOptions))
            {
                return;
            }

            try
            {
                ApplyPatch(patchOptions);
                Console.WriteLine("Patch successfully applied!");
            }

            catch (IOException)
            {
                Console.WriteLine("Unable to access the League of Legends directory. " +
                                  "Make sure that League of Legends is closed.");
            }

            catch (AggregateException)
            {
                Console.WriteLine("Failed to apply the patch.");
            }
        }