mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-14 08:17:14 +00:00
Add savegame sensitive pkm legality checking
uses the forme count of the savefile (rather than a futureproofed same-gen forme count) Closes #1559
This commit is contained in:
parent
062684f4a6
commit
24121553b4
5 changed files with 10 additions and 7 deletions
|
@ -25,6 +25,7 @@ namespace PKHeX.Core
|
|||
|
||||
public readonly bool Parsed;
|
||||
public readonly bool Valid;
|
||||
private readonly PersonalInfo PersonalInfo;
|
||||
public LegalInfo Info { get; private set; }
|
||||
public bool ParsedValid => Parsed && Valid;
|
||||
public bool ParsedInvalid => Parsed && !Valid;
|
||||
|
@ -68,12 +69,14 @@ namespace PKHeX.Core
|
|||
/// Checks the input <see cref="PKM"/> data for legality.
|
||||
/// </summary>
|
||||
/// <param name="pk">Input data to check</param>
|
||||
public LegalityAnalysis(PKM pk)
|
||||
/// <param name="table"><see cref="SaveFile"/> specific personal data</param>
|
||||
public LegalityAnalysis(PKM pk, PersonalTable table = null)
|
||||
{
|
||||
#if SUPPRESS
|
||||
try
|
||||
#endif
|
||||
{
|
||||
PersonalInfo = table?.GetFormeEntry(pk.Species, pk.AltForm) ?? pk.PersonalInfo;
|
||||
switch (pk.Format) // prior to storing GameVersion
|
||||
{
|
||||
case 1: ParsePK1(pk); break;
|
||||
|
|
|
@ -1852,11 +1852,11 @@ namespace PKHeX.Core
|
|||
if (pkm.Format < 4)
|
||||
return; // no forms exist
|
||||
|
||||
int count = pkm.PersonalInfo.FormeCount;
|
||||
int count = PersonalInfo.FormeCount;
|
||||
if (count == 1 && pkm.AltForm == 0)
|
||||
return; // no forms to check
|
||||
|
||||
if (pkm.AltForm > count && !IsValidOutOfBoundsForme(pkm.Species, pkm.AltForm, Info.Generation))
|
||||
if (pkm.AltForm >= count && !IsValidOutOfBoundsForme(pkm.Species, pkm.AltForm, Info.Generation))
|
||||
{
|
||||
AddLine(Severity.Invalid, string.Format(V304, count, pkm.AltForm), CheckIdentifier.Form);
|
||||
return;
|
||||
|
|
|
@ -221,7 +221,7 @@ namespace PKHeX.WinForms.Controls
|
|||
if (!fieldsLoaded)
|
||||
return;
|
||||
|
||||
Legality = la ?? new LegalityAnalysis(pkm);
|
||||
Legality = la ?? new LegalityAnalysis(pkm, RequestSaveFile.Personal);
|
||||
if (!Legality.Parsed || HaX || pkm.Species == 0)
|
||||
{
|
||||
PB_WarnMove1.Visible = PB_WarnMove2.Visible = PB_WarnMove3.Visible = PB_WarnMove4.Visible =
|
||||
|
|
|
@ -1010,7 +1010,7 @@ namespace PKHeX.WinForms
|
|||
return;
|
||||
|
||||
var sprite = dragout.Image;
|
||||
var la = new LegalityAnalysis(pkx);
|
||||
var la = new LegalityAnalysis(pkx, C_SAV.SAV.Personal);
|
||||
if (la.Parsed && pkx.Species != 0)
|
||||
{
|
||||
var img = la.Valid ? Resources.valid : Resources.warn;
|
||||
|
@ -1036,7 +1036,7 @@ namespace PKHeX.WinForms
|
|||
}
|
||||
private void ShowLegality(object sender, EventArgs e, PKM pk)
|
||||
{
|
||||
LegalityAnalysis la = new LegalityAnalysis(pk);
|
||||
LegalityAnalysis la = new LegalityAnalysis(pk, C_SAV.SAV.Personal);
|
||||
if (pk.Slot < 0)
|
||||
PKME_Tabs.UpdateLegality(la);
|
||||
bool verbose = ModifierKeys == Keys.Control;
|
||||
|
|
|
@ -145,7 +145,7 @@ namespace PKHeX.WinForms
|
|||
{
|
||||
if (slot < 30)
|
||||
pkm.Box = box;
|
||||
var la = new LegalityAnalysis(pkm);
|
||||
var la = new LegalityAnalysis(pkm, SAV.Personal);
|
||||
if (la.Parsed && !la.Valid && pkm.Species != 0)
|
||||
sprite = ImageUtil.LayerImage(sprite, Resources.warn, 0, 14, 1);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue