Skip to content

Commit

Permalink
Only validate active mods for cyclics
Browse files Browse the repository at this point in the history
  • Loading branch information
taubenangriff committed Apr 7, 2023
1 parent eb12a99 commit 9824f06
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ModManager_Classes/Validation/CyclicDependencyValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ internal class CyclicDependencyValidator : IModValidator
{
public void Validate(IEnumerable<Mod> changed, IReadOnlyCollection<Mod> all)
{
foreach (Mod x in all)
x.Attributes.RemoveAttributesByType(AttributeType.CyclicDependency);
foreach (Mod x in changed)
{
var cyclics = CyclicDependencies(x, all);
Expand All @@ -25,8 +27,11 @@ public void Validate(IEnumerable<Mod> changed, IReadOnlyCollection<Mod> all)

private IEnumerable<Mod> CyclicDependencies(Mod x, IReadOnlyCollection<Mod> others)
{
if (!x.IsActive)
return Enumerable.Empty<Mod>();

return others.Where(y =>
(y.Modinfo?.LoadAfterIds?.Contains(x.ModID) ?? false)
y.IsActive && (y.Modinfo?.LoadAfterIds?.Contains(x.ModID) ?? false)
&& (x.Modinfo?.LoadAfterIds?.Contains(y.ModID) ?? false));
}
}
Expand Down

0 comments on commit 9824f06

Please sign in to comment.