From f0df115ccd2d08e52144960a88b0abaebbd31a6a Mon Sep 17 00:00:00 2001 From: Kurt Date: Fri, 23 Aug 2019 18:03:10 -0700 Subject: [PATCH] Fix box load on uninitialized box load Closes #2376 probably will be rewritten at a later time; am reworking the slot info messaging for drag/drop/display --- PKHeX.Core/Saves/SAV4.cs | 2 +- PKHeX.WinForms/Controls/SAV Editor/BoxEditor.cs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/PKHeX.Core/Saves/SAV4.cs b/PKHeX.Core/Saves/SAV4.cs index 07510afed..9b56ea99c 100644 --- a/PKHeX.Core/Saves/SAV4.cs +++ b/PKHeX.Core/Saves/SAV4.cs @@ -579,7 +579,7 @@ public int Y // Storage public override int CurrentBox { - get => Data[Version == GameVersion.HGSS ? GetBoxOffset(BoxCount) : Box - 4]; + get => (sbyte)Data[Version == GameVersion.HGSS ? GetBoxOffset(BoxCount) : Box - 4]; set => Data[Version == GameVersion.HGSS ? GetBoxOffset(BoxCount) : Box - 4] = (byte)value; } diff --git a/PKHeX.WinForms/Controls/SAV Editor/BoxEditor.cs b/PKHeX.WinForms/Controls/SAV Editor/BoxEditor.cs index b57aecd65..35eb2a8fb 100644 --- a/PKHeX.WinForms/Controls/SAV Editor/BoxEditor.cs +++ b/PKHeX.WinForms/Controls/SAV Editor/BoxEditor.cs @@ -257,7 +257,10 @@ private void GetBox(object sender, EventArgs e) public void InitializeFromSAV(SaveFile sav) { Editor = new BoxEdit(sav); - Editor.LoadBox(sav.CurrentBox); + int box = sav.CurrentBox; + if ((uint)box >= sav.BoxCount) + box = 0; + Editor.LoadBox(box); ResetBoxNames(); // Display the Box Names } }