Browse Source

Added check for game version boundary

pull/46/head
Anairkoen Schno 4 years ago
parent
commit
bb44e27923
5 changed files with 27 additions and 16 deletions
  1. +6
    -2
      IPA.Injector/GameVersionEarly.cs
  2. +4
    -4
      IPA.Injector/Injector.cs
  3. +0
    -1
      IPA.Injector/Updates.cs
  4. +3
    -9
      IPA.Loader/Loader/PluginLoader.cs
  5. +14
    -0
      IPA.Loader/Utilities/BeatSaber.cs

+ 6
- 2
IPA.Injector/GameVersionEarly.cs View File

@ -15,7 +15,7 @@ namespace IPA.Injector
{ {
internal static class GameVersionEarly internal static class GameVersionEarly
{ {
internal static string ResolveDataPath(string installDir) =>
internal static string ResolveDataPath(string installDir) =>
Directory.EnumerateDirectories(installDir, "*_Data").First(); Directory.EnumerateDirectories(installDir, "*_Data").First();
internal static string GlobalGameManagers(string installDir) => internal static string GlobalGameManagers(string installDir) =>
@ -53,7 +53,11 @@ namespace IPA.Injector
internal static SemVer.Version SafeParseVersion() => new SemVer.Version(GetGameVersion(), true); 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() internal static void Load()
{ {


+ 4
- 4
IPA.Injector/Injector.cs View File

@ -85,17 +85,17 @@ namespace IPA.Injector
CriticalSection.Configure(); CriticalSection.Configure();
Updates.InstallPendingUpdates();
LibLoader.SetupAssemblyFilenames(true);
loader.Debug("Prepping bootstrapper"); loader.Debug("Prepping bootstrapper");
// updates backup // updates backup
InstallBootstrapPatch(); InstallBootstrapPatch();
LibLoader.SetupAssemblyFilenames(true);
GameVersionEarly.Load(); GameVersionEarly.Load();
Updates.InstallPendingUpdates();
//HarmonyProtector.Protect(); //HarmonyProtector.Protect();
pluginAsyncLoadTask = PluginLoader.LoadTask(); pluginAsyncLoadTask = PluginLoader.LoadTask();


+ 0
- 1
IPA.Injector/Updates.cs View File

@ -37,7 +37,6 @@ namespace IPA.Injector
{ {
Process.Start(new ProcessStartInfo Process.Start(new ProcessStartInfo
{ {
// will never actually be null
FileName = path, FileName = path,
Arguments = $"\"-nw={Process.GetCurrentProcess().Id},s={string.Join(" ", Environment.GetCommandLineArgs().Skip(1).StrJP()).Replace("\\", "\\\\").Replace(",", "\\,")}\"", Arguments = $"\"-nw={Process.GetCurrentProcess().Id},s={string.Join(" ", Environment.GetCommandLineArgs().Skip(1).StrJP()).Replace("\\", "\\\\").Replace(",", "\\,")}\"",
UseShellExecute = false UseShellExecute = false


+ 3
- 9
IPA.Loader/Loader/PluginLoader.cs View File

@ -136,14 +136,11 @@ namespace IPA.Loader
internal static void YeetIfNeeded() internal static void YeetIfNeeded()
{ {
string pluginDir = BeatSaber.PluginsPath; 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)) if (Directory.Exists(oldPluginsName))
Directory.Delete(oldPluginsName, true); Directory.Delete(oldPluginsName, true);
@ -153,9 +150,6 @@ namespace IPA.Loader
else else
Directory.CreateDirectory(pluginDir); Directory.CreateDirectory(pluginDir);
} }
SelfConfig.SelfConfigRef.Value.LastGameVersion = gameVer.ToString();
SelfConfig.LoaderConfig.Store(SelfConfig.SelfConfigRef.Value);
} }
internal static List<PluginMetadata> PluginsMetadata = new List<PluginMetadata>(); internal static List<PluginMetadata> PluginsMetadata = new List<PluginMetadata>();


+ 14
- 0
IPA.Loader/Utilities/BeatSaber.cs View File

@ -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);
}
/// <summary> /// <summary>
/// The different types of releases of the game. /// The different types of releases of the game.
/// </summary> /// </summary>


Loading…
Cancel
Save