Eliminate goto in ItemUseCB_Medicine

This commit is contained in:
Thomas Winwood 2020-10-21 20:07:34 +01:00
parent 585f313c64
commit 2239f3aa60

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)