From 977860f834fb465c19f99a1e444032b359784c4e Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sat, 30 Sep 2023 15:31:11 -0300 Subject: [PATCH] Fixed deleting PC mon by placing another one on top with B (#3360) --- src/pokemon_storage_system.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index 849c523b8e19..b6bbad3ee8db 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -678,6 +678,7 @@ static void InitSummaryScreenData(void); static void SetSelectionAfterSummaryScreen(void); static void SetMonMarkings(u8); static bool8 IsRemovingLastPartyMon(void); +static bool8 CanPlaceMon(void); static bool8 CanShiftMon(void); static bool8 IsMonBeingMoved(void); static void TryRefreshDisplayMon(void); @@ -3690,8 +3691,15 @@ static void Task_OnBPressed(u8 taskId) PrintMessage(MSG_HOLDING_POKE); sStorage->state = 1; #else - PlaySE(SE_SELECT); - SetPokeStorageTask(Task_PlaceMon); + if (CanPlaceMon()) + { + PlaySE(SE_SELECT); + SetPokeStorageTask(Task_PlaceMon); + } + else + { + SetPokeStorageTask(Task_PokeStorageMain); + } #endif } else if (IsMovingItem()) @@ -6826,6 +6834,20 @@ static bool8 IsRemovingLastPartyMon(void) return FALSE; } +static bool8 CanPlaceMon(void) +{ + if (sIsMonBeingMoved) + { + if (sCursorArea == CURSOR_AREA_IN_PARTY && GetMonData(&gPlayerParty[sCursorPosition], MON_DATA_SPECIES) == SPECIES_NONE) + return TRUE; + else if (sCursorArea == CURSOR_AREA_IN_BOX && GetBoxMonDataAt(StorageGetCurrentBox(), sCursorPosition, MON_DATA_SPECIES_OR_EGG) == SPECIES_NONE) + return TRUE; + else + return FALSE; + } + return FALSE; +} + static bool8 CanShiftMon(void) { if (sIsMonBeingMoved)