Clean up SetDex guard clauses

add egg checks for gen4-6/8, group species bound checks
This commit is contained in:
Kurt
2021-06-04 17:26:06 -07:00
parent 7ee60d9e98
commit d30e00ffbe
5 changed files with 8 additions and 10 deletions

View File

@@ -128,8 +128,6 @@ private void ClearSeen(int species)
public override void SetDex(PKM pkm)
{
if (SAV.Version == GameVersion.Invalid) // sanity
return;
if ((uint)(pkm.Species - 1) >= (uint)SAV.MaxSpeciesID) // out of range
return;
if (pkm.IsEgg) // do not add

View File

@@ -281,6 +281,8 @@ public override void SetDex(PKM pkm)
int species = pkm.Species;
if (species is 0 or > Legal.MaxSpeciesID_4)
return;
if (pkm.IsEgg) // do not add
return;
var gender = pkm.Gender;
var form = pkm.Form;

View File

@@ -67,9 +67,9 @@ protected override void SetAllDexSeenFlags(int baseBit, int form, int gender, bo
public override void SetDex(PKM pkm)
{
if (pkm.Species == 0)
if (pkm.Species is 0 or > Legal.MaxSpeciesID_5)
return;
if (pkm.Species > SAV.MaxSpeciesID)
if (pkm.IsEgg) // do not add
return;
int bit = pkm.Species - 1;

View File

@@ -68,13 +68,9 @@ protected override void SetAllDexSeenFlags(int baseBit, int form, int gender, bo
public override void SetDex(PKM pkm)
{
if (PokeDex < 0)
if (pkm.Species is 0 or > Legal.MaxSpeciesID_6)
return;
if (pkm.Species == 0)
return;
if (pkm.Species > SAV.MaxSpeciesID)
return;
if (SAV.Version == GameVersion.Invalid)
if (pkm.IsEgg) // do not add
return;
int bit = pkm.Species - 1;

View File

@@ -470,6 +470,8 @@ public override void SetDex(PKM pkm)
int species = pkm.Species;
if (!GetEntry(species, out _))
return;
if (pkm.IsEgg) // do not add
return;
bool owned = GetCaught(species);