Fix bug in addInventoryItem

Bug : addInventoryItem could overwrite items if their indexes weren't
matching their order in the inventory list.