mirror of
https://github.com/HarbourMasters/Shipwright
synced 2026-08-21 06:48:39 -04:00
29c7e75688
gItemSlots and sExtraItemBases only cover the item IDs that live in the inventory, but Item_Give and Item_CheckObtainability index them with any item ID. Reading past gItemSlots lands on gUpgradeShifts, so INV_CONTENT(ITEM_SKULL_TOKEN) resolved to the Bow slot and stored the token there, permanently corrupting the save. Route both through a bounds-checked Item_GetSlot that reports SLOT_NONE for items that have no slot, and skip the inventory store in that case. That read is also undefined behaviour, which link-time optimization is free to exploit: with it present clang dropped the ITEM_SKULL_TOKEN branch and the ITEM_MEDALLION_WATER horse fixup from Item_Give entirely, so tokens were never counted either. Co-authored-by: Claude Opus 5 <noreply@anthropic.com>