mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-10 14:44:24 +00:00
PK5: Clear party stats on import
Add property get/set for the undocumented fields
This commit is contained in:
parent
69794e7328
commit
bc054c09ed
4 changed files with 11 additions and 9 deletions
|
@ -272,8 +272,8 @@ namespace PKHeX.Core
|
|||
public override int Stat_SPA { get => ReadUInt16LittleEndian(Data.AsSpan(0x98)); set => WriteUInt16LittleEndian(Data.AsSpan(0x98), (ushort)value); }
|
||||
public override int Stat_SPD { get => ReadUInt16LittleEndian(Data.AsSpan(0x9A)); set => WriteUInt16LittleEndian(Data.AsSpan(0x9A), (ushort)value); }
|
||||
|
||||
public Span<byte> HeldMail => Data.Slice(0x9C, 0x38);
|
||||
public Span<byte> Seals => Data.Slice(0xD4, 0x18);
|
||||
public Span<byte> HeldMail => Data.AsSpan(0x9C, 0x38);
|
||||
public Span<byte> Seals => Data.AsSpan(0xD4, 0x18);
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -305,12 +305,14 @@ namespace PKHeX.Core
|
|||
|
||||
DateTime moment = DateTime.Now;
|
||||
|
||||
PK5 pk5 = new((byte[])Data.Clone()) // Convert away!
|
||||
PK5 pk5 = new(Data.AsSpan(0, PokeCrypto.SIZE_5PARTY).ToArray()) // Convert away!
|
||||
{
|
||||
JunkByte = 0,
|
||||
OT_Friendship = 70,
|
||||
// Apply new met date
|
||||
MetDate = moment,
|
||||
};
|
||||
pk5.HeldMail.Clear();
|
||||
|
||||
// Arceus Type Changing -- Plate forcibly removed.
|
||||
if (pk5.Species == (int)Core.Species.Arceus)
|
||||
|
|
|
@ -255,6 +255,7 @@ namespace PKHeX.Core
|
|||
#region Battle Stats
|
||||
public override int Status_Condition { get => ReadInt32LittleEndian(Data.AsSpan(0x88)); set => WriteInt32LittleEndian(Data.AsSpan(0x88), value); }
|
||||
public override int Stat_Level { get => Data[0x8C]; set => Data[0x8C] = (byte)value; }
|
||||
public byte JunkByte { get => Data[0x8D]; set => Data[0x8D] = value; }
|
||||
public override int Stat_HPCurrent { get => ReadUInt16LittleEndian(Data.AsSpan(0x8E)); set => WriteUInt16LittleEndian(Data.AsSpan(0x8E), (ushort)value); }
|
||||
public override int Stat_HPMax { get => ReadUInt16LittleEndian(Data.AsSpan(0x90)); set => WriteUInt16LittleEndian(Data.AsSpan(0x90), (ushort)value); }
|
||||
public override int Stat_ATK { get => ReadUInt16LittleEndian(Data.AsSpan(0x92)); set => WriteUInt16LittleEndian(Data.AsSpan(0x92), (ushort)value); }
|
||||
|
@ -263,9 +264,8 @@ namespace PKHeX.Core
|
|||
public override int Stat_SPA { get => ReadUInt16LittleEndian(Data.AsSpan(0x98)); set => WriteUInt16LittleEndian(Data.AsSpan(0x98), (ushort)value); }
|
||||
public override int Stat_SPD { get => ReadUInt16LittleEndian(Data.AsSpan(0x9A)); set => WriteUInt16LittleEndian(Data.AsSpan(0x9A), (ushort)value); }
|
||||
|
||||
public byte[] GetHeldMailData() => Data.Slice(0x9C, 0x38);
|
||||
public void SetHeldMailData(byte[] value) => value.CopyTo(Data, 0x9C);
|
||||
public void ClearHeldMailData() => Array.Clear(Data, 0x9C, 0x38);
|
||||
public Span<byte> HeldMail => Data.AsSpan(0x9C, 0x38);
|
||||
public ulong JunkData { get => ReadUInt64LittleEndian(Data.AsSpan(0xD4, 8)); set => WriteUInt64LittleEndian(Data.AsSpan(0xD4, 8), value); }
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace PKHeX.Core
|
|||
}
|
||||
}
|
||||
|
||||
public override void CopyTo(PK5 pk5) => pk5.SetHeldMailData(Data);
|
||||
public override void CopyTo(PK5 pk5) => Data.CopyTo(pk5.HeldMail);
|
||||
public override ushort AuthorTID { get => ReadUInt16LittleEndian(Data.AsSpan(0)); set => WriteUInt16LittleEndian(Data.AsSpan(0), value); }
|
||||
public override ushort AuthorSID { get => ReadUInt16LittleEndian(Data.AsSpan(2)); set => WriteUInt16LittleEndian(Data.AsSpan(2), value); }
|
||||
public override byte AuthorGender { get => Data[4]; set => Data[4] = value; }
|
||||
|
|
|
@ -76,7 +76,7 @@ namespace PKHeX.WinForms
|
|||
case SAV4 sav4:
|
||||
m = new Mail4[p.Count + 20];
|
||||
for (int i = 0; i < p.Count; i++)
|
||||
m[i] = new Mail4(((PK4)p[i]).GetHeldMailData());
|
||||
m[i] = new Mail4(((PK4)p[i]).HeldMail.ToArray());
|
||||
for (int i = p.Count, j = 0; i < m.Length; i++, j++)
|
||||
m[i] = sav4.GetMail(j);
|
||||
var l4 = (Mail4)m[^1];
|
||||
|
@ -88,7 +88,7 @@ namespace PKHeX.WinForms
|
|||
case SAV5 sav5:
|
||||
m = new Mail5[p.Count + 20];
|
||||
for (int i = 0; i < p.Count; i++)
|
||||
m[i] = new Mail5(((PK5)p[i]).GetHeldMailData());
|
||||
m[i] = new Mail5(((PK5)p[i]).HeldMail.ToArray());
|
||||
for (int i = p.Count, j = 0; i < m.Length; i++, j++)
|
||||
m[i] = sav5.GetMail(j);
|
||||
var l5 = (Mail5)m[^1];
|
||||
|
|
Loading…
Reference in a new issue