diff --git a/PKHeX.Core/Editing/Saves/BoxManip/BoxManipParam.cs b/PKHeX.Core/Editing/Saves/BoxManip/BoxManipParam.cs index 8f58f8136..7af44c6c5 100644 --- a/PKHeX.Core/Editing/Saves/BoxManip/BoxManipParam.cs +++ b/PKHeX.Core/Editing/Saves/BoxManip/BoxManipParam.cs @@ -1,9 +1,9 @@ -namespace PKHeX.Core; +namespace PKHeX.Core; /// /// Criteria for manipulating box data. /// /// Box to start at (inclusive) -/// Box to stop at (exclusive) +/// Box to stop after (inclusive) /// Iterate in reverse public readonly record struct BoxManipParam(int Start, int Stop, bool Reverse = false); diff --git a/PKHeX.Core/Saves/SaveFile.cs b/PKHeX.Core/Saves/SaveFile.cs index 9ff0962d1..f86e77530 100644 --- a/PKHeX.Core/Saves/SaveFile.cs +++ b/PKHeX.Core/Saves/SaveFile.cs @@ -741,7 +741,7 @@ public int ClearBoxes(int BoxStart = 0, int BoxEnd = -1, Func? delete { var storage = BoxBuffer.AsSpan(); - if (BoxEnd < 0) + if ((uint)BoxEnd >= BoxCount) BoxEnd = BoxCount - 1; var blank = GetDataForBox(BlankPKM); @@ -778,7 +778,7 @@ public int ClearBoxes(int BoxStart = 0, int BoxEnd = -1, Func? delete /// Count of modified slots. public int ModifyBoxes(Action action, int BoxStart = 0, int BoxEnd = -1) { - if (BoxEnd < 0) + if ((uint)BoxEnd >= BoxCount) BoxEnd = BoxCount - 1; var storage = BoxBuffer.AsSpan(); diff --git a/PKHeX.WinForms/Subforms/SAV_Database.cs b/PKHeX.WinForms/Subforms/SAV_Database.cs index b43955fba..25f906391 100644 --- a/PKHeX.WinForms/Subforms/SAV_Database.cs +++ b/PKHeX.WinForms/Subforms/SAV_Database.cs @@ -681,7 +681,7 @@ private void Menu_DeleteClones_Click(object sender, EventArgs e) } var boxClear = new BoxManipClearDuplicate(BoxManipType.DeleteClones, pk => SearchUtil.GetCloneDetectMethod(method)(pk)); - var param = new BoxManipParam(0, SAV.BoxCount); + var param = new BoxManipParam(0, SAV.BoxCount - 1); int count = boxClear.Execute(SAV, param); deleted += count;