Skip to content

Commit

Permalink
Merge #3434 Don't prompt user to choose conflicting modules
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Sep 27, 2021
2 parents 40eda03 + 5b0af47 commit 83aad88
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ All notable changes to this project will be documented in this file.
- [Multiple] Set GNOME single window property (#3425 by: HebaruSan; reviewed: DasSkelett)
- [Multiple] Default install stanza multi-game support, catch missing install_to (#3441 by: HebaruSan; reviewed: DasSkelett)
- [GUI] Escape ampersands in mod info abstract label (#3429 by: HebaruSan; reviewed: DasSkelett)
- [Core] Don't prompt user to choose conflicting modules (#3434 by: HebaruSan; reviewed: DasSkelett)

### Internal

Expand Down
17 changes: 16 additions & 1 deletion Core/Registry/AvailableModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ private static bool DependsAndConflictsOK(CkanModule module, IEnumerable<CkanMod
}
}
}
var othersMinusSelf = others.Where(m => m.identifier != module.identifier).Memoize();
if (module.conflicts != null)
{
// Skip self-conflicts (but catch other modules providing self)
var othersMinusSelf = others.Where(m => m.identifier != module.identifier).Memoize();
foreach (RelationshipDescriptor rel in module.conflicts)
{
// If any of the conflicts are present, fail
Expand All @@ -144,6 +144,21 @@ private static bool DependsAndConflictsOK(CkanModule module, IEnumerable<CkanMod
}
}
}
// Check reverse conflicts so user isn't prompted to choose modules that will error out immediately
var selfArray = new CkanModule[] { module };
foreach (CkanModule other in othersMinusSelf)
{
if (other.conflicts != null)
{
foreach (RelationshipDescriptor rel in other.conflicts)
{
if (rel.MatchesAny(selfArray, null, null))
{
return false;
}
}
}
}
return true;
}

Expand Down

0 comments on commit 83aad88

Please sign in to comment.