From 3b8643bc77bf46225ed6a5f4ac74a42e039dbd7d Mon Sep 17 00:00:00 2001 From: Kurt Date: Tue, 18 Jul 2017 16:21:31 -0700 Subject: [PATCH] Fix gen1 VC legality checking error GetGenMovesCheckOrder doesn't respect generation restrictions, while EncounterMoves does; filter afterwards. Add compiler flags in the Analysis file to toggle try/catch off for easier debugging. Just uncomment the #define SUPPRESS line. Closes #1345 --- PKHeX.Core/Legality/Analysis.cs | 11 ++++++++--- PKHeX.Core/Legality/Encounters/VerifyCurrentMoves.cs | 4 +++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/PKHeX.Core/Legality/Analysis.cs b/PKHeX.Core/Legality/Analysis.cs index 4cb9a6e7a..489116374 100644 --- a/PKHeX.Core/Legality/Analysis.cs +++ b/PKHeX.Core/Legality/Analysis.cs @@ -1,6 +1,7 @@ -using System; +#define SUPPRESS + +using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; using System.Reflection; using static PKHeX.Core.LegalityCheckStrings; @@ -55,7 +56,9 @@ private IEnumerable AllSuggestedRelearnMoves public LegalityAnalysis(PKM pk) { +#if SUPPRESS try +#endif { switch (pk.Format) // prior to storing GameVersion { @@ -90,14 +93,16 @@ public LegalityAnalysis(PKM pk) AddLine(Severity.Indeterminate, V188, CheckIdentifier.Fateful); } } +#if SUPPRESS catch (Exception e) { - Debug.WriteLine(e.Message); + System.Diagnostics.Debug.WriteLine(e.Message); Valid = false; AddLine(Severity.Invalid, V190, CheckIdentifier.Misc); pkm = pk; Error = true; } +#endif Parsed = true; } diff --git a/PKHeX.Core/Legality/Encounters/VerifyCurrentMoves.cs b/PKHeX.Core/Legality/Encounters/VerifyCurrentMoves.cs index 73026af97..9862d78de 100644 --- a/PKHeX.Core/Legality/Encounters/VerifyCurrentMoves.cs +++ b/PKHeX.Core/Legality/Encounters/VerifyCurrentMoves.cs @@ -256,6 +256,8 @@ private static CheckMoveResult[] ParseMoves(PKM pkm, int[] moves, int[] special, var IncenseMovesLearned = new List(); // Check moves going backwards, marking the move valid in the most current generation when it can be learned int[] generations = GetGenMovesCheckOrder(pkm); + if (pkm.Format <= 2) + generations = generations.Where(z => z < info.EncounterMoves.LevelUpMoves.Length).ToArray(); foreach (var gen in generations) { var HMLearned = new int[0]; @@ -290,7 +292,7 @@ private static CheckMoveResult[] ParseMoves(PKM pkm, int[] moves, int[] special, else if (gen == pkm.GenNumber && special.Contains(moves[m])) res[m] = new CheckMoveResult(MoveSource.Special, gen, Severity.Valid, V175, CheckIdentifier.Move); - if (res[m] == null || gen < 3) + if (res[m] == null || gen >= 3) continue; if (res[m].Valid && gen == 2 && NonTradebackLvlMoves.Contains(m))