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
This commit is contained in:
Kurt
2019-08-23 18:03:10 -07:00
parent bf6c25eca7
commit f0df115ccd
2 changed files with 5 additions and 2 deletions

View File

@@ -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;
}

View File

@@ -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
}
}