diff --git a/PKHeX/Legality/Analysis.cs b/PKHeX/Legality/Analysis.cs index 331d2f021..dd2e11a3c 100644 --- a/PKHeX/Legality/Analysis.cs +++ b/PKHeX/Legality/Analysis.cs @@ -9,6 +9,12 @@ public partial class LegalityAnalysis private PKM pkm; private readonly List Parse = new List(); + private enum Encounters + { + Unknown = -1, + Generic = 0 + } + private object EncounterMatch; private Type EncounterType; private bool EncounterIsMysteryGift => EncounterType.IsSubclassOf(typeof (MysteryGift)); @@ -95,6 +101,10 @@ private void updateMoveLegality() private void updateChecks() { Encounter = verifyEncounter(); + + // If EncounterMatch is null, nullrefexception will prevent a lot of analysis from happening at all. + EncounterMatch = EncounterMatch ?? Encounters.Unknown; + EncounterType = EncounterMatch?.GetType(); if (EncounterType == typeof (MysteryGift)) EncounterType = EncounterType.BaseType;