From 03be38c8df4a536da1614d8cc8c30dc8b37eaae7 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sat, 28 Jan 2023 19:18:10 -0800 Subject: [PATCH] Handle remapped zukan species The one critical spot it was needed :( Revise SeenAll for genderflag set; just wipe -> reapply. Closes #3745 --- .../Saves/Substructures/PokeDex/Zukan9.cs | 42 ++++++++++++------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/PKHeX.Core/Saves/Substructures/PokeDex/Zukan9.cs b/PKHeX.Core/Saves/Substructures/PokeDex/Zukan9.cs index f58c49d13..cfeff2889 100644 --- a/PKHeX.Core/Saves/Substructures/PokeDex/Zukan9.cs +++ b/PKHeX.Core/Saves/Substructures/PokeDex/Zukan9.cs @@ -24,7 +24,9 @@ public sealed class Zukan9 : ZukanBase { if (species > SAV.MaxSpeciesID) throw new ArgumentOutOfRangeException(nameof(species), species, null); - var span = Paldea.Data.AsSpan(species * EntrySize); + + var internalSpecies = SpeciesConverter.GetInternal9(species); + var span = Paldea.Data.AsSpan(internalSpecies * EntrySize); return new PokeDexEntry9SV(span); } @@ -165,36 +167,44 @@ public sealed class Zukan9 : ZukanBase private void SeenAll(ushort species, byte formCount, bool value = true, bool shinyToo = false) { + // Wipe existing gender flags. + var entry = Get(species); + entry.SetIsGenderSeen(0, false); + entry.SetIsGenderSeen(1, false); + if (value && !entry.IsSeen) + entry.SetSeen(value); + if (!value || shinyToo) + entry.SetSeenIsShiny(value); + var pt = SAV.Personal; for (byte form = 0; form < formCount; form++) { var pi = pt.GetFormEntry(species, form); - var seenSpecies = value; - bool seenForm = seenSpecies && pi.IsPresentInGame; - SeenAll(species, form, pi, shinyToo, seenSpecies, seenForm); + bool seenForm = value && pi.IsPresentInGame; + SetIsFormSeen(entry, pi, form, seenForm); } } + - private void SeenAll(ushort species, byte form, IGenderDetail pi, bool shinyToo, bool seenSpecies, bool seenForm) + private static void SetIsFormSeen(PokeDexEntry9SV entry, IGenderDetail pi, byte form, bool seenForm) { - var entry = Get(species); - if (seenSpecies && !entry.IsSeen) - entry.SetSeen(seenSpecies); + entry.SetIsFormSeen(form, seenForm); + if (seenForm) + SetIsFormSeenGender(entry, pi); + } - if (!seenSpecies || (seenForm && pi.IsDualGender)) + private static void SetIsFormSeenGender(PokeDexEntry9SV entry, IGenderDetail pi) + { + if (pi.IsDualGender) { - entry.SetIsGenderSeen(0, seenForm); - entry.SetIsGenderSeen(1, seenForm); + entry.SetIsGenderSeen(0, true); + entry.SetIsGenderSeen(1, true); } else { var gender = pi.FixedGender(); - entry.SetIsGenderSeen(gender, seenForm); + entry.SetIsGenderSeen(gender, true); } - entry.SetIsFormSeen(form, seenForm); - - if (!seenSpecies || shinyToo) - entry.SetSeenIsShiny(seenSpecies); } public override void CompleteDex(bool shinyToo = false)