From 5ede6feb38127d4bf0dec06e007c8ad07b7b59d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20H=2E=20Attard?= Date: Mon, 13 Nov 2023 04:05:55 -0300 Subject: [PATCH] SAV1 can implement IEventWorkArray (#4061) --- PKHeX.Core/Saves/SAV1.cs | 7 ++++++- PKHeX.Core/Saves/Substructures/Gen12/SAV1Offsets.cs | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/PKHeX.Core/Saves/SAV1.cs b/PKHeX.Core/Saves/SAV1.cs index f247fde47..0854395b2 100644 --- a/PKHeX.Core/Saves/SAV1.cs +++ b/PKHeX.Core/Saves/SAV1.cs @@ -7,7 +7,7 @@ namespace PKHeX.Core; /// /// Generation 1 object. /// -public sealed class SAV1 : SaveFile, ILangDeviantSave, IEventFlagArray +public sealed class SAV1 : SaveFile, ILangDeviantSave, IEventFlagArray, IEventWorkArray { protected internal override string ShortSummary => $"{OT} ({Version}) - {PlayTimeString}"; public override string Extension => ".sav"; @@ -164,6 +164,11 @@ public void SetEventFlag(int flagNumber, bool value) SetFlag(Offsets.EventFlag + (flagNumber >> 3), flagNumber & 7, value); } + // Event Work + public int EventWorkCount => 0x100; + public byte GetWork(int index) => Data[Offsets.EventWork + index]; + public void SetWork(int index, byte value) => Data[Offsets.EventWork + index] = value; + protected override byte[] GetFinalData() { var capacity = Japanese ? PokeListType.StoredJP : PokeListType.Stored; diff --git a/PKHeX.Core/Saves/Substructures/Gen12/SAV1Offsets.cs b/PKHeX.Core/Saves/Substructures/Gen12/SAV1Offsets.cs index db7c347d8..7b4764c1e 100644 --- a/PKHeX.Core/Saves/Substructures/Gen12/SAV1Offsets.cs +++ b/PKHeX.Core/Saves/Substructures/Gen12/SAV1Offsets.cs @@ -22,6 +22,7 @@ private static SAV1Offsets GetINT() => new() CurrentBoxIndex = 0x284C, Coin = 0x2850, ObjectSpawnFlags = 0x2852, // 2 bytes after Coin + EventWork = 0x289C, Starter = 0x29C3, EventFlag = 0x29F3, PlayTime = 0x2CED, @@ -48,6 +49,7 @@ private static SAV1Offsets GetJPN() => new() CurrentBoxIndex = 0x2842, Coin = 0x2846, ObjectSpawnFlags = 0x2848, // 2 bytes after Coin + EventWork = 0x2892, Starter = 0x29B9, EventFlag = 0x29E9, PlayTime = 0x2CA0, @@ -75,6 +77,7 @@ private static SAV1Offsets GetJPN() => new() public int ObjectSpawnFlags { get; private init; } public int Starter { get; private init; } public int EventFlag { get; private init; } + public int EventWork { get; private init; } public int PlayTime { get; private init; } public int Daycare { get; private init; } public int Party { get; private init; }