From 65182a69bc535673757a35de61006576d07c2374 Mon Sep 17 00:00:00 2001 From: Luca Date: Sat, 10 Jul 2021 17:50:53 +0200 Subject: [PATCH 1/3] nullreference exception --- HalgarisRPGLoot/WeaponAnalyer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HalgarisRPGLoot/WeaponAnalyer.cs b/HalgarisRPGLoot/WeaponAnalyer.cs index c1d46f8..f4875af 100644 --- a/HalgarisRPGLoot/WeaponAnalyer.cs +++ b/HalgarisRPGLoot/WeaponAnalyer.cs @@ -74,7 +74,7 @@ public void Analyze() AllEnchantedItems = AllListItems.Where(e => !e.Resolved.ObjectEffect.IsNull).ToArray(); AllObjectEffects = State.LoadOrder.PriorityOrder.ObjectEffect().WinningOverrides() - .Where(k => !k.Name.ToString().EndsWith("FX")) // Excluding Bound Weapon FX Object Effects as they don't do a thing on non bound weapons. + .Where(x => x.Name != null).Where(k => k.Name.ToString().EndsWith("FX")) // Excluding Bound Weapon FX Object Effects as they don't do a thing on non bound weapons. .ToDictionary(k => k.FormKey); AllEnchantments = AllEnchantedItems From e7d4a815c028f68a4b91a09d9a97fef236b1dba7 Mon Sep 17 00:00:00 2001 From: Luca Date: Sat, 10 Jul 2021 20:12:25 +0200 Subject: [PATCH 2/3] missing `!` caused infinite loop. --- HalgarisRPGLoot/WeaponAnalyer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HalgarisRPGLoot/WeaponAnalyer.cs b/HalgarisRPGLoot/WeaponAnalyer.cs index f4875af..b6810ff 100644 --- a/HalgarisRPGLoot/WeaponAnalyer.cs +++ b/HalgarisRPGLoot/WeaponAnalyer.cs @@ -74,7 +74,7 @@ public void Analyze() AllEnchantedItems = AllListItems.Where(e => !e.Resolved.ObjectEffect.IsNull).ToArray(); AllObjectEffects = State.LoadOrder.PriorityOrder.ObjectEffect().WinningOverrides() - .Where(x => x.Name != null).Where(k => k.Name.ToString().EndsWith("FX")) // Excluding Bound Weapon FX Object Effects as they don't do a thing on non bound weapons. + .Where(x => x.Name != null).Where(k => !k.Name.ToString().EndsWith("FX")) // Excluding Bound Weapon FX Object Effects as they don't do a thing on non bound weapons. .ToDictionary(k => k.FormKey); AllEnchantments = AllEnchantedItems From b3c325ceeef45fc7f6bfd2ec51d21d8200ac5af1 Mon Sep 17 00:00:00 2001 From: Luca Date: Sat, 10 Jul 2021 20:25:39 +0200 Subject: [PATCH 3/3] infinite loop prevention - thx @Noggog --- HalgarisRPGLoot/ArmorAnalyzer.cs | 3 ++- HalgarisRPGLoot/WeaponAnalyer.cs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/HalgarisRPGLoot/ArmorAnalyzer.cs b/HalgarisRPGLoot/ArmorAnalyzer.cs index 7bf9022..c12e829 100644 --- a/HalgarisRPGLoot/ArmorAnalyzer.cs +++ b/HalgarisRPGLoot/ArmorAnalyzer.cs @@ -232,9 +232,10 @@ private FormKey GenerateEnchantment( { var level = item.Entry.Data.Level; var forLevel = ByLevelIndexed[level]; + var takeMin = Math.Min(rarityEnchCount, forLevel.Length); var effects = Extensions.Repeatedly(() => forLevel.RandomItem()) .Distinct() - .Take(rarityEnchCount) + .Take(takeMin) .Shuffle(); var oldench = effects.First().Enchantment; diff --git a/HalgarisRPGLoot/WeaponAnalyer.cs b/HalgarisRPGLoot/WeaponAnalyer.cs index b6810ff..96f3cdd 100644 --- a/HalgarisRPGLoot/WeaponAnalyer.cs +++ b/HalgarisRPGLoot/WeaponAnalyer.cs @@ -233,9 +233,10 @@ private FormKey GenerateEnchantment( { var level = item.Entry.Data.Level; var forLevel = ByLevelIndexed[level]; + var takeMin = Math.Min(rarityEnchCount, forLevel.Length); var effects = Extensions.Repeatedly(() => forLevel.RandomItem()) .Distinct() - .Take(rarityEnchCount) + .Take(takeMin) .Shuffle(); var oldench = effects.First().Enchantment;