Clear gen2 exclusive moves on pk2->pk1

Closes #1214
This commit is contained in:
Kurt 2017-06-10 08:31:31 -07:00
parent 8a1691eb91
commit d19b83000d
2 changed files with 23 additions and 0 deletions

View File

@ -895,5 +895,27 @@ public void TransferPropertiesWithReflection(PKM Source, PKM Destination)
ReflectUtil.SetValue(Destination, property, prop);
}
}
/// <summary>
/// Clears moves that a <see cref="PKM"/> may have, possibly from a future generation.
/// </summary>
public void ClearInvalidMoves()
{
uint invalid = 0;
var moves = Moves;
for (var i = 0; i < moves.Length; i++)
{
if (moves[i] <= MaxMoveID)
continue;
invalid++;
moves[i] = 0;
}
if (invalid == 0)
return;
Moves = moves;
FixMoves();
}
}
}

View File

@ -227,6 +227,7 @@ public static PKM convertToFormat(PKM pk, Type PKMType, out string comment)
return null;
}
pkm = ((PK2) pk).convertToPK1();
pkm.ClearInvalidMoves();
}
else
pkm = null;