diff --git a/ModFinderClient/Mod/ModVersion.cs b/ModFinderClient/Mod/ModVersion.cs index 76a1012d7e..1021906396 100644 --- a/ModFinderClient/Mod/ModVersion.cs +++ b/ModFinderClient/Mod/ModVersion.cs @@ -104,10 +104,11 @@ public int CompareTo(ModVersion other) if (this.VersionNumbers is null && other.VersionNumbers is null) return 0; - if (this.VersionNumbers is not null && other.VersionNumbers is null) - return 1; if (this.VersionNumbers is null && other.VersionNumbers is not null) return -1; + if (this.VersionNumbers is not null && other.VersionNumbers is null) + return 1; + var longestLength = this.VersionNumbers.Length > other.VersionNumbers.Length ? this.VersionNumbers.Length @@ -127,9 +128,9 @@ public int CompareTo(ModVersion other) return 0; if (Suffix is null && other.Suffix is not null) - return 1; - if (Suffix is not null && other.Suffix is null) return -1; + if (Suffix is not null && other.Suffix is null) + return 1; c = Suffix.CompareTo(other.Suffix); return c; diff --git a/ModFinderClient/UI/ModViewModel.cs b/ModFinderClient/UI/ModViewModel.cs index e57206a0f7..f3ddf785a5 100644 --- a/ModFinderClient/UI/ModViewModel.cs +++ b/ModFinderClient/UI/ModViewModel.cs @@ -175,15 +175,12 @@ public void SetRequirements(List requirements) { ModVersion requiredVersion = default; var idStr = id; - var separatorIndex = id.LastIndexOf('-'); - if (separatorIndex > 0) + var iDVersionpattern = @"(.*)-(\d+.*)"; + var match = Regex.Match(idStr, iDVersionpattern); + if (match.Success) { - // There's a version requirement - requiredVersion = ModVersion.Parse(id[separatorIndex..]); - - // The mod ID might have a '-' :( *cough*TTT*cough* - if (requiredVersion != default) - idStr = id[..separatorIndex]; + requiredVersion = ModVersion.Parse(match.Groups[2].Value); + idStr = match.Groups[1].Value; } Logger.Log.Info($"{Name} requires {idStr} at version {requiredVersion}");