mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-20 21:33:40 -07:00
item: introduce Item_GetAction
When creating custom items, let's not immediately crash if trying to lookup an unknown item action for a new id Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
parent
47cb94061b
commit
82fff58062
2 changed files with 12 additions and 2 deletions
|
@ -1239,6 +1239,7 @@ void Sample_Destroy(GameState* thisx);
|
|||
void Sample_Init(GameState* thisx);
|
||||
void Inventory_ChangeEquipment(s16 equipment, u16 value);
|
||||
void *Item_GetIcon(s16 item);
|
||||
s32 Item_GetAction(s16 item);
|
||||
u8 Inventory_DeleteEquipment(PlayState* play, s16 equipment);
|
||||
void Inventory_ChangeUpgrade(s16 upgrade, s16 value);
|
||||
void Object_InitBank(PlayState* play, ObjectContext* objectCtx);
|
||||
|
|
|
@ -2253,7 +2253,7 @@ s8 Player_ItemToItemAction(s32 item) {
|
|||
} else if (item == ITEM_FISHING_POLE) {
|
||||
return PLAYER_IA_FISHING_POLE;
|
||||
} else {
|
||||
return sItemActions[item];
|
||||
return Item_GetAction(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10657,9 +10657,18 @@ void Player_StartMode_BlueWarp(PlayState* play, Player* this) {
|
|||
|
||||
static u8 D_808546F0[] = { ITEM_SWORD_MASTER, ITEM_SWORD_KOKIRI };
|
||||
|
||||
// Helper so that we don't buffer overrun item actions with custom items
|
||||
s32 Item_GetAction(s16 item) {
|
||||
if (item > ARRAY_COUNT(sItemActions)-1) {
|
||||
return PLAYER_IA_POCKET_EGG;
|
||||
}
|
||||
|
||||
return sItemActions[item];
|
||||
}
|
||||
|
||||
void func_80846720(PlayState* play, Player* this, s32 arg2) {
|
||||
s32 item = D_808546F0[(void)0, gSaveContext.linkAge];
|
||||
s32 itemAction = sItemActions[item];
|
||||
s32 itemAction = Item_GetAction(item);
|
||||
|
||||
Player_DestroyHookshot(this);
|
||||
Player_DetachHeldActor(play, this);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue