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. ///