Now that I've confused, flustered and maddened everyone with my code submissions so far, let's move on to something more productive.
Here's what I'm seeing at first glance with the 'Bandolier' issue.
inventory.cpp::Client::SetBandolier(const EQApplicationPacket *app)
Code:
slot = m_inv.HasItem(m_pp.bandoliers[bss->number].items[BandolierSlot].item_id, 1, invWhereWorn|invWherePersonal|invWhereCursor);
Item.cpp::Inventory::HasItem(uint32 item_id, uint8 quantity, uint8 where)
Code:
if(where & invWhereCursor) {
// Check cursor queue
slot_id = _HasItem(m_cursor, item_id, quantity);
if (slot_id != SLOT_INVALID)
return slot_id;
}
The following internal function is overloaded allowing two argument sets. The checks in Inventory::HasItem all use the first definition with
the exception of the last check that uses the second one, which is m_cursor.
Item.cpp::Inventory::_HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity)
Code:
for (it=iqueue.begin(); it!=iqueue.end(); it++) {
ItemInst* inst = *it;
if (inst)
{
if (inst->GetID() == item_id) {
quantity_found += (inst->GetCharges()<=0) ? 1 : inst->GetCharges();
if (quantity_found >= quantity)
return SLOT_CURSOR;
}
Notice how 'it' is iterated. If an item is found, it returns SLOT_CURSOR. MAJOR PROBLEM there unless it's found at slot 8000...
SetBandolier assigns the weapon slot based on 'HasItem.' Say, for instance, the item being sought is in the fourth queue position. The actual
item is in slot 8003, but the Bandolier function thinks it is in slot 30 (queue slot 8000) because of 'return SLOT_CURSOR;' This is creating a
CSD.
We can't change that to slot_id because the client doesn't allow cursor queue manipulation. We should consider only checking the queue
for items, but not allowing their removal unless all items up to that item are also removed, and possibly pushed back to the cursor.
I think this is one of the causes of the bandolier issue, and possibly the tradeskill cursor issue as well.
If you think my logic is flawed, your input is welcome. I need to understand this if I'm to stand any chance of fixing it.