Skip to content

Commit

Permalink
Fixed key detection using multipass check
Browse files Browse the repository at this point in the history
  • Loading branch information
erri120 committed Sep 14, 2020
1 parent e19ddde commit 11be9da
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions MortalEnemies/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using Mutagen.Bethesda;
Expand Down Expand Up @@ -55,14 +56,23 @@ private static void RunPatch(SynthesisState<ISkyrimMod, ISkyrimModGetter> state)
{
try
{
KeyValuePair<string, List<string>> classification = config.Classifications.First(x =>
List<KeyValuePair<string, List<string>>> classifications = config.Classifications
.Where(x => x.Key.Equals(race.EditorID!, StringComparison.OrdinalIgnoreCase))
.ToList();
if (classifications.Count == 1)
return (race, edid: classifications.First().Key);
if (race.Name?.String == null)
return (race, edid: string.Empty);
classifications = config.Classifications.Where(x =>
{
if (x.Key.Equals(race.EditorID!, StringComparison.OrdinalIgnoreCase))
return true;
if (race.Name?.String == null) return false;
return x.Value.Any(y => y.Equals(race.Name.String, StringComparison.OrdinalIgnoreCase));
});
return (race, edid: classification.Key);
var (_, value) = x;
return value.Any(y => y.Equals(race.Name.String, StringComparison.OrdinalIgnoreCase));
}).ToList();
return (race, edid: classifications.First().Key);
}
catch (InvalidOperationException)
{
Expand Down

0 comments on commit 11be9da

Please sign in to comment.