From dd53ad8cd4cac1bbd9cf8896cbc4a27a00e4e369 Mon Sep 17 00:00:00 2001 From: William Casarin Date: Sat, 12 Jul 2025 10:05:38 -0700 Subject: [PATCH] item: make SLOT macro safe for custom items When creating custom items, have a fallback slot for custom item ids that don't have an entry in the itemId -> slot mapping table Signed-off-by: William Casarin --- soh/include/macros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/soh/include/macros.h b/soh/include/macros.h index 325fb91b6..fe7770da4 100644 --- a/soh/include/macros.h +++ b/soh/include/macros.h @@ -65,7 +65,7 @@ #define IS_DAY (gSaveContext.nightFlag == 0) #define IS_NIGHT (gSaveContext.nightFlag == 1) -#define SLOT(item) gItemSlots[item] +#define SLOT(item) (item > ARRAY_COUNT(gItemSlots)-1 ? SLOT_BOTTLE_1 : gItemSlots[item]) #define INV_CONTENT(item) gSaveContext.inventory.items[SLOT(item)] #define AMMO(item) gSaveContext.inventory.ammo[SLOT(item)] #define BEANS_BOUGHT AMMO(ITEM_BEAN + 1)