From 06d6854daaf2ea2578239ae0d8ae8a463681c69e Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Sat, 21 Dec 2019 01:21:27 -0600 Subject: [PATCH 1/4] Made pending updates install *before* the patching --- IPA.Injector/Injector.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/IPA.Injector/Injector.cs b/IPA.Injector/Injector.cs index 83f6a616..95d14ee1 100644 --- a/IPA.Injector/Injector.cs +++ b/IPA.Injector/Injector.cs @@ -85,13 +85,13 @@ namespace IPA.Injector CriticalSection.Configure(); + Updates.InstallPendingUpdates(); + loader.Debug("Prepping bootstrapper"); - + // updates backup InstallBootstrapPatch(); - Updates.InstallPendingUpdates(); - LibLoader.SetupAssemblyFilenames(true); GameVersionEarly.Load(); From 735a533d192f5d46f1329326822c53d06ecc29ce Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Sat, 21 Dec 2019 01:22:05 -0600 Subject: [PATCH 2/4] Bumped version --- IPA.Loader/Config/SelfConfig.cs | 2 +- IPA.Loader/Loader/manifest.json | 2 +- IPA/Program.cs | 2 +- appveyor.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/IPA.Loader/Config/SelfConfig.cs b/IPA.Loader/Config/SelfConfig.cs index 8855a5b1..5aadce44 100644 --- a/IPA.Loader/Config/SelfConfig.cs +++ b/IPA.Loader/Config/SelfConfig.cs @@ -67,7 +67,7 @@ namespace IPA.Config } internal const string IPAName = "Beat Saber IPA"; - internal const string IPAVersion = "3.13.4"; + internal const string IPAVersion = "3.13.5"; // uses Updates.AutoUpdate, Updates.AutoCheckUpdates, YeetMods, Debug.ShowCallSource, Debug.ShowDebug, // Debug.CondenseModLogs diff --git a/IPA.Loader/Loader/manifest.json b/IPA.Loader/Loader/manifest.json index b668894d..3f41c6a0 100644 --- a/IPA.Loader/Loader/manifest.json +++ b/IPA.Loader/Loader/manifest.json @@ -8,7 +8,7 @@ "gameVersion": "1.6.0", "id": "BSIPA", "name": "Beat Saber IPA", - "version": "3.13.4", + "version": "3.13.5", "icon": "IPA.icon_white.png", "features": [ "define-feature(print, IPA.Loader.Features.PrintFeature)", diff --git a/IPA/Program.cs b/IPA/Program.cs index 307c0196..dee82a42 100644 --- a/IPA/Program.cs +++ b/IPA/Program.cs @@ -23,7 +23,7 @@ namespace IPA Unknown } - public const string FileVersion = "3.13.4"; + public const string FileVersion = "3.13.5"; public static Version Version => Assembly.GetEntryAssembly().GetName().Version; diff --git a/appveyor.yml b/appveyor.yml index d6af93ef..8fda1d50 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,7 @@ version: 'BSIPA-{branch}-{build}' environment: - bsipa_version: '3.13.4' + bsipa_version: '3.13.5' gh_token: secure: E42gl/yepETuoLSwbJZ1GmEIPK6cCJu6zkd59NA21XiICtEV6COOLW7aehi1tcVU From 71420b3206acb6ece20b6a16d465c00104a6cefc Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Sat, 21 Dec 2019 01:51:47 -0600 Subject: [PATCH 3/4] 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) && From e6097054b26d7a7cf584f5acb928b92b168ebc2c Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Sat, 21 Dec 2019 14:11:10 -0600 Subject: [PATCH 4/4] Added check for game version boundary --- IPA.Injector/GameVersionEarly.cs | 8 ++++++-- IPA.Injector/Injector.cs | 8 ++++---- IPA.Injector/Updates.cs | 1 - IPA.Loader/Loader/PluginLoader.cs | 12 +++--------- IPA.Loader/Utilities/BeatSaber.cs | 14 ++++++++++++++ 5 files changed, 27 insertions(+), 16 deletions(-) diff --git a/IPA.Injector/GameVersionEarly.cs b/IPA.Injector/GameVersionEarly.cs index 2d088e7d..97dc264f 100644 --- a/IPA.Injector/GameVersionEarly.cs +++ b/IPA.Injector/GameVersionEarly.cs @@ -15,7 +15,7 @@ namespace IPA.Injector { internal static class GameVersionEarly { - internal static string ResolveDataPath(string installDir) => + internal static string ResolveDataPath(string installDir) => Directory.EnumerateDirectories(installDir, "*_Data").First(); internal static string GlobalGameManagers(string installDir) => @@ -53,7 +53,11 @@ namespace IPA.Injector internal static SemVer.Version SafeParseVersion() => new SemVer.Version(GetGameVersion(), true); - private static void _Load() => BeatSaber.SetEarlyGameVersion(SafeParseVersion()); + private static void _Load() + { + BeatSaber.SetEarlyGameVersion(SafeParseVersion()); + BeatSaber.CheckGameVersionBoundary(); + } internal static void Load() { diff --git a/IPA.Injector/Injector.cs b/IPA.Injector/Injector.cs index 7ccc86bd..d611f67b 100644 --- a/IPA.Injector/Injector.cs +++ b/IPA.Injector/Injector.cs @@ -85,17 +85,17 @@ namespace IPA.Injector CriticalSection.Configure(); - Updates.InstallPendingUpdates(); - - LibLoader.SetupAssemblyFilenames(true); - loader.Debug("Prepping bootstrapper"); // updates backup InstallBootstrapPatch(); + LibLoader.SetupAssemblyFilenames(true); + GameVersionEarly.Load(); + Updates.InstallPendingUpdates(); + //HarmonyProtector.Protect(); pluginAsyncLoadTask = PluginLoader.LoadTask(); diff --git a/IPA.Injector/Updates.cs b/IPA.Injector/Updates.cs index 6ded9dc3..13a71250 100644 --- a/IPA.Injector/Updates.cs +++ b/IPA.Injector/Updates.cs @@ -37,7 +37,6 @@ namespace IPA.Injector { Process.Start(new ProcessStartInfo { - // will never actually be null FileName = path, Arguments = $"\"-nw={Process.GetCurrentProcess().Id},s={string.Join(" ", Environment.GetCommandLineArgs().Skip(1).StrJP()).Replace("\\", "\\\\").Replace(",", "\\,")}\"", UseShellExecute = false diff --git a/IPA.Loader/Loader/PluginLoader.cs b/IPA.Loader/Loader/PluginLoader.cs index 99deaaa5..4872a8e9 100644 --- a/IPA.Loader/Loader/PluginLoader.cs +++ b/IPA.Loader/Loader/PluginLoader.cs @@ -136,14 +136,11 @@ namespace IPA.Loader internal static void YeetIfNeeded() { string pluginDir = BeatSaber.PluginsPath; - var gameVer = BeatSaber.GameVersion; - var lastVerS = SelfConfig.LastGameVersion_; - var lastVer = lastVerS != null ? new AlmostVersion(lastVerS, gameVer) : null; - if (SelfConfig.YeetMods_ && lastVer != null && gameVer != lastVer) + if (SelfConfig.YeetMods_ && BeatSaber.IsGameVersionBoundary) { - var oldPluginsName = Path.Combine(BeatSaber.InstallPath, $"Old {lastVer} Plugins"); - var newPluginsName = Path.Combine(BeatSaber.InstallPath, $"Old {gameVer} Plugins"); + var oldPluginsName = Path.Combine(BeatSaber.InstallPath, $"Old {BeatSaber.OldVersion} Plugins"); + var newPluginsName = Path.Combine(BeatSaber.InstallPath, $"Old {BeatSaber.GameVersion} Plugins"); if (Directory.Exists(oldPluginsName)) Directory.Delete(oldPluginsName, true); @@ -153,9 +150,6 @@ namespace IPA.Loader else Directory.CreateDirectory(pluginDir); } - - SelfConfig.SelfConfigRef.Value.LastGameVersion = gameVer.ToString(); - SelfConfig.LoaderConfig.Store(SelfConfig.SelfConfigRef.Value); } internal static List PluginsMetadata = new List(); diff --git a/IPA.Loader/Utilities/BeatSaber.cs b/IPA.Loader/Utilities/BeatSaber.cs index f6d57c2a..091d5b91 100644 --- a/IPA.Loader/Utilities/BeatSaber.cs +++ b/IPA.Loader/Utilities/BeatSaber.cs @@ -46,6 +46,20 @@ namespace IPA.Utilities } } + internal static bool IsGameVersionBoundary { get; private set; } + internal static AlmostVersion OldVersion { get; private set; } + internal static void CheckGameVersionBoundary() + { + var gameVer = GameVersion; + var lastVerS = SelfConfig.LastGameVersion_; + var OldVersion = lastVerS != null ? new AlmostVersion(lastVerS, gameVer) : null; + + IsGameVersionBoundary = OldVersion != null && gameVer != OldVersion; + + SelfConfig.SelfConfigRef.Value.LastGameVersion = gameVer.ToString(); + SelfConfig.LoaderConfig.Store(SelfConfig.SelfConfigRef.Value); + } + /// /// The different types of releases of the game. ///