Skip to content

Commit 024abf7

Browse files
claudeKimLS
authored andcommitted
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
1 parent 9d2cc21 commit 024abf7

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

common/inventory_profile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1839,7 +1839,7 @@ int16 EQ::InventoryProfile::FindFirstFreeSlotThatFitsItem(const EQ::ItemData *it
18391839
}
18401840
}
18411841
}
1842-
return 0;
1842+
return INVALID_INDEX;
18431843
}
18441844

18451845
//This function has the same flaw as noted above

zone/inventory.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4679,7 +4679,8 @@ bool Client::PutItemInInventoryWithStacking(EQ::ItemInstance *inst)
46794679
return true;
46804680
}
46814681
}
4682-
if (free_id != INVALID_INDEX) {
4682+
// Protect equipment slots (0-22) from being overwritten
4683+
if (free_id != INVALID_INDEX && !EQ::ValueWithin(free_id, EQ::invslot::EQUIPMENT_BEGIN, EQ::invslot::EQUIPMENT_END)) {
46834684
if (PutItemInInventory(free_id, *inst, true)) {
46844685
return true;
46854686
}

0 commit comments

Comments
 (0)