From 6cff642ff197a0aa49783ebc95272d98153f38b7 Mon Sep 17 00:00:00 2001 From: Kurt Date: Mon, 4 Jun 2018 20:25:54 -0700 Subject: [PATCH] Skip format check on pk* init also remove ck3/xk3 no-op call (no encryption for those formats, like bk4). --- PKHeX.Core/PKM/CK3.cs | 3 --- PKHeX.Core/PKM/PK3.cs | 2 +- PKHeX.Core/PKM/PK4.cs | 2 +- PKHeX.Core/PKM/PK5.cs | 2 +- PKHeX.Core/PKM/PK6.cs | 2 +- PKHeX.Core/PKM/PK7.cs | 2 +- PKHeX.Core/PKM/Util/PKMConverter.cs | 8 ++++---- PKHeX.Core/PKM/XK3.cs | 3 --- 8 files changed, 9 insertions(+), 15 deletions(-) diff --git a/PKHeX.Core/PKM/CK3.cs b/PKHeX.Core/PKM/CK3.cs index e5776e4ef..8221a8016 100644 --- a/PKHeX.Core/PKM/CK3.cs +++ b/PKHeX.Core/PKM/CK3.cs @@ -21,10 +21,7 @@ namespace PKHeX.Core public CK3(byte[] decryptedData = null, string ident = null) { Data = decryptedData ?? new byte[SIZE_PARTY]; - PKMConverter.CheckEncrypted(ref Data); Identifier = ident; - if (Data.Length != SIZE_PARTY) - Array.Resize(ref Data, SIZE_PARTY); } public CK3() => Data = new byte[SIZE_PARTY]; public override PKM Clone() => new CK3((byte[])Data.Clone(), Identifier); diff --git a/PKHeX.Core/PKM/PK3.cs b/PKHeX.Core/PKM/PK3.cs index cdc7719e1..1f9f81620 100644 --- a/PKHeX.Core/PKM/PK3.cs +++ b/PKHeX.Core/PKM/PK3.cs @@ -17,7 +17,7 @@ namespace PKHeX.Core public PK3(byte[] decryptedData = null, string ident = null) { Data = decryptedData ?? new byte[SIZE_PARTY]; - PKMConverter.CheckEncrypted(ref Data); + PKMConverter.CheckEncrypted(ref Data, Format); Identifier = ident; if (Data.Length != SIZE_PARTY) Array.Resize(ref Data, SIZE_PARTY); diff --git a/PKHeX.Core/PKM/PK4.cs b/PKHeX.Core/PKM/PK4.cs index 056f95a51..faf7562d0 100644 --- a/PKHeX.Core/PKM/PK4.cs +++ b/PKHeX.Core/PKM/PK4.cs @@ -18,7 +18,7 @@ namespace PKHeX.Core public PK4(byte[] decryptedData = null, string ident = null) { Data = decryptedData ?? new byte[SIZE_PARTY]; - PKMConverter.CheckEncrypted(ref Data); + PKMConverter.CheckEncrypted(ref Data, Format); Identifier = ident; if (Data.Length != SIZE_PARTY) Array.Resize(ref Data, SIZE_PARTY); diff --git a/PKHeX.Core/PKM/PK5.cs b/PKHeX.Core/PKM/PK5.cs index 733ff4128..14979832e 100644 --- a/PKHeX.Core/PKM/PK5.cs +++ b/PKHeX.Core/PKM/PK5.cs @@ -18,7 +18,7 @@ namespace PKHeX.Core public PK5(byte[] decryptedData = null, string ident = null) { Data = decryptedData ?? new byte[SIZE_PARTY]; - PKMConverter.CheckEncrypted(ref Data); + PKMConverter.CheckEncrypted(ref Data, Format); Identifier = ident; if (Data.Length != SIZE_PARTY) Array.Resize(ref Data, SIZE_PARTY); diff --git a/PKHeX.Core/PKM/PK6.cs b/PKHeX.Core/PKM/PK6.cs index 7303d907d..95144c438 100644 --- a/PKHeX.Core/PKM/PK6.cs +++ b/PKHeX.Core/PKM/PK6.cs @@ -19,7 +19,7 @@ namespace PKHeX.Core public PK6(byte[] decryptedData = null, string ident = null) { Data = decryptedData ?? new byte[SIZE_PARTY]; - PKMConverter.CheckEncrypted(ref Data); + PKMConverter.CheckEncrypted(ref Data, Format); Identifier = ident; if (Data.Length != SIZE_PARTY) Array.Resize(ref Data, SIZE_PARTY); diff --git a/PKHeX.Core/PKM/PK7.cs b/PKHeX.Core/PKM/PK7.cs index 60ca5a15f..72222478e 100644 --- a/PKHeX.Core/PKM/PK7.cs +++ b/PKHeX.Core/PKM/PK7.cs @@ -20,7 +20,7 @@ namespace PKHeX.Core public PK7(byte[] decryptedData = null, string ident = null) { Data = decryptedData ?? new byte[SIZE_PARTY]; - PKMConverter.CheckEncrypted(ref Data); + PKMConverter.CheckEncrypted(ref Data, Format); Identifier = ident; if (Data.Length != SIZE_PARTY) Array.Resize(ref Data, SIZE_PARTY); diff --git a/PKHeX.Core/PKM/Util/PKMConverter.cs b/PKHeX.Core/PKM/Util/PKMConverter.cs index 0c073a3c9..69ebb6cc1 100644 --- a/PKHeX.Core/PKM/Util/PKMConverter.cs +++ b/PKHeX.Core/PKM/Util/PKMConverter.cs @@ -85,8 +85,8 @@ namespace PKHeX.Core /// An instance of created from the given , or null if is invalid. public static PKM GetPKMfromBytes(byte[] data, string ident = null, int prefer = 7) { - CheckEncrypted(ref data); - switch (GetPKMDataFormat(data)) + int format = GetPKMDataFormat(data); + switch (format) { case 1: var PL1 = new PokemonList1(data, PokemonList1.CapacityType.Single, data.Length == PKX.SIZE_1JLIST); @@ -361,9 +361,9 @@ namespace PKHeX.Core /// /// The input PKM object is decrypted; no new object is returned. /// PKM to check encryption for (and decrypt if appropriate). - public static void CheckEncrypted(ref byte[] pkm) + /// Format specific check selection + public static void CheckEncrypted(ref byte[] pkm, int format) { - int format = GetPKMDataFormat(pkm); switch (format) { case 1: diff --git a/PKHeX.Core/PKM/XK3.cs b/PKHeX.Core/PKM/XK3.cs index fa9b042f3..1de1ff0f5 100644 --- a/PKHeX.Core/PKM/XK3.cs +++ b/PKHeX.Core/PKM/XK3.cs @@ -19,10 +19,7 @@ namespace PKHeX.Core public XK3(byte[] decryptedData = null, string ident = null) { Data = decryptedData ?? new byte[SIZE_PARTY]; - PKMConverter.CheckEncrypted(ref Data); Identifier = ident; - if (Data.Length != SIZE_PARTY) - Array.Resize(ref Data, SIZE_PARTY); } public XK3() => Data = new byte[SIZE_PARTY]; public override PKM Clone() => new XK3((byte[])Data.Clone(), Identifier) {Purification = Purification};