From 6e482946e2c5f2241861691dbe05c4eace424e63 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 11 Jan 2026 00:55:05 -0600 Subject: [PATCH] Add Gen4 HG/SS ball check GUI would display the selected ball, but internally it was forced back to Poke. Currently, the setter sanitizes both values, but if manually modified via external code, technically it could be in an invalid state. - Add check if ball is disassociated from what is expected (modified outside of the GUI) - GUI updates to the final (sanity checked) value regardless of what was selected. https://projectpokemon.org/home/forums/topic/57375-pkhex-new-update-legality-errors-contribution-page/page/35/#findComment-298902 --- PKHeX.Core/Legality/Verifiers/MiscVerifier.cs | 10 ++++++++++ PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs | 9 +++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/PKHeX.Core/Legality/Verifiers/MiscVerifier.cs b/PKHeX.Core/Legality/Verifiers/MiscVerifier.cs index 203721fec..f9a7ccaee 100644 --- a/PKHeX.Core/Legality/Verifiers/MiscVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/MiscVerifier.cs @@ -96,6 +96,16 @@ public override void Verify(LegalityAnalysis data) private void VerifyMisc4(LegalityAnalysis data, G4PKM pk) { + // Verify misc values that were introduced in HG/SS + + // Version is a true match. If not from HG/SS, should not have HG/SS ball value set. + if (pk.BallHGSS != 0 || pk.BallDPPt != pk.Ball) + { + // Only set the HG/SS value if it originated in HG/SS and was not an event. + if (!pk.HGSS || pk.FatefulEncounter) + data.AddLine(GetInvalid(CheckIdentifier.Ball, BallEncMismatch)); + } + // Mood: // Range is [-127, 127]. Deduplicated unique adjustments are +8, +10, and -20. // Increment adjustments of -2 (-20 +8 +10) and +2 (+8*4 +10 -20) are possible. diff --git a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs index 036d71f26..61b4a40b9 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs @@ -709,8 +709,13 @@ private void ClickBall(object sender, EventArgs e) using var frm = new BallBrowser(); frm.LoadBalls(Entity); frm.ShowDialog(); - if (frm.WasBallChosen) - CB_Ball.SelectedValue = (int)frm.BallChoice; + if (!frm.WasBallChosen) + return; + + // Set to the entity, then check the updated value. + // Gen4 has split fields for HG/SS and D/P/Pt segregation. If the value refused to update, show the refused value. + Entity.Ball = frm.BallChoice; + CB_Ball.SelectedValue = (int)Entity.Ball; } private void ClickMetLocation(object sender, EventArgs e)