diff --git a/PKHeX.Core/PKM/BK4.cs b/PKHeX.Core/PKM/BK4.cs
index 58f572d1b..0a0a38004 100644
--- a/PKHeX.Core/PKM/BK4.cs
+++ b/PKHeX.Core/PKM/BK4.cs
@@ -22,12 +22,11 @@ public sealed class BK4 : _K4
public override bool Valid => ChecksumValid || (Sanity == 0 && Species <= MaxSpeciesID);
- public BK4(byte[] decryptedData, string ident = null)
+ public BK4(byte[] decryptedData)
{
Data = decryptedData;
uint sv = ((PID & 0x3E000) >> 0xD) % 24;
Data = PKX.ShuffleArray(Data, sv, PKX.SIZE_4BLOCK);
- Identifier = ident;
if (Sanity != 0 && Species <= MaxSpeciesID && !ChecksumValid) // We can only hope
RefreshChecksum();
if (Valid && Sanity == 0)
@@ -42,7 +41,7 @@ public BK4()
SetStats(GetStats(PersonalInfo));
}
- public override PKM Clone() => new BK4((byte[])Encrypt().Clone(), Identifier);
+ public override PKM Clone() => new BK4((byte[])Encrypt().Clone()){Identifier = Identifier};
public string GetString(int Offset, int Count) => StringConverter.GetBEString4(Data, Offset, Count);
public byte[] SetString(string value, int maxLength) => StringConverter.SetBEString4(value, maxLength);
diff --git a/PKHeX.Core/PKM/CK3.cs b/PKHeX.Core/PKM/CK3.cs
index 9a78da8e1..3d7c4b4c3 100644
--- a/PKHeX.Core/PKM/CK3.cs
+++ b/PKHeX.Core/PKM/CK3.cs
@@ -21,14 +21,9 @@ public sealed class CK3 : _K3, IShadowPKM
public override int Format => 3;
public override PersonalInfo PersonalInfo => PersonalTable.RS[Species];
- public CK3(byte[] decryptedData, string ident = null)
- {
- Data = decryptedData;
- Identifier = ident;
- }
-
+ public CK3(byte[] decryptedData) => Data = decryptedData;
public CK3() => Data = new byte[SIZE_PARTY];
- public override PKM Clone() => new CK3((byte[])Data.Clone(), Identifier);
+ public override PKM Clone() => new CK3((byte[])Data.Clone()) {Identifier = Identifier};
private string GetString(int Offset, int Count) => StringConverter.GetBEString3(Data, Offset, Count);
private byte[] SetString(string value, int maxLength) => StringConverter.SetBEString3(value, maxLength);
diff --git a/PKHeX.Core/PKM/PB7.cs b/PKHeX.Core/PKM/PB7.cs
index 702fb27ac..d13811b04 100644
--- a/PKHeX.Core/PKM/PB7.cs
+++ b/PKHeX.Core/PKM/PB7.cs
@@ -29,16 +29,15 @@ public sealed class PB7 : _K6, IHyperTrain, IAwakened
public PB7() => Data = new byte[SIZE];
- public PB7(byte[] decryptedData, string ident = null)
+ public PB7(byte[] decryptedData)
{
Data = decryptedData;
PKMConverter.CheckEncrypted(ref Data, 7);
- Identifier = ident;
if (Data.Length != SIZE)
Array.Resize(ref Data, SIZE);
}
- public override PKM Clone() => new PB7((byte[])Data.Clone(), Identifier);
+ public override PKM Clone() => new PB7((byte[])Data.Clone()){Identifier = Identifier};
private string GetString(int Offset, int Count) => StringConverter.GetString7(Data, Offset, Count);
private byte[] SetString(string value, int maxLength, bool chinese = false) => StringConverter.SetString7b(value, maxLength, Language, chinese: chinese);
diff --git a/PKHeX.Core/PKM/PK1.cs b/PKHeX.Core/PKM/PK1.cs
index c0d79c62c..924b234c9 100644
--- a/PKHeX.Core/PKM/PK1.cs
+++ b/PKHeX.Core/PKM/PK1.cs
@@ -16,10 +16,12 @@ public sealed class PK1 : _K12
public override int Format => 1;
- public PK1(byte[] decryptedData = null, string ident = null, bool jp = false) : base(decryptedData, ident, jp) { }
+ public PK1(byte[] decryptedData, bool jp = false) : base(decryptedData, jp) { }
+ public PK1(bool jp = false) : base(new byte[PKX.SIZE_1PARTY], jp) { }
- public override PKM Clone() => new PK1((byte[])Data.Clone(), Identifier, Japanese)
+ public override PKM Clone() => new PK1((byte[])Data.Clone(), Japanese)
{
+ Identifier = Identifier,
otname = (byte[])otname.Clone(),
nick = (byte[])nick.Clone(),
};
@@ -109,7 +111,7 @@ private void SetSpeciesValues(int value)
public PK2 ConvertToPK2()
{
- PK2 pk2 = new PK2(null, Identifier, Japanese) {Species = Species};
+ PK2 pk2 = new PK2(null, Japanese) {Species = Species};
Array.Copy(Data, 0x7, pk2.Data, 0x1, 0x1A);
otname.CopyTo(pk2.otname, 0);
nick.CopyTo(pk2.nick, 0);
diff --git a/PKHeX.Core/PKM/PK2.cs b/PKHeX.Core/PKM/PK2.cs
index b08af6834..f8bf91a63 100644
--- a/PKHeX.Core/PKM/PK2.cs
+++ b/PKHeX.Core/PKM/PK2.cs
@@ -15,10 +15,12 @@ public sealed class PK2 : _K12
public override int Format => 2;
- public PK2(byte[] decryptedData = null, string ident = null, bool jp = false) : base(decryptedData, ident, jp) { }
+ public PK2(byte[] decryptedData, bool jp = false) : base(decryptedData, jp) { }
+ public PK2(bool jp = false) : base(new byte[PKX.SIZE_2PARTY], jp) { }
- public override PKM Clone() => new PK2((byte[])Data.Clone(), Identifier, Japanese)
+ public override PKM Clone() => new PK2((byte[])Data.Clone(), Japanese)
{
+ Identifier = Identifier,
otname = (byte[])otname.Clone(),
nick = (byte[])nick.Clone(),
IsEgg = IsEgg,
@@ -96,7 +98,7 @@ public override int Stat_Level
public PK1 ConvertToPK1()
{
- PK1 pk1 = new PK1(null, Identifier, Japanese) {TradebackStatus = TradebackType.WasTradeback};
+ PK1 pk1 = new PK1(Japanese) {TradebackStatus = TradebackType.WasTradeback};
Array.Copy(Data, 0x1, pk1.Data, 0x7, 0x1A);
pk1.Species = Species; // This will take care of Typing :)
diff --git a/PKHeX.Core/PKM/PK3.cs b/PKHeX.Core/PKM/PK3.cs
index dc9428f13..c00990822 100644
--- a/PKHeX.Core/PKM/PK3.cs
+++ b/PKHeX.Core/PKM/PK3.cs
@@ -19,16 +19,15 @@ public sealed class PK3 : _K3
public PK3() => Data = new byte[PKX.SIZE_3PARTY];
- public PK3(byte[] decryptedData, string ident = null)
+ public PK3(byte[] decryptedData)
{
Data = decryptedData;
PKMConverter.CheckEncrypted(ref Data, Format);
- Identifier = ident;
if (Data.Length != SIZE_PARTY)
Array.Resize(ref Data, SIZE_PARTY);
}
- public override PKM Clone() => new PK3((byte[])Data.Clone(), Identifier);
+ public override PKM Clone() => new PK3((byte[])Data.Clone()){Identifier = Identifier};
private string GetString(int Offset, int Count) => StringConverter.GetString3(Data, Offset, Count, Japanese);
private byte[] SetString(string value, int maxLength) => StringConverter.SetString3(value, maxLength, Japanese);
diff --git a/PKHeX.Core/PKM/PK4.cs b/PKHeX.Core/PKM/PK4.cs
index 5e2c29ccb..7e0279d2f 100644
--- a/PKHeX.Core/PKM/PK4.cs
+++ b/PKHeX.Core/PKM/PK4.cs
@@ -20,16 +20,15 @@ public sealed class PK4 : _K4
public PK4() => Data = new byte[PKX.SIZE_4PARTY];
- public PK4(byte[] decryptedData, string ident = null)
+ public PK4(byte[] decryptedData)
{
Data = decryptedData;
PKMConverter.CheckEncrypted(ref Data, Format);
- Identifier = ident;
if (Data.Length != SIZE_PARTY)
Array.Resize(ref Data, SIZE_PARTY);
}
- public override PKM Clone() => new PK4((byte[])Data.Clone(), Identifier);
+ public override PKM Clone() => new PK4((byte[])Data.Clone()){Identifier = Identifier};
private string GetString(int Offset, int Count) => StringConverter.GetString4(Data, Offset, Count);
private byte[] SetString(string value, int maxLength) => StringConverter.SetString4(value, maxLength);
diff --git a/PKHeX.Core/PKM/PK5.cs b/PKHeX.Core/PKM/PK5.cs
index 1ff25a89a..439080147 100644
--- a/PKHeX.Core/PKM/PK5.cs
+++ b/PKHeX.Core/PKM/PK5.cs
@@ -26,16 +26,15 @@ public sealed class PK5 : PKM, IRibbonSetEvent3, IRibbonSetEvent4, IRibbonSetUni
public PK5() => Data = new byte[PKX.SIZE_5PARTY];
- public PK5(byte[] decryptedData, string ident = null)
+ public PK5(byte[] decryptedData)
{
Data = decryptedData;
PKMConverter.CheckEncrypted(ref Data, Format);
- Identifier = ident;
if (Data.Length != SIZE_PARTY)
Array.Resize(ref Data, SIZE_PARTY);
}
- public override PKM Clone() => new PK5((byte[])Data.Clone(), Identifier);
+ public override PKM Clone() => new PK5((byte[])Data.Clone()){Identifier = Identifier};
private string GetString(int Offset, int Count) => StringConverter.GetString5(Data, Offset, Count);
private byte[] SetString(string value, int maxLength) => StringConverter.SetString5(value, maxLength);
diff --git a/PKHeX.Core/PKM/PK6.cs b/PKHeX.Core/PKM/PK6.cs
index b2047a217..84df4a278 100644
--- a/PKHeX.Core/PKM/PK6.cs
+++ b/PKHeX.Core/PKM/PK6.cs
@@ -17,16 +17,15 @@ public sealed class PK6 : _K6, IRibbonSetEvent3, IRibbonSetEvent4, IRibbonSetCom
public PK6() => Data = new byte[PKX.SIZE_6PARTY];
- public PK6(byte[] decryptedData, string ident = null)
+ public PK6(byte[] decryptedData)
{
Data = decryptedData;
PKMConverter.CheckEncrypted(ref Data, Format);
- Identifier = ident;
if (Data.Length != SIZE_PARTY)
Array.Resize(ref Data, SIZE_PARTY);
}
- public override PKM Clone() => new PK6((byte[])Data.Clone(), Identifier);
+ public override PKM Clone() => new PK6((byte[])Data.Clone()){Identifier = Identifier};
private string GetString(int Offset, int Count) => StringConverter.GetString6(Data, Offset, Count);
private byte[] SetString(string value, int maxLength) => StringConverter.SetString6(value, maxLength);
diff --git a/PKHeX.Core/PKM/PK7.cs b/PKHeX.Core/PKM/PK7.cs
index fdf7610f4..ba28190ba 100644
--- a/PKHeX.Core/PKM/PK7.cs
+++ b/PKHeX.Core/PKM/PK7.cs
@@ -18,16 +18,15 @@ public sealed class PK7 : _K6, IRibbonSetEvent3, IRibbonSetEvent4, IRibbonSetCom
public PK7() => Data = new byte[PKX.SIZE_6PARTY];
- public PK7(byte[] decryptedData, string ident = null)
+ public PK7(byte[] decryptedData)
{
Data = decryptedData;
PKMConverter.CheckEncrypted(ref Data, Format);
- Identifier = ident;
if (Data.Length != SIZE_PARTY)
Array.Resize(ref Data, SIZE_PARTY);
}
- public override PKM Clone() => new PK7((byte[])Data.Clone(), Identifier);
+ public override PKM Clone() => new PK7((byte[])Data.Clone()){Identifier = Identifier};
private string GetString(int Offset, int Count) => StringConverter.GetString7(Data, Offset, Count);
private byte[] SetString(string value, int maxLength, bool chinese = false) => StringConverter.SetString7(value, maxLength, Language, chinese: chinese);
diff --git a/PKHeX.Core/PKM/Shared/_K12.cs b/PKHeX.Core/PKM/Shared/_K12.cs
index f9fd937e3..f71f35756 100644
--- a/PKHeX.Core/PKM/Shared/_K12.cs
+++ b/PKHeX.Core/PKM/Shared/_K12.cs
@@ -31,11 +31,10 @@ public override string FileNameWithoutExtension
private int StringLength => Japanese ? STRLEN_J : STRLEN_U;
public override bool Japanese => otname.Length == STRLEN_J;
- protected _K12(byte[] decryptedData, string ident = null, bool jp = false)
+ protected _K12(byte[] decryptedData, bool jp = false)
{
int partySize = SIZE_PARTY;
- Data = decryptedData ?? new byte[partySize];
- Identifier = ident;
+ Data = decryptedData;
if (Data.Length != partySize)
Array.Resize(ref Data, partySize);
int strLen = jp ? STRLEN_J : STRLEN_U;
diff --git a/PKHeX.Core/PKM/Util/PKMConverter.cs b/PKHeX.Core/PKM/Util/PKMConverter.cs
index a8227c35a..3b9b3824d 100644
--- a/PKHeX.Core/PKM/Util/PKMConverter.cs
+++ b/PKHeX.Core/PKM/Util/PKMConverter.cs
@@ -80,40 +80,36 @@ public static int GetPKMDataFormat(byte[] data)
/// Optional identifier for the Pokemon. Usually the full path of the source file.
/// Optional identifier for the preferred generation. Usually the generation of the destination save file.
/// An instance of created from the given , or null if is invalid.
- public static PKM GetPKMfromBytes(byte[] data, string ident = null, int prefer = 7)
+ public static PKM GetPKMfromBytes(byte[] data, int prefer = 7)
{
int format = GetPKMDataFormat(data);
switch (format)
{
case 1:
var PL1 = new PokeList1(data);
- if (ident != null)
- PL1[0].Identifier = ident;
return PL1[0];
case 2:
var PL2 = new PokeList2(data);
- if (ident != null)
- PL2[0].Identifier = ident;
return PL2[0];
case 3:
switch (data.Length) {
- case PKX.SIZE_3CSTORED: return new CK3(data, ident);
- case PKX.SIZE_3XSTORED: return new XK3(data, ident);
- default: return new PK3(data, ident);
+ case PKX.SIZE_3CSTORED: return new CK3(data);
+ case PKX.SIZE_3XSTORED: return new XK3(data);
+ default: return new PK3(data);
}
case 4:
- var pk = new PK4(data, ident);
+ var pk = new PK4(data);
if (!pk.Valid || pk.Sanity != 0)
{
- var bk = new BK4(data, ident);
+ var bk = new BK4(data);
if (bk.Valid)
return bk;
}
return pk;
case 5:
- return new PK5(data, ident);
+ return new PK5(data);
case 6:
- var pkx = new PK6(data, ident);
+ var pkx = new PK6(data);
return CheckPKMFormat7(pkx, prefer);
default:
return null;
@@ -130,7 +126,7 @@ private static PKM CheckPKMFormat7(PK6 pk, int prefer)
{
if (GameVersion.GG.Contains(pk.Version))
return new PB7(pk.Data);
- return IsPK6FormatReallyPK7(pk, prefer) ? new PK7(pk.Data, pk.Identifier) : (PKM)pk;
+ return IsPK6FormatReallyPK7(pk, prefer) ? new PK7(pk.Data) : (PKM)pk;
}
///
diff --git a/PKHeX.Core/PKM/XK3.cs b/PKHeX.Core/PKM/XK3.cs
index 6cde68402..ab407350c 100644
--- a/PKHeX.Core/PKM/XK3.cs
+++ b/PKHeX.Core/PKM/XK3.cs
@@ -20,14 +20,9 @@ public sealed class XK3 : _K3, IShadowPKM
public override int Format => 3;
public override PersonalInfo PersonalInfo => PersonalTable.RS[Species];
- public XK3(byte[] decryptedData, string ident = null)
- {
- Data = decryptedData;
- Identifier = ident;
- }
-
+ public XK3(byte[] decryptedData) => Data = decryptedData;
public XK3() => Data = new byte[SIZE_PARTY];
- public override PKM Clone() => new XK3((byte[])Data.Clone(), Identifier) {Purification = Purification};
+ public override PKM Clone() => new XK3((byte[])Data.Clone()){Identifier = Identifier, Purification = Purification};
private string GetString(int Offset, int Count) => StringConverter.GetBEString3(Data, Offset, Count);
private byte[] SetString(string value, int maxLength) => StringConverter.SetBEString3(value, maxLength);
diff --git a/PKHeX.Core/Saves/SAV1.cs b/PKHeX.Core/Saves/SAV1.cs
index 7751f5c3b..ced4653f6 100644
--- a/PKHeX.Core/Saves/SAV1.cs
+++ b/PKHeX.Core/Saves/SAV1.cs
@@ -180,7 +180,7 @@ private int GetBoxRawDataOffset(int i)
private int SIZE_STOREDBOX => PokeList1.GetDataLength(Japanese ? PokeListType.StoredJP : PokeListType.Stored, Japanese);
private int SIZE_STOREDPARTY => PokeList1.GetDataLength(PokeListType.Party, Japanese);
- public override PKM BlankPKM => new PK1(null, null, Japanese);
+ public override PKM BlankPKM => new PK1(Japanese);
public override Type PKMType => typeof(PK1);
public override int MaxMoveID => Legal.MaxMoveID_1;
diff --git a/PKHeX.Core/Saves/Substructures/Battle Videos/BV6.cs b/PKHeX.Core/Saves/Substructures/Battle Videos/BV6.cs
index 2678b4666..615b31ca1 100644
--- a/PKHeX.Core/Saves/Substructures/Battle Videos/BV6.cs
+++ b/PKHeX.Core/Saves/Substructures/Battle Videos/BV6.cs
@@ -92,7 +92,7 @@ public PKM[][] PlayerTeams
{
int offset = start + (PKX.SIZE_6PARTY*((t * 6) + p));
offset += 8*(((t * 6) + p)/6); // 8 bytes padding between teams
- Teams[t][p] = new PK6(Data.Skip(offset).Take(PKX.SIZE_6PARTY).ToArray(), $"Team {t}, Slot {p}");
+ Teams[t][p] = new PK6(Data.Skip(offset).Take(PKX.SIZE_6PARTY).ToArray()) {Identifier = $"Team {t}, Slot {p}"};
}
}
return Teams;
diff --git a/PKHeX.Core/Saves/Substructures/Battle Videos/BV7.cs b/PKHeX.Core/Saves/Substructures/Battle Videos/BV7.cs
index d036bc74c..d5de62e74 100644
--- a/PKHeX.Core/Saves/Substructures/Battle Videos/BV7.cs
+++ b/PKHeX.Core/Saves/Substructures/Battle Videos/BV7.cs
@@ -34,7 +34,7 @@ private PKM[][] PlayerTeams
for (int p = 0; p < 6; p++)
{
int offset = offsets[t] + (PKX.SIZE_6PARTY * p);
- Teams[t][p] = new PK7(Data.Skip(offset).Take(PKX.SIZE_6STORED).ToArray(), $"Team {t}, Slot {p}");
+ Teams[t][p] = new PK7(Data.Skip(offset).Take(PKX.SIZE_6STORED).ToArray()) {Identifier = $"Team {t}, Slot {p}"};
}
}
return Teams;
diff --git a/PKHeX.WinForms/Subforms/SAV_Database.cs b/PKHeX.WinForms/Subforms/SAV_Database.cs
index d7099cdb4..c6f4991dc 100644
--- a/PKHeX.WinForms/Subforms/SAV_Database.cs
+++ b/PKHeX.WinForms/Subforms/SAV_Database.cs
@@ -344,13 +344,15 @@ private static List LoadPKMSaves(string pkmdb, string savdb, string EXTERNA
var extensions = new HashSet(PKM.Extensions.Select(z => $".{z}"));
Parallel.ForEach(files, file =>
{
- FileInfo fi = new FileInfo(file);
+ var fi = new FileInfo(file);
if (!extensions.Contains(fi.Extension) || !PKX.IsPKM(fi.Length)) return;
var data = File.ReadAllBytes(file);
var prefer = PKX.GetPKMFormatFromExtension(fi.Extension, SAV.Generation);
- var pk = PKMConverter.GetPKMfromBytes(data, file, prefer);
- if (pk?.Species > 0)
- dbTemp.Add(pk);
+ var pk = PKMConverter.GetPKMfromBytes(data, prefer);
+ if (!(pk?.Species > 0))
+ return;
+ pk.Identifier = file;
+ dbTemp.Add(pk);
});
#if LOADALL