Add safety check to loadItemIcon (#380)

* Add safety check to loadItemIcon

* Update mm/src/code/code_8012EC80.c
This commit is contained in:
Garrett Cox
2024-05-22 09:05:04 -05:00
parent a46850859a
commit cd1592cff6
+11 -3
View File
@@ -3310,8 +3310,12 @@ void Interface_InitMinigame(PlayState* play) {
void Interface_Dpad_LoadItemIconImpl(PlayState* play, u8 btn) {
InterfaceContext* interfaceCtx = &play->interfaceCtx;
interfaceCtx->iconItemSegment[DPAD_BUTTON(btn) + EQUIP_SLOT_MAX] = gItemIcons[DPAD_GET_CUR_FORM_BTN_ITEM(btn)];
if (DPAD_GET_CUR_FORM_BTN_ITEM(btn) < ARRAY_COUNT(gItemIcons)) {
interfaceCtx->iconItemSegment[DPAD_BUTTON(btn) + EQUIP_SLOT_MAX] = gItemIcons[DPAD_GET_CUR_FORM_BTN_ITEM(btn)];
} else {
interfaceCtx->iconItemSegment[btn] = gEmptyTexture;
}
}
void Interface_LoadItemIconImpl(PlayState* play, u8 btn) {
@@ -3320,7 +3324,11 @@ void Interface_LoadItemIconImpl(PlayState* play, u8 btn) {
// #region 2S2H [Port]
// CmpDma_LoadFile(SEGMENT_ROM_START(icon_item_static_yar), GET_CUR_FORM_BTN_ITEM(btn),
// &interfaceCtx->iconItemSegment[(u32)btn * 0x1000], 0x1000);
interfaceCtx->iconItemSegment[btn] = gItemIcons[GET_CUR_FORM_BTN_ITEM(btn)];
if (GET_CUR_FORM_BTN_ITEM(btn) < ARRAY_COUNT(gItemIcons)) {
interfaceCtx->iconItemSegment[btn] = gItemIcons[GET_CUR_FORM_BTN_ITEM(btn)];
} else {
interfaceCtx->iconItemSegment[btn] = gEmptyTexture;
}
// #endregion
}