mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-27 06:20:25 +00:00
Use min parameter count
PK2 doesn't like getting passed null for the byte[] parameter (rightly so); don't depend on the src code order having the first constructor being the one with the least arguments fix it in pk1/2 so that the first constructor has the least args, anyway
This commit is contained in:
parent
8a08d32dff
commit
99baca5f5e
3 changed files with 3 additions and 3 deletions
|
@ -16,8 +16,8 @@ namespace PKHeX.Core
|
|||
|
||||
public override int Format => 1;
|
||||
|
||||
public PK1(byte[] decryptedData, bool jp = false) : base(decryptedData, jp) { }
|
||||
public PK1(bool jp = false) : base(new byte[PKX.SIZE_1PARTY], jp) { }
|
||||
public PK1(byte[] decryptedData, bool jp = false) : base(decryptedData, jp) { }
|
||||
|
||||
public override PKM Clone() => new PK1((byte[])Data.Clone(), Japanese)
|
||||
{
|
||||
|
|
|
@ -15,8 +15,8 @@ namespace PKHeX.Core
|
|||
|
||||
public override int Format => 2;
|
||||
|
||||
public PK2(byte[] decryptedData, bool jp = false) : base(decryptedData, jp) { }
|
||||
public PK2(bool jp = false) : base(new byte[PKX.SIZE_2PARTY], jp) { }
|
||||
public PK2(byte[] decryptedData, bool jp = false) : base(decryptedData, jp) { }
|
||||
|
||||
public override PKM Clone() => new PK2((byte[])Data.Clone(), Japanese)
|
||||
{
|
||||
|
|
|
@ -445,7 +445,7 @@ namespace PKHeX.Core
|
|||
public static PKM GetBlank(Type t)
|
||||
{
|
||||
var constructors = t.GetTypeInfo().DeclaredConstructors.Where(z => !z.IsStatic);
|
||||
var argCount = constructors.First().GetParameters().Length;
|
||||
var argCount = constructors.Min(z => z.GetParameters().Length);
|
||||
return (PKM)Activator.CreateInstance(t, new object[argCount]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue