mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-08-28 11:15:01 -05:00
Fix clearing of clones (off by 1 last box)
Clamp end box in the clear/modify actions too, just in case.
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
namespace PKHeX.Core;
|
||||
namespace PKHeX.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Criteria for manipulating box data.
|
||||
/// </summary>
|
||||
/// <param name="Start">Box to start at (inclusive)</param>
|
||||
/// <param name="Stop">Box to stop at (exclusive)</param>
|
||||
/// <param name="Stop">Box to stop after (inclusive)</param>
|
||||
/// <param name="Reverse">Iterate in reverse</param>
|
||||
public readonly record struct BoxManipParam(int Start, int Stop, bool Reverse = false);
|
||||
|
||||
@@ -741,7 +741,7 @@ public int ClearBoxes(int BoxStart = 0, int BoxEnd = -1, Func<PKM, bool>? 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<PKM, bool>? delete
|
||||
/// <returns>Count of modified <see cref="PKM"/> slots.</returns>
|
||||
public int ModifyBoxes(Action<PKM> action, int BoxStart = 0, int BoxEnd = -1)
|
||||
{
|
||||
if (BoxEnd < 0)
|
||||
if ((uint)BoxEnd >= BoxCount)
|
||||
BoxEnd = BoxCount - 1;
|
||||
|
||||
var storage = BoxBuffer.AsSpan();
|
||||
|
||||
@@ -681,7 +681,7 @@ private void Menu_DeleteClones_Click(object sender, EventArgs e)
|
||||
}
|
||||
|
||||
var boxClear = new BoxManipClearDuplicate<string>(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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user