diff --git a/PKHeX.Core/Saves/SAV1.cs b/PKHeX.Core/Saves/SAV1.cs index 31bfdb3fb..f31f31f8e 100644 --- a/PKHeX.Core/Saves/SAV1.cs +++ b/PKHeX.Core/Saves/SAV1.cs @@ -255,6 +255,14 @@ public override int TID public override int SID { get => 0; set { } } + public string Rival + { + get => GetString(Offsets.Rival, OTLength); + set => SetString(value, OTLength).CopyTo(Data, Offsets.Rival); + } + + public Span Rival_Trash { get => Data.AsSpan(Offsets.Rival, StringLength); set { if (value.Length == StringLength) value.CopyTo(Data.AsSpan(Offsets.Rival)); } } + public bool Yellow => Starter == 0x54; // Pikachu public int Starter => Data[Offsets.Starter]; diff --git a/PKHeX.Core/Saves/SAV2.cs b/PKHeX.Core/Saves/SAV2.cs index 579318502..0eab36131 100644 --- a/PKHeX.Core/Saves/SAV2.cs +++ b/PKHeX.Core/Saves/SAV2.cs @@ -326,6 +326,18 @@ public Span OT_Trash set { if (value.Length == StringLength) value.CopyTo(Data.AsSpan(Offsets.Trainer1 + 2)); } } + public string Rival + { + get => GetString(Offsets.Rival, (Korean ? 2 : 1) * OTLength); + set => SetString(value, (Korean ? 2 : 1) * OTLength).CopyTo(Data, Offsets.Rival); + } + + public Span Rival_Trash + { + get => Data.AsSpan(Offsets.Rival, StringLength); + set { if (value.Length == StringLength) value.CopyTo(Data.AsSpan(Offsets.Rival)); } + } + public override int Gender { get => Version == GameVersion.C ? Data[Offsets.Gender] : 0; diff --git a/PKHeX.Core/Saves/SAV4.cs b/PKHeX.Core/Saves/SAV4.cs index 9618ba7ac..7aedfef79 100644 --- a/PKHeX.Core/Saves/SAV4.cs +++ b/PKHeX.Core/Saves/SAV4.cs @@ -232,6 +232,9 @@ public override int PlayedSeconds public abstract int X { get; set; } public abstract int Y { get; set; } + public abstract string Rival { get; set; } + public abstract Span Rival_Trash { get; set; } + public abstract int X2 { get; set; } public abstract int Y2 { get; set; } public abstract int Z { get; set; } diff --git a/PKHeX.Core/Saves/SAV4DP.cs b/PKHeX.Core/Saves/SAV4DP.cs index 15f837a33..f261d6e92 100644 --- a/PKHeX.Core/Saves/SAV4DP.cs +++ b/PKHeX.Core/Saves/SAV4DP.cs @@ -145,6 +145,19 @@ private void SetActiveGiftFlags(IReadOnlyList gifts) public override int M { get => BitConverter.ToUInt16(General, 0x1238); set => BitConverter.GetBytes((ushort)value).CopyTo(General, 0x1238); } public override int X { get => BitConverter.ToUInt16(General, 0x1240); set => BitConverter.GetBytes((ushort)(X2 = value)).CopyTo(General, 0x1240); } public override int Y { get => BitConverter.ToUInt16(General, 0x1244); set => BitConverter.GetBytes((ushort)(Y2 = value)).CopyTo(General, 0x1244); } + + public override string Rival + { + get => GetString(0x25A8, OTLength); + set => SetString(value, OTLength).CopyTo(Data, 0x25A8); + } + + public override Span Rival_Trash + { + get => Data.AsSpan(0x25A8, OTLength); + set { if (value.Length == OTLength) value.CopyTo(Data.AsSpan(0x25A8)); } + } + public override int X2 { get => BitConverter.ToUInt16(General, 0x25FA); set => BitConverter.GetBytes((ushort)value).CopyTo(General, 0x25FA); } public override int Y2 { get => BitConverter.ToUInt16(General, 0x25FE); set => BitConverter.GetBytes((ushort)value).CopyTo(General, 0x25FE); } public override int Z { get => BitConverter.ToUInt16(General, 0x2602); set => BitConverter.GetBytes((ushort)value).CopyTo(General, 0x2602); } diff --git a/PKHeX.Core/Saves/SAV4HGSS.cs b/PKHeX.Core/Saves/SAV4HGSS.cs index 413a9118c..3086ca483 100644 --- a/PKHeX.Core/Saves/SAV4HGSS.cs +++ b/PKHeX.Core/Saves/SAV4HGSS.cs @@ -154,6 +154,19 @@ public override IReadOnlyList Inventory public override int M { get => BitConverter.ToUInt16(General, 0x1234); set => BitConverter.GetBytes((ushort)value).CopyTo(General, 0x1234); } public override int X { get => BitConverter.ToUInt16(General, 0x123C); set => BitConverter.GetBytes((ushort)(X2 = value)).CopyTo(General, 0x123C); } public override int Y { get => BitConverter.ToUInt16(General, 0x1240); set => BitConverter.GetBytes((ushort)(Y2 = value)).CopyTo(General, 0x1240); } + + public override string Rival + { + get => GetString(0x22D4, OTLength); + set => SetString(value, OTLength).CopyTo(Data, 0x22D4); + } + + public override Span Rival_Trash + { + get => Data.AsSpan(0x22D4, OTLength); + set { if (value.Length == OTLength) value.CopyTo(Data.AsSpan(0x22D4)); } + } + public override int X2 { get => BitConverter.ToUInt16(General, 0x236E); set => BitConverter.GetBytes((ushort)value).CopyTo(General, 0x236E); } public override int Y2 { get => BitConverter.ToUInt16(General, 0x2372); set => BitConverter.GetBytes((ushort)value).CopyTo(General, 0x2372); } public override int Z { get => BitConverter.ToUInt16(General, 0x2376); set => BitConverter.GetBytes((ushort)value).CopyTo(General, 0x2376); } diff --git a/PKHeX.Core/Saves/SAV4Pt.cs b/PKHeX.Core/Saves/SAV4Pt.cs index 475454dbd..2138fb720 100644 --- a/PKHeX.Core/Saves/SAV4Pt.cs +++ b/PKHeX.Core/Saves/SAV4Pt.cs @@ -111,6 +111,19 @@ public override IReadOnlyList Inventory public override int M { get => BitConverter.ToUInt16(General, 0x1280); set => BitConverter.GetBytes((ushort)value).CopyTo(General, 0x1280); } public override int X { get => BitConverter.ToUInt16(General, 0x1288); set => BitConverter.GetBytes((ushort)(X2 = value)).CopyTo(General, 0x1288); } public override int Y { get => BitConverter.ToUInt16(General, 0x128C); set => BitConverter.GetBytes((ushort)(Y2 = value)).CopyTo(General, 0x128C); } + + public override string Rival + { + get => GetString(0x27E8, OTLength); + set => SetString(value, OTLength).CopyTo(Data, 0x27E8); + } + + public override Span Rival_Trash + { + get => Data.AsSpan(0x27E8, OTLength); + set { if (value.Length == OTLength) value.CopyTo(Data.AsSpan(0x27E8)); } + } + public override int X2 { get => BitConverter.ToUInt16(General, 0x287E); set => BitConverter.GetBytes((ushort)value).CopyTo(General, 0x287E); } public override int Y2 { get => BitConverter.ToUInt16(General, 0x2882); set => BitConverter.GetBytes((ushort)value).CopyTo(General, 0x2882); } public override int Z { get => BitConverter.ToUInt16(General, 0x2886); set => BitConverter.GetBytes((ushort)value).CopyTo(General, 0x2886); } diff --git a/PKHeX.Core/Saves/SAV5B2W2.cs b/PKHeX.Core/Saves/SAV5B2W2.cs index 7e7f04eb4..1c3ac913c 100644 --- a/PKHeX.Core/Saves/SAV5B2W2.cs +++ b/PKHeX.Core/Saves/SAV5B2W2.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; namespace PKHeX.Core { @@ -56,5 +57,17 @@ private void Initialize() public PWTBlock5 PWT => Blocks.PWT; public override int Fused => 0x1FA00 + sizeof(uint); public override int GTS => 0x20400; + + public string Rival + { + get => GetString(0x23BA4, OTLength); + set => SetString(value, OTLength).CopyTo(Data, 0x23BA4); + } + + public Span Rival_Trash + { + get => Data.AsSpan(0x23BA4, OTLength); + set { if (value.Length == OTLength) value.CopyTo(Data.AsSpan(0x23BA4)); } + } } } diff --git a/PKHeX.Core/Saves/Substructures/Gen12/SAV1Offsets.cs b/PKHeX.Core/Saves/Substructures/Gen12/SAV1Offsets.cs index 92ea2ac94..c446248a8 100644 --- a/PKHeX.Core/Saves/Substructures/Gen12/SAV1Offsets.cs +++ b/PKHeX.Core/Saves/Substructures/Gen12/SAV1Offsets.cs @@ -11,6 +11,7 @@ private static SAV1Offsets GetINT() => new() DexSeen = 0x25B6, Items = 0x25C9, Money = 0x25F3, + Rival = 0x25F6, Options = 0x2601, Badges = 0x2602, TID = 0x2605, @@ -36,6 +37,7 @@ private static SAV1Offsets GetJPN() => new() DexSeen = 0x25B1, Items = 0x25C4, Money = 0x25EE, + Rival = 0x25F1, Options = 0x25F7, Badges = 0x25F8, TID = 0x25FB, @@ -60,6 +62,7 @@ private static SAV1Offsets GetJPN() => new() public int DexSeen { get; private init; } public int Items { get; private init; } public int Money { get; private init; } + public int Rival { get; private init; } public int Options { get; private init; } public int Badges { get; private init; } public int TID { get; private init; } diff --git a/PKHeX.Core/Saves/Substructures/Gen12/SAV2Offsets.cs b/PKHeX.Core/Saves/Substructures/Gen12/SAV2Offsets.cs index fcc0da52d..d8ff72aa7 100644 --- a/PKHeX.Core/Saves/Substructures/Gen12/SAV2Offsets.cs +++ b/PKHeX.Core/Saves/Substructures/Gen12/SAV2Offsets.cs @@ -23,6 +23,7 @@ public SAV2Offsets(SAV2 sav) public int Options { get; } public int Trainer1 { get; } + public int Rival { get; private set; } public int DaylightSavings { get; private set; } = -1; public int TimePlayed { get; private set; } = -1; @@ -55,6 +56,7 @@ private void LoadOffsetsInternational(GameVersion version) { RTCFlags = 0x0C60; + Rival = 0x2021; DaylightSavings = 0x2042; OtherCurrentBox = 0x284C; switch (version) @@ -116,6 +118,7 @@ private void LoadOffsetsInternational(GameVersion version) private void LoadOffsetsJapanese(GameVersion version) { + Rival = 0x2017; DaylightSavings = 0x2029; TimePlayed = 0x2034; Palette = 0x204C; @@ -184,6 +187,7 @@ private void LoadOffsetsKorean() RTCFlags = 0x1060; // No Crystal Version + Rival = 0x2021; DaylightSavings = 0x2042; OtherCurrentBox = 0x284C;