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