mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-05-13 23:50:25 -05:00
Add parameter-less constructors
Removes null check for hot path where data is actually provided
This commit is contained in:
parent
95776d8520
commit
cfbdb7c26c
|
|
@ -28,10 +28,8 @@ public override int Ball
|
|||
set => Gift.Ball = value;
|
||||
}
|
||||
|
||||
public PCD(byte[] data = null)
|
||||
{
|
||||
Data = data ?? new byte[Size];
|
||||
}
|
||||
public PCD() => Data = new byte[Size];
|
||||
public PCD(byte[] data) => Data = data;
|
||||
|
||||
public PGT Gift
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,10 +11,8 @@ public sealed class PGF : MysteryGift, IRibbonSetEvent3, IRibbonSetEvent4, ILang
|
|||
public const int Size = 0xCC;
|
||||
public override int Format => 5;
|
||||
|
||||
public PGF(byte[] data = null)
|
||||
{
|
||||
Data = data ?? new byte[Size];
|
||||
}
|
||||
public PGF() => Data = new byte[Size];
|
||||
public PGF(byte[] data) => Data = data;
|
||||
|
||||
public override int TID { get => BitConverter.ToUInt16(Data, 0x00); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x00); }
|
||||
public override int SID { get => BitConverter.ToUInt16(Data, 0x02); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x02); }
|
||||
|
|
|
|||
|
|
@ -45,10 +45,8 @@ private enum GiftType
|
|||
public override bool GiftUsed { get => false; set { } }
|
||||
public override object Content => PK;
|
||||
|
||||
public PGT(byte[] data = null)
|
||||
{
|
||||
Data = data ?? new byte[Size];
|
||||
}
|
||||
public PGT() => Data = new byte[Size];
|
||||
public PGT(byte[] data) => Data = data;
|
||||
|
||||
public byte CardType { get => Data[0]; set => Data[0] = value; }
|
||||
// Unused 0x01
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ public sealed class WB7 : MysteryGift, IRibbonSetEvent3, IRibbonSetEvent4, ILang
|
|||
|
||||
public override int Format => 7;
|
||||
|
||||
public WB7() : this(new byte[SizeFull]) { }
|
||||
public WB7() => Data = new byte[SizeFull];
|
||||
public WB7(byte[] data) => Data = data;
|
||||
|
||||
public byte RestrictVersion { get => Data[0]; set => Data[0] = value; }
|
||||
|
|
@ -418,7 +418,7 @@ public override PKM ConvertToPKM(ITrainerInfo SAV)
|
|||
if ((SAV.Generation > Format && OriginGame == 0) || !CanBeReceivedByVersion(pk.Version))
|
||||
{
|
||||
// give random valid game
|
||||
do { pk.Version = (int)GameVersion.SN + Util.Rand.Next(4); }
|
||||
do { pk.Version = (int)GameVersion.GP + Util.Rand.Next(2); }
|
||||
while (!CanBeReceivedByVersion(pk.Version));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,9 +14,11 @@ public sealed class WC6 : MysteryGift, IRibbonSetEvent3, IRibbonSetEvent4, ILang
|
|||
public const uint EonTicketConst = 0x225D73C2;
|
||||
public override int Format => 6;
|
||||
|
||||
public WC6(byte[] data = null)
|
||||
public WC6() => Data = new byte[Size];
|
||||
|
||||
public WC6(byte[] data)
|
||||
{
|
||||
Data = data ?? new byte[Size];
|
||||
Data = data;
|
||||
if (Data.Length == SizeFull)
|
||||
{
|
||||
// Load Restrictions
|
||||
|
|
|
|||
|
|
@ -13,9 +13,11 @@ public sealed class WC7 : MysteryGift, IRibbonSetEvent3, IRibbonSetEvent4, ILang
|
|||
public const int SizeFull = 0x310;
|
||||
public override int Format => 7;
|
||||
|
||||
public WC7(byte[] data = null)
|
||||
public WC7() => Data = new byte[Size];
|
||||
|
||||
public WC7(byte[] data)
|
||||
{
|
||||
Data = data ?? new byte[Size];
|
||||
Data = data;
|
||||
if (Data.Length != SizeFull)
|
||||
return;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ namespace PKHeX.Core
|
|||
/// <summary>
|
||||
/// Notes about the next format
|
||||
/// </summary>
|
||||
public class PB7 : PKM, IAwakened
|
||||
public sealed class PB7 : PKM, IAwakened
|
||||
{
|
||||
public static readonly byte[] ExtraBytes =
|
||||
{
|
||||
|
|
@ -21,9 +21,11 @@ public class PB7 : PKM, IAwakened
|
|||
public override int Format => 7;
|
||||
public override PersonalInfo PersonalInfo => PersonalTable.GG.GetFormeEntry(Species, AltForm);
|
||||
|
||||
public PB7(byte[] decryptedData = null, string ident = null)
|
||||
public PB7() => Data = new byte[SIZE];
|
||||
|
||||
public PB7(byte[] decryptedData, string ident = null)
|
||||
{
|
||||
Data = decryptedData ?? new byte[SIZE];
|
||||
Data = decryptedData;
|
||||
PKMConverter.CheckEncrypted(ref Data, 7);
|
||||
Identifier = ident;
|
||||
if (Data.Length != SIZE)
|
||||
|
|
|
|||
|
|
@ -15,16 +15,17 @@ public sealed class PK3 : _K3
|
|||
public override int Format => 3;
|
||||
public override PersonalInfo PersonalInfo => PersonalTable.RS[Species];
|
||||
|
||||
public PK3(byte[] decryptedData = null, string ident = null)
|
||||
public PK3() => Data = new byte[PKX.SIZE_3PARTY];
|
||||
|
||||
public PK3(byte[] decryptedData, string ident = null)
|
||||
{
|
||||
Data = decryptedData ?? new byte[SIZE_PARTY];
|
||||
Data = decryptedData;
|
||||
PKMConverter.CheckEncrypted(ref Data, Format);
|
||||
Identifier = ident;
|
||||
if (Data.Length != SIZE_PARTY)
|
||||
Array.Resize(ref Data, SIZE_PARTY);
|
||||
}
|
||||
|
||||
public PK3() => Data = new byte[SIZE_PARTY];
|
||||
public override PKM Clone() => new PK3((byte[])Data.Clone(), Identifier);
|
||||
|
||||
private string GetString(int Offset, int Count) => StringConverter.GetString3(Data, Offset, Count, Japanese);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,9 @@ public sealed class PK4 : _K4
|
|||
public override int Format => 4;
|
||||
public override PersonalInfo PersonalInfo => PersonalTable.HGSS.GetFormeEntry(Species, AltForm);
|
||||
|
||||
public PK4(byte[] decryptedData = null, string ident = null)
|
||||
public PK4() => Data = new byte[PKX.SIZE_4PARTY];
|
||||
|
||||
public PK4(byte[] decryptedData, string ident = null)
|
||||
{
|
||||
Data = decryptedData ?? new byte[SIZE_PARTY];
|
||||
PKMConverter.CheckEncrypted(ref Data, Format);
|
||||
|
|
@ -25,7 +27,6 @@ public PK4(byte[] decryptedData = null, string ident = null)
|
|||
Array.Resize(ref Data, SIZE_PARTY);
|
||||
}
|
||||
|
||||
public PK4() => Data = new byte[SIZE_PARTY];
|
||||
public override PKM Clone() => new PK4((byte[])Data.Clone(), Identifier);
|
||||
|
||||
private string GetString(int Offset, int Count) => StringConverter.GetString4(Data, Offset, Count);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,9 @@ public sealed class PK5 : PKM, IRibbonSetEvent3, IRibbonSetEvent4, IRibbonSetUni
|
|||
public override int Format => 5;
|
||||
public override PersonalInfo PersonalInfo => PersonalTable.B2W2.GetFormeEntry(Species, AltForm);
|
||||
|
||||
public PK5(byte[] decryptedData = null, string ident = null)
|
||||
public PK5() => Data = new byte[PKX.SIZE_5PARTY];
|
||||
|
||||
public PK5(byte[] decryptedData, string ident = null)
|
||||
{
|
||||
Data = decryptedData ?? new byte[SIZE_PARTY];
|
||||
PKMConverter.CheckEncrypted(ref Data, Format);
|
||||
|
|
|
|||
|
|
@ -17,7 +17,9 @@ public sealed class PK6 : PKM, IRibbonSetEvent3, IRibbonSetEvent4, IRibbonSetCom
|
|||
public override int Format => 6;
|
||||
public override PersonalInfo PersonalInfo => PersonalTable.AO.GetFormeEntry(Species, AltForm);
|
||||
|
||||
public PK6(byte[] decryptedData = null, string ident = null)
|
||||
public PK6() => Data = new byte[PKX.SIZE_6PARTY];
|
||||
|
||||
public PK6(byte[] decryptedData, string ident = null)
|
||||
{
|
||||
Data = decryptedData ?? new byte[SIZE_PARTY];
|
||||
PKMConverter.CheckEncrypted(ref Data, Format);
|
||||
|
|
|
|||
|
|
@ -18,9 +18,11 @@ public sealed class PK7 : PKM, IRibbonSetEvent3, IRibbonSetEvent4, IRibbonSetCom
|
|||
public override int Format => 7;
|
||||
public override PersonalInfo PersonalInfo => PersonalTable.USUM.GetFormeEntry(Species, AltForm);
|
||||
|
||||
public PK7(byte[] decryptedData = null, string ident = null)
|
||||
public PK7() => Data = new byte[PKX.SIZE_6PARTY];
|
||||
|
||||
public PK7(byte[] decryptedData, string ident = null)
|
||||
{
|
||||
Data = decryptedData ?? new byte[SIZE_PARTY];
|
||||
Data = decryptedData;
|
||||
PKMConverter.CheckEncrypted(ref Data, Format);
|
||||
Identifier = ident;
|
||||
if (Data.Length != SIZE_PARTY)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user