Skip to content

Commit

Permalink
Merge pull request #104 from BarleyFlour/main
Browse files Browse the repository at this point in the history
Fixed null suffix being considered newer than any suffix.
Fixed required mods with hyphens and no version not being parsed properly as required mods.
  • Loading branch information
BarleyFlour authored Jun 21, 2024
2 parents adc02d2 + ae58e74 commit c4349f2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
9 changes: 5 additions & 4 deletions ModFinderClient/Mod/ModVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down
13 changes: 5 additions & 8 deletions ModFinderClient/UI/ModViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,12 @@ public void SetRequirements(List<string> 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}");
Expand Down

0 comments on commit c4349f2

Please sign in to comment.