From 71420b3206acb6ece20b6a16d465c00104a6cefc Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Sat, 21 Dec 2019 01:51:47 -0600 Subject: [PATCH] Added flag to disable reverting during installations --- IPA.Injector/GameVersionEarly.cs | 2 +- IPA.Injector/Injector.cs | 4 ++-- IPA/Program.cs | 29 ++++++++++++++++------------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/IPA.Injector/GameVersionEarly.cs b/IPA.Injector/GameVersionEarly.cs index b3cbec86..2d088e7d 100644 --- a/IPA.Injector/GameVersionEarly.cs +++ b/IPA.Injector/GameVersionEarly.cs @@ -58,7 +58,7 @@ namespace IPA.Injector internal static void Load() { // This exists for the same reason the wierdness in Injector.Main does - var unused = Type.GetType("SemVer.Version, SemVer", false); + _ = Type.GetType("SemVer.Version, SemVer", false); _Load(); } diff --git a/IPA.Injector/Injector.cs b/IPA.Injector/Injector.cs index 95d14ee1..7ccc86bd 100644 --- a/IPA.Injector/Injector.cs +++ b/IPA.Injector/Injector.cs @@ -87,13 +87,13 @@ namespace IPA.Injector Updates.InstallPendingUpdates(); + LibLoader.SetupAssemblyFilenames(true); + loader.Debug("Prepping bootstrapper"); // updates backup InstallBootstrapPatch(); - LibLoader.SetupAssemblyFilenames(true); - GameVersionEarly.Load(); //HarmonyProtector.Protect(); diff --git a/IPA/Program.cs b/IPA/Program.cs index dee82a42..bdf5b430 100644 --- a/IPA/Program.cs +++ b/IPA/Program.cs @@ -27,19 +27,19 @@ namespace IPA public static Version Version => Assembly.GetEntryAssembly().GetName().Version; - public static readonly ArgumentFlag ArgHelp = new ArgumentFlag("--help", "-h") { DocString = "prints this message" }; - public static readonly ArgumentFlag ArgWaitFor = new ArgumentFlag("--waitfor", "-w") { DocString = "waits for the specified PID to exit", ValueString = "PID" }; - public static readonly ArgumentFlag ArgForce = new ArgumentFlag("--force", "-f") { DocString = "forces the operation to go through" }; - public static readonly ArgumentFlag ArgRevert = new ArgumentFlag("--revert", "-r") { DocString = "reverts the IPA installation" }; - public static readonly ArgumentFlag ArgNoWait = new ArgumentFlag("--nowait", "-n") { DocString = "doesn't wait for user input after the operation" }; - public static readonly ArgumentFlag ArgStart = new ArgumentFlag("--start", "-s") { DocString = "uses value_ as arguments to start the game after the patch/unpatch", ValueString = "ARGUMENTS" }; - public static readonly ArgumentFlag ArgLaunch = new ArgumentFlag("--launch", "-l") { DocString = "uses positional parameters as arguments to start the game after patch/unpatch" }; - //public static readonly ArgumentFlag ArgDestructive = new ArgumentFlag("--destructive", "-d") { DocString = "patches the game using the now outdated destructive methods" }; + public static readonly ArgumentFlag ArgHelp = new ArgumentFlag("--help", "-h") { DocString = "prints this message" }; + public static readonly ArgumentFlag ArgWaitFor = new ArgumentFlag("--waitfor", "-w") { DocString = "waits for the specified PID to exit", ValueString = "PID" }; + public static readonly ArgumentFlag ArgForce = new ArgumentFlag("--force", "-f") { DocString = "forces the operation to go through" }; + public static readonly ArgumentFlag ArgRevert = new ArgumentFlag("--revert", "-r") { DocString = "reverts the IPA installation" }; + public static readonly ArgumentFlag ArgNoRevert = new ArgumentFlag("--no-revert", "-R") { DocString = "prevents a normal installation from first reverting" }; + public static readonly ArgumentFlag ArgNoWait = new ArgumentFlag("--nowait", "-n") { DocString = "doesn't wait for user input after the operation" }; + public static readonly ArgumentFlag ArgStart = new ArgumentFlag("--start", "-s") { DocString = "uses the specified arguments to start the game after the patch/unpatch", ValueString = "ARGUMENTS" }; + public static readonly ArgumentFlag ArgLaunch = new ArgumentFlag("--launch", "-l") { DocString = "uses positional parameters as arguments to start the game after patch/unpatch" }; [STAThread] public static void Main(string[] args) { - Arguments.CmdLine.Flags(ArgHelp, ArgWaitFor, ArgForce, ArgRevert, ArgNoWait, ArgStart, ArgLaunch/*, ArgDestructive*/).Process(); + Arguments.CmdLine.Flags(ArgHelp, ArgWaitFor, ArgForce, ArgRevert, ArgNoWait, ArgStart, ArgLaunch, ArgNoRevert).Process(); if (ArgHelp) { @@ -159,10 +159,13 @@ namespace IPA { var backup = new BackupUnit(context); - Console.ForegroundColor = ConsoleColor.Cyan; - Console.WriteLine("Restoring old version... "); - if (BackupManager.HasBackup(context)) - BackupManager.Restore(context); + if (!ArgNoRevert) + { + Console.ForegroundColor = ConsoleColor.Cyan; + Console.WriteLine("Restoring old version... "); + if (BackupManager.HasBackup(context)) + BackupManager.Restore(context); + } var nativePluginFolder = Path.Combine(context.DataPathDst, "Plugins"); bool isFlat = Directory.Exists(nativePluginFolder) &&