From 86814d014d29801c613f93043f0262336c8bd05d Mon Sep 17 00:00:00 2001 From: Kurt Date: Thu, 2 Jun 2022 19:04:27 -0700 Subject: [PATCH] Fix recog of Home fixed PID shinies Not to be confused with Home fixed PID antishinies WC8 is the only format to have fixed shinies, but let's copy the logic to WB8 and WA8 if they're ever added in the future. Fix mgdb display filtering for SWSH & PLA (swapped oops) Closes #3511 --- PKHeX.Core/MysteryGifts/WA8.cs | 4 ++++ PKHeX.Core/MysteryGifts/WB8.cs | 3 +++ PKHeX.Core/MysteryGifts/WC8.cs | 3 +++ PKHeX.WinForms/Subforms/SAV_MysteryGiftDB.cs | 9 ++++++--- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/PKHeX.Core/MysteryGifts/WA8.cs b/PKHeX.Core/MysteryGifts/WA8.cs index 9962610ff..60fb55e61 100644 --- a/PKHeX.Core/MysteryGifts/WA8.cs +++ b/PKHeX.Core/MysteryGifts/WA8.cs @@ -548,9 +548,13 @@ private void SetPINGA(PKM pk, EncounterCriteria criteria) ShinyType8.FixedValue => GetFixedPID(tr), _ => throw new ArgumentOutOfRangeException(nameof(type)), }; + private uint GetFixedPID(ITrainerID tr) { var pid = PID; + if (pid != 0 && !(TID == 0 && SID == 0)) + return pid; + if (!tr.IsShiny(pid, 8)) return pid; if (IsHOMEGift) diff --git a/PKHeX.Core/MysteryGifts/WB8.cs b/PKHeX.Core/MysteryGifts/WB8.cs index 3b76270af..771c83d55 100644 --- a/PKHeX.Core/MysteryGifts/WB8.cs +++ b/PKHeX.Core/MysteryGifts/WB8.cs @@ -548,6 +548,9 @@ private void SetPINGA(PKM pk, EncounterCriteria criteria) private uint GetFixedPID(ITrainerID tr) { var pid = PID; + if (pid != 0 && !(TID == 0 && SID == 0)) + return pid; + if (!tr.IsShiny(pid, 8)) return pid; if (IsHOMEGift) diff --git a/PKHeX.Core/MysteryGifts/WC8.cs b/PKHeX.Core/MysteryGifts/WC8.cs index ffd2623c4..4da324e78 100644 --- a/PKHeX.Core/MysteryGifts/WC8.cs +++ b/PKHeX.Core/MysteryGifts/WC8.cs @@ -541,6 +541,9 @@ private void SetPINGA(PKM pk, EncounterCriteria criteria) private uint GetFixedPID(ITrainerID tr) { var pid = PID; + if (pid != 0 && !(TID == 0 && SID == 0)) + return pid; + if (!tr.IsShiny(pid, 8)) return pid; if (IsHOMEGift && !IsHOMEShinyPossible(DateTime.Now)) diff --git a/PKHeX.WinForms/Subforms/SAV_MysteryGiftDB.cs b/PKHeX.WinForms/Subforms/SAV_MysteryGiftDB.cs index 6632b56e0..70bd6b6e6 100644 --- a/PKHeX.WinForms/Subforms/SAV_MysteryGiftDB.cs +++ b/PKHeX.WinForms/Subforms/SAV_MysteryGiftDB.cs @@ -214,11 +214,14 @@ private void LoadDatabase() if (Main.Settings.MysteryDb.FilterUnavailableSpecies) { + static bool IsPresentInGameSWSH(ISpeciesForm pk) => PersonalTable.SWSH.IsPresentInGame(pk.Species, pk.Form); + static bool IsPresentInGameBDSP(ISpeciesForm pk) => PersonalTable.BDSP.IsPresentInGame(pk.Species, pk.Form); + static bool IsPresentInGameLA(ISpeciesForm pk) => PersonalTable.LA.IsPresentInGame(pk.Species, pk.Form); db = SAV switch { - SAV8LA => db.Where(z => PersonalTable.SWSH.IsPresentInGame(z.Species, z.Form)), - SAV8BS => db.Where(z => PersonalTable.BDSP.IsPresentInGame(z.Species, z.Form)), - SAV8SWSH => db.Where(z => PersonalTable.LA.IsPresentInGame(z.Species, z.Form)), + SAV8SWSH => db.Where(IsPresentInGameSWSH), + SAV8BS => db.Where(IsPresentInGameBDSP), + SAV8LA => db.Where(IsPresentInGameLA), SAV7b => db.Where(z => z is WB7), SAV7 => db.Where(z => z.Generation < 7 || z is WC7), _ => db.Where(z => z.Generation <= SAV.Generation),