mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-10 14:44:24 +00:00
Add personalinfo references per PKM format
Fix possible hang in pk6/pk7 if country/region is unset (continues loop). PersonalInfo references are not to be used when calculating stats (use the savefile table instead)
This commit is contained in:
parent
26ff17fd24
commit
ed14ab7436
12 changed files with 44 additions and 2 deletions
|
@ -12,6 +12,7 @@ namespace PKHeX
|
|||
public sealed override int SIZE_PARTY => PKX.SIZE_4PARTY;
|
||||
public override int SIZE_STORED => PKX.SIZE_4STORED;
|
||||
public override int Format => 4;
|
||||
public override PersonalInfo PersonalInfo => PersonalTable.HGSS[Species];
|
||||
|
||||
public override byte[] DecryptedBoxData => EncryptedBoxData;
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace PKHeX
|
||||
{
|
||||
|
@ -16,6 +15,8 @@ namespace PKHeX
|
|||
public sealed override int SIZE_PARTY => PKX.SIZE_3CSTORED;
|
||||
public override int SIZE_STORED => PKX.SIZE_3CSTORED;
|
||||
public override int Format => 3;
|
||||
public override PersonalInfo PersonalInfo => PersonalTable.RS[Species];
|
||||
|
||||
public CK3(byte[] decryptedData = null, string ident = null)
|
||||
{
|
||||
Data = (byte[])(decryptedData ?? new byte[SIZE_PARTY]).Clone();
|
||||
|
|
|
@ -8,6 +8,7 @@ namespace PKHeX
|
|||
// Internal use only
|
||||
protected internal byte[] otname;
|
||||
protected internal byte[] nick;
|
||||
public override PersonalInfo PersonalInfo => PersonalTable.RBY[Species];
|
||||
|
||||
public byte[] OT_Name_Raw => (byte[])otname.Clone();
|
||||
public byte[] Nickname_Raw => (byte[])nick.Clone();
|
||||
|
|
|
@ -8,6 +8,7 @@ namespace PKHeX
|
|||
// Internal use only
|
||||
protected internal byte[] otname;
|
||||
protected internal byte[] nick;
|
||||
public override PersonalInfo PersonalInfo => PersonalTable.C[Species];
|
||||
|
||||
public byte[] OT_Name_Raw => (byte[])otname.Clone();
|
||||
public byte[] Nickname_Raw => (byte[])nick.Clone();
|
||||
|
|
|
@ -12,6 +12,8 @@ namespace PKHeX
|
|||
public sealed override int SIZE_PARTY => PKX.SIZE_3PARTY;
|
||||
public override int SIZE_STORED => PKX.SIZE_3STORED;
|
||||
public override int Format => 3;
|
||||
public override PersonalInfo PersonalInfo => PersonalTable.RS[Species];
|
||||
|
||||
public PK3(byte[] decryptedData = null, string ident = null)
|
||||
{
|
||||
Data = (byte[])(decryptedData ?? new byte[SIZE_PARTY]).Clone();
|
||||
|
|
|
@ -12,6 +12,8 @@ namespace PKHeX
|
|||
public sealed override int SIZE_PARTY => PKX.SIZE_4PARTY;
|
||||
public override int SIZE_STORED => PKX.SIZE_4STORED;
|
||||
public override int Format => 4;
|
||||
public override PersonalInfo PersonalInfo => PersonalTable.HGSS.getFormeEntry(Species, AltForm);
|
||||
|
||||
public PK4(byte[] decryptedData = null, string ident = null)
|
||||
{
|
||||
Data = (byte[])(decryptedData ?? new byte[SIZE_PARTY]).Clone();
|
||||
|
|
|
@ -13,6 +13,8 @@ namespace PKHeX
|
|||
public sealed override int SIZE_PARTY => PKX.SIZE_5PARTY;
|
||||
public override int SIZE_STORED => PKX.SIZE_5STORED;
|
||||
public override int Format => 5;
|
||||
public override PersonalInfo PersonalInfo => PersonalTable.B2W2.getFormeEntry(Species, AltForm);
|
||||
|
||||
public PK5(byte[] decryptedData = null, string ident = null)
|
||||
{
|
||||
Data = (byte[])(decryptedData ?? new byte[SIZE_PARTY]).Clone();
|
||||
|
|
|
@ -14,6 +14,8 @@ namespace PKHeX
|
|||
public sealed override int SIZE_PARTY => PKX.SIZE_6PARTY;
|
||||
public override int SIZE_STORED => PKX.SIZE_6STORED;
|
||||
public override int Format => 6;
|
||||
public override PersonalInfo PersonalInfo => (AO ? PersonalTable.AO : PersonalTable.XY).getFormeEntry(Species, AltForm);
|
||||
|
||||
public PK6(byte[] decryptedData = null, string ident = null)
|
||||
{
|
||||
Data = (byte[])(decryptedData ?? new byte[SIZE_PARTY]).Clone();
|
||||
|
@ -530,6 +532,8 @@ namespace PKHeX
|
|||
}
|
||||
if (Geo1_Country == 0 && !IsUntraded && !IsUntradedEvent6)
|
||||
{
|
||||
if ((Country | Region) == 0)
|
||||
break;
|
||||
// Traded Non-Eggs/Events need to have a current location.
|
||||
Geo1_Country = Country;
|
||||
Geo1_Region = Region;
|
||||
|
|
|
@ -14,6 +14,8 @@ namespace PKHeX
|
|||
public sealed override int SIZE_PARTY => PKX.SIZE_6PARTY;
|
||||
public override int SIZE_STORED => PKX.SIZE_6STORED;
|
||||
public override int Format => 7;
|
||||
public override PersonalInfo PersonalInfo => PersonalTable.SM.getFormeEntry(Species, AltForm);
|
||||
|
||||
public PK7(byte[] decryptedData = null, string ident = null)
|
||||
{
|
||||
Data = (byte[])(decryptedData ?? new byte[SIZE_PARTY]).Clone();
|
||||
|
@ -538,6 +540,8 @@ namespace PKHeX
|
|||
}
|
||||
if (Geo1_Country == 0 && !IsUntraded && !IsUntradedEvent6)
|
||||
{
|
||||
if ((Country | Region) == 0)
|
||||
break;
|
||||
// Traded Non-Eggs/Events need to have a current location.
|
||||
Geo1_Country = Country;
|
||||
Geo1_Region = Region;
|
||||
|
|
|
@ -9,6 +9,7 @@ namespace PKHeX
|
|||
public abstract int SIZE_PARTY { get; }
|
||||
public abstract int SIZE_STORED { get; }
|
||||
public virtual string Extension => "pk" + Format;
|
||||
public abstract PersonalInfo PersonalInfo { get; }
|
||||
|
||||
// Internal Attributes set on creation
|
||||
public byte[] Data; // Raw Storage
|
||||
|
@ -388,10 +389,31 @@ namespace PKHeX
|
|||
public virtual bool WasEventEgg => ((Egg_Location > 40000 && Egg_Location < 50000) || (FatefulEncounter && Egg_Location > 0)) && Met_Level == 1;
|
||||
public virtual bool WasTradedEgg => Egg_Location == 30002;
|
||||
public virtual bool WasIngameTrade => Met_Location == 30001;
|
||||
public virtual bool IsUntraded => string.IsNullOrWhiteSpace(HT_Name);
|
||||
public virtual bool IsUntraded => string.IsNullOrWhiteSpace(HT_Name) && GenNumber == Format;
|
||||
public virtual bool SecretSuperTrainingUnlocked { get { return false; } set { } }
|
||||
public virtual bool SecretSuperTrainingComplete { get { return false; } set { } }
|
||||
|
||||
public bool InhabitedGeneration(int Generation)
|
||||
{
|
||||
if (Format < Generation)
|
||||
return false; // Future
|
||||
if (GenNumber > Generation)
|
||||
return false; // Past
|
||||
|
||||
switch (Generation) // Sanity Check Species ID
|
||||
{
|
||||
case 1: return Species <= Legal.MaxSpeciesID_1;
|
||||
case 2: return Species <= Legal.MaxSpeciesID_2;
|
||||
case 3: return Species <= Legal.MaxSpeciesID_3;
|
||||
case 4: return Species <= Legal.MaxSpeciesID_4;
|
||||
case 5: return Species <= Legal.MaxSpeciesID_5;
|
||||
case 6: return Species <= Legal.MaxSpeciesID_6;
|
||||
case 7: return Species <= Legal.MaxSpeciesID_7;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Methods
|
||||
public abstract bool getGenderIsValid();
|
||||
public void RefreshChecksum() { Checksum = CalculateChecksum(); }
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace PKHeX
|
|||
public sealed override int SIZE_PARTY => PKX.SIZE_3XSTORED;
|
||||
public override int SIZE_STORED => PKX.SIZE_3XSTORED;
|
||||
public override int Format => 3;
|
||||
public override PersonalInfo PersonalInfo => PersonalTable.RS[Species];
|
||||
public XK3(byte[] decryptedData = null, string ident = null)
|
||||
{
|
||||
Data = (byte[])(decryptedData ?? new byte[SIZE_PARTY]).Clone();
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace PKHeX.Tests.PKM
|
|||
public int EggMetYear { get; set; }
|
||||
public int EggMetMonth { get; set; }
|
||||
public int EggMetDay { get; set; }
|
||||
public override PersonalInfo PersonalInfo => null;
|
||||
|
||||
protected override int Met_Year
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue