mirror of
https://github.com/kwsch/PKHeX
synced 2025-02-17 05:48:44 +00:00
Rework & fix party slot deletion
Two birds with one stone: - sav4 doesn't use Data (instead uses General/Storage), so we need to use the abstracted method calls instead of trying to do things manually. - setting a blank pkm at a party slot will decrease the party count! don't decrease things twice.
This commit is contained in:
parent
c3a6fd2a64
commit
3b0fd81aae
1 changed files with 7 additions and 7 deletions
|
@ -424,17 +424,17 @@ namespace PKHeX.Core
|
|||
|
||||
public void DeletePartySlot(int slot)
|
||||
{
|
||||
if (PartyCount <= slot) // beyond party range (or empty data already present)
|
||||
int newEmpty = PartyCount - 1;
|
||||
if ((uint)slot > newEmpty) // beyond party range (or empty data already present)
|
||||
return;
|
||||
// Move all party slots down one
|
||||
for (int i = slot + 1; i < 6; i++) // Slide slots down
|
||||
for (int i = slot + 1; i <= newEmpty; i++) // Slide slots down
|
||||
{
|
||||
int slotTo = GetPartyOffset(i - 1);
|
||||
int slotFrom = GetPartyOffset(i);
|
||||
SetData(GetData(slotFrom, SIZE_PARTY), slotTo);
|
||||
var current = GetPartySlotAtIndex(i);
|
||||
SetPartySlotAtIndex(current, i - 1, PKMImportSetting.Skip, PKMImportSetting.Skip);
|
||||
}
|
||||
SetPartySlot(BlankPKM, GetPartyOffset(5), PKMImportSetting.Skip, PKMImportSetting.Skip);
|
||||
PartyCount--;
|
||||
SetPartySlotAtIndex(BlankPKM, newEmpty, PKMImportSetting.Skip, PKMImportSetting.Skip);
|
||||
// PartyCount will automatically update via above call. Do not adjust.
|
||||
}
|
||||
|
||||
#region Slot Storing
|
||||
|
|
Loading…
Add table
Reference in a new issue