From 0fd9d2c0d5bb5b4bf9ac624eddb965aefa7cbc24 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Thu, 30 Sep 2021 21:55:21 -0300 Subject: [PATCH] Optimized so it only changes forms when moving items. --- src/pokemon_storage_system.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index 7768f4e32d..3c7051e169 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -3799,9 +3799,16 @@ static void GiveChosenBagItem(void) { u8 pos = GetCursorPosition(); if (sInPartyMenu) + { + struct Pokemon *mon = &gPlayerParty[pos]; SetMonData(&gPlayerParty[pos], MON_DATA_HELD_ITEM, &itemId); + SetMonFormPSS(&mon->box); + } else + { SetCurrentBoxMonData(pos, MON_DATA_HELD_ITEM, &itemId); + SetMonFormPSS(&gPokemonStoragePtr->boxes[StorageGetCurrentBox()][pos]); + } RemoveBagItem(itemId, 1); } @@ -7020,7 +7027,6 @@ static void SetDisplayMonData(void *pokemon, u8 mode) StringCopyPadded(sStorage->displayMonItemName, ItemId_GetName(sStorage->displayMonItemId), CHAR_SPACE, 8); else StringFill(sStorage->displayMonItemName, CHAR_SPACE, 8); - SetMonFormPSS(pokemon); } } @@ -8860,11 +8866,14 @@ static void TakeItemFromMon(u8 cursorArea, u8 cursorPos) { SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &itemId); SetBoxMonIconObjMode(cursorPos, 1); + SetMonFormPSS(&gPokemonStoragePtr->boxes[StorageGetCurrentBox()][cursorPos]); } else { + struct Pokemon *mon = &gPlayerParty[cursorPos]; SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &itemId); SetPartyMonIconObjMode(cursorPos, 1); + SetMonFormPSS(&mon->box); } sStorage->movingItemId = sStorage->displayMonItemId; @@ -8899,12 +8908,15 @@ static void SwapItemsWithMon(u8 cursorArea, u8 cursorPos) itemId = GetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM); SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &sStorage->movingItemId); sStorage->movingItemId = itemId; + SetMonFormPSS(&gPokemonStoragePtr->boxes[StorageGetCurrentBox()][cursorPos]); } else { + struct Pokemon *mon = &gPlayerParty[cursorPos]; itemId = GetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM); SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &sStorage->movingItemId); sStorage->movingItemId = itemId; + SetMonFormPSS(&mon->box); } id = GetItemIconIdxByPosition(CURSOR_AREA_IN_HAND, 0); @@ -8926,11 +8938,14 @@ static void GiveItemToMon(u8 cursorArea, u8 cursorPos) { SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &sStorage->movingItemId); SetBoxMonIconObjMode(cursorPos, 0); + SetMonFormPSS(&gPokemonStoragePtr->boxes[StorageGetCurrentBox()][cursorPos]); } else { + struct Pokemon *mon = &gPlayerParty[cursorPos]; SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &sStorage->movingItemId); SetPartyMonIconObjMode(cursorPos, 0); + SetMonFormPSS(&mon->box); } } @@ -8950,11 +8965,14 @@ static void MoveItemFromMonToBag(u8 cursorArea, u8 cursorPos) { SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &itemId); SetBoxMonIconObjMode(cursorPos, 1); + SetMonFormPSS(&gPokemonStoragePtr->boxes[StorageGetCurrentBox()][cursorPos]); } else { + struct Pokemon *mon = &gPlayerParty[cursorPos]; SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &itemId); SetPartyMonIconObjMode(cursorPos, 1); + SetMonFormPSS(&mon->box); } }