Merge pull request #1238 from ketsuban/master

Eliminate goto in ItemUseCB_Medicine
This commit is contained in:
GriffinR 2020-10-29 23:50:17 -04:00 committed by GitHub
commit fbff087e9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4325,9 +4325,13 @@ void ItemUseCB_Medicine(u8 taskId, TaskFunc task)
u16 hp = 0;
struct Pokemon *mon = &gPlayerParty[gPartyMenu.slotId];
u16 item = gSpecialVar_ItemId;
bool8 canHeal;
bool8 canHeal, cannotUse;
if (NotUsingHPEVItemOnShedinja(mon, item))
if (NotUsingHPEVItemOnShedinja(mon, item) == FALSE)
{
cannotUse = TRUE;
}
else
{
canHeal = IsHPRecoveryItem(item);
if (canHeal == TRUE)
@ -4336,21 +4340,19 @@ void ItemUseCB_Medicine(u8 taskId, TaskFunc task)
if (hp == GetMonData(mon, MON_DATA_MAX_HP))
canHeal = FALSE;
}
if (ExecuteTableBasedItemEffect_(gPartyMenu.slotId, item, 0))
cannotUse = ExecuteTableBasedItemEffect_(gPartyMenu.slotId, item, 0);
}
if (cannotUse != FALSE)
{
iTriedHonestlyIDid:
gPartyMenuUseExitCallback = FALSE;
PlaySE(SE_SELECT);
DisplayPartyMenuMessage(gText_WontHaveEffect, TRUE);
ScheduleBgCopyTilemapToVram(2);
gTasks[taskId].func = task;
return;
}
}
else
{
goto iTriedHonestlyIDid; //TODO: resolve this goto
}
gPartyMenuUseExitCallback = TRUE;
if (!IsItemFlute(item))
{
@ -4381,6 +4383,7 @@ void ItemUseCB_Medicine(u8 taskId, TaskFunc task)
ScheduleBgCopyTilemapToVram(2);
gTasks[taskId].func = task;
}
}
}
static void Task_DisplayHPRestoredMessage(u8 taskId)