From 024abf74a8ef36d0a9ab49dff165a211a1875ab7 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 23 Jan 2026 21:38:43 +0000 Subject: [PATCH] Fix inventory overflow bug overwriting equipment slot 0 FindFirstFreeSlotThatFitsItem was returning 0 instead of INVALID_INDEX when no free slot was found. This caused items to be placed in slot 0 (charm equipment slot) when inventory was full, overwriting equipped items. Changes: - Fix FindFirstFreeSlotThatFitsItem to return INVALID_INDEX when no slot found - Add defensive check in PutItemInInventoryWithStacking to protect equipment slots 0-22 from being targeted for item placement --- common/inventory_profile.cpp | 2 +- zone/inventory.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/common/inventory_profile.cpp b/common/inventory_profile.cpp index 6d16f50b0..4907cd1b9 100644 --- a/common/inventory_profile.cpp +++ b/common/inventory_profile.cpp @@ -1839,7 +1839,7 @@ int16 EQ::InventoryProfile::FindFirstFreeSlotThatFitsItem(const EQ::ItemData *it } } } - return 0; + return INVALID_INDEX; } //This function has the same flaw as noted above diff --git a/zone/inventory.cpp b/zone/inventory.cpp index 812d09aba..cb28aeb2c 100644 --- a/zone/inventory.cpp +++ b/zone/inventory.cpp @@ -4679,7 +4679,8 @@ bool Client::PutItemInInventoryWithStacking(EQ::ItemInstance *inst) return true; } } - if (free_id != INVALID_INDEX) { + // Protect equipment slots (0-22) from being overwritten + if (free_id != INVALID_INDEX && !EQ::ValueWithin(free_id, EQ::invslot::EQUIPMENT_BEGIN, EQ::invslot::EQUIPMENT_END)) { if (PutItemInInventory(free_id, *inst, true)) { return true; }