Browse Source

Mod yeeter now only compares 'important' parts of version for equality

pull/32/head
Anairkoen Schno 5 years ago
parent
commit
34e63dd30e
2 changed files with 17 additions and 1 deletions
  1. +1
    -1
      IPA.Loader/Loader/PluginManager.cs
  2. +16
    -0
      IPA.Loader/Utilities/Utils.cs

+ 1
- 1
IPA.Loader/Loader/PluginManager.cs View File

@ -296,7 +296,7 @@ namespace IPA.Loader
var lastVerS = SelfConfig.SelfConfigRef.Value.LastGameVersion; var lastVerS = SelfConfig.SelfConfigRef.Value.LastGameVersion;
var lastVer = lastVerS != null ? new SemVer.Version(lastVerS, true) : null; var lastVer = lastVerS != null ? new SemVer.Version(lastVerS, true) : null;
if (lastVer != null && gameVer != lastVer)
if (lastVer != null && Utils.VersionCompareNoPrerelease(gameVer, lastVer) != 0)
{ {
var oldPluginsName = Path.Combine(BeatSaber.InstallPath, $"Old {lastVer} Plugins"); var oldPluginsName = Path.Combine(BeatSaber.InstallPath, $"Old {lastVer} Plugins");
var newPluginsName = Path.Combine(BeatSaber.InstallPath, $"Old {gameVer} Plugins"); var newPluginsName = Path.Combine(BeatSaber.InstallPath, $"Old {gameVer} Plugins");


+ 16
- 0
IPA.Loader/Utilities/Utils.cs View File

@ -166,5 +166,21 @@ namespace IPA.Utilities
else return DateTime.MinValue.AddTicks((long)UnsafeAdvanceTicks++); // return MinValue as a fallback else return DateTime.MinValue.AddTicks((long)UnsafeAdvanceTicks++); // return MinValue as a fallback
} }
} }
/// <summary>
/// Compares a pair of <see cref="SemVer.Version"/>s ignoring both the prerelease and build fields.
/// </summary>
/// <param name="l">the left value</param>
/// <param name="r">the right value</param>
/// <returns>-1 if l is less than r, 0 if they are equal in the numeric portion, or 1 if l is greater than r</returns>
public static int VersionCompareNoPrerelease(SemVer.Version l, SemVer.Version r)
{
var cmpVal = l.Major - r.Major;
if (cmpVal != 0) return cmpVal;
cmpVal = l.Minor - r.Minor;
if (cmpVal != 0) return cmpVal;
cmpVal = l.Patch - r.Patch;
return cmpVal;
}
} }
} }

Loading…
Cancel
Save