diff --git a/PKHeX/PKM/PK2.cs b/PKHeX/PKM/PK2.cs index fcd06f5dd..a6319b95c 100644 --- a/PKHeX/PKM/PK2.cs +++ b/PKHeX/PKM/PK2.cs @@ -337,6 +337,13 @@ public override int Stat_Level Array.Copy(otname, 0, pk1.otname, 0, otname.Length); Array.Copy(nick, 0, pk1.nick, 0, nick.Length); + int[] newMoves = pk1.Moves; + for (int i = 0; i < 4; i++) + if (newMoves[i] > 165) // not present in Gen 1 + newMoves[i] = 0; + pk1.Moves = newMoves; + pk1.FixMoves(); + return pk1; } } diff --git a/PKHeX/PKM/PKMConverter.cs b/PKHeX/PKM/PKMConverter.cs index 55fd04f4d..7ab96784a 100644 --- a/PKHeX/PKM/PKMConverter.cs +++ b/PKHeX/PKM/PKMConverter.cs @@ -100,43 +100,32 @@ namespace PKHeX } internal static PKM convertToFormat(PKM pk, int Format, out string comment) { - string currentFormat = pk.Format.ToString(); - PKM pkm = pk.Clone(); - - if (pk == null) + if (pk == null || pk.Species == 0) { comment = "Null input. Aborting."; return null; } + + string currentFormat = pk.Format.ToString(); + PKM pkm = pk.Clone(); + if (pk.Format == Format) { comment = "No need to convert, current format matches requested format."; return pk; } - if (pk.Format != Format && pk.Format <= 2 && Format <= 2) + if (pk.Format <= 2 && Format <= 2) // 1<->2, already checked not equal { - if (Format == 2) // pk.Format == 1 + switch (Format) { - pkm = ((PK1) pk).convertToPK2(); - } - if (Format == 1) // pk.Format == 2 - { - // Only convert if it's legal to do so. - if (1 <= pk.Species && pk.Species <= 151) - { - foreach (var move in new[] { pk.Move1, pk.Move2, pk.Move3, pk.Move4}) - if (move < 1 || move > 165) - { - comment = $"Pokemon cannot be converted due to invalid move: {Main.movelist[move]}"; - return null; - } - pkm = ((PK2) pk).convertToPK1(); - } - else - { - comment =$"Cannot convert a {PKX.getSpeciesName(pk.Species, ((PK2)pk).Japanese ? 1 : 2)} to pk{Format}"; - return null; - } + case 1: + if (pk.Species > 151) + { comment = $"Cannot convert a {PKX.getSpeciesName(pk.Species, ((PK2)pk).Japanese ? 1 : 2)} to pk{Format}"; return null; } + pkm = ((PK2)pk).convertToPK1(); + break; + case 2: + pkm = ((PK1)pk).convertToPK2(); + break; } comment = $"Converted from pk{pk.Format} to pk{Format}"; return pkm;