Fix inventory overflow bug overwriting equipment slot 0
Some checks failed
Build / Linux (push) Has been cancelled
Build / Windows (push) Has been cancelled

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
This commit is contained in:
Claude 2026-01-23 21:38:43 +00:00 committed by Alex
parent 9d2cc213ce
commit 024abf74a8
2 changed files with 3 additions and 2 deletions

View File

@ -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

View File

@ -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;
}