Handle remapped zukan species

The one critical spot it was needed :(
Revise SeenAll for genderflag set; just wipe -> reapply.

Closes #3745
This commit is contained in:
Kurt 2023-01-28 19:18:10 -08:00
parent 19b7e0fda3
commit 03be38c8df

View file

@ -24,7 +24,9 @@ public sealed class Zukan9 : ZukanBase<SAV9SV>
{ {
if (species > SAV.MaxSpeciesID) if (species > SAV.MaxSpeciesID)
throw new ArgumentOutOfRangeException(nameof(species), species, null); 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); return new PokeDexEntry9SV(span);
} }
@ -165,36 +167,44 @@ public sealed class Zukan9 : ZukanBase<SAV9SV>
private void SeenAll(ushort species, byte formCount, bool value = true, bool shinyToo = false) 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; var pt = SAV.Personal;
for (byte form = 0; form < formCount; form++) for (byte form = 0; form < formCount; form++)
{ {
var pi = pt.GetFormEntry(species, form); var pi = pt.GetFormEntry(species, form);
var seenSpecies = value; bool seenForm = value && pi.IsPresentInGame;
bool seenForm = seenSpecies && pi.IsPresentInGame; SetIsFormSeen(entry, pi, form, seenForm);
SeenAll(species, form, pi, shinyToo, seenSpecies, 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); entry.SetIsFormSeen(form, seenForm);
if (seenSpecies && !entry.IsSeen) if (seenForm)
entry.SetSeen(seenSpecies); 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(0, true);
entry.SetIsGenderSeen(1, seenForm); entry.SetIsGenderSeen(1, true);
} }
else else
{ {
var gender = pi.FixedGender(); 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) public override void CompleteDex(bool shinyToo = false)