This is a fix for the bug that let you loot a lore augment even if you have one already slotted.
This is done by modifying 3 function , both Inventory::_hasItem and eq_constants.h.
I added a new slot type to return when the search item from _hasItem is found in a augment slot. I chose the value 1001 but feel free to change it to a more appropriate value if it need to.
Code:
enum InventorySlot
{
////////////////////////
// Equip slots
////////////////////////
SLOT_CHARM = 0,
SLOT_EAR01 = 1,
SLOT_HEAD = 2,
SLOT_FACE = 3,
SLOT_EAR02 = 4,
SLOT_NECK = 5,
SLOT_SHOULDER = 6,
SLOT_ARMS = 7,
SLOT_BACK = 8,
SLOT_BRACER01 = 9,
SLOT_BRACER02 = 10,
SLOT_RANGE = 11,
SLOT_HANDS = 12,
SLOT_PRIMARY = 13,
SLOT_SECONDARY = 14,
SLOT_RING01 = 15,
SLOT_RING02 = 16,
SLOT_CHEST = 17,
SLOT_LEGS = 18,
SLOT_FEET = 19,
SLOT_WAIST = 20,
SLOT_AMMO = 21,
////////////////////////
// All other slots
////////////////////////
SLOT_PERSONAL_BEGIN = 22,
SLOT_PERSONAL_END = 29,
SLOT_CURSOR = 30,
SLOT_CURSOR_END = (sint16)0xFFFE, // Last item on cursor queue
// Cursor bag slots are 331->340 (10 slots)
// Personal Inventory Slots
// Slots 1 through 8 are slots 22->29
// Inventory bag slots are 251->330 (10 slots per bag)
// Tribute slots are 400-404? (upper bound unknown)
// storing these in worn item's map
// Bank slots
// Bank slots 1 through 16 are slots 2000->2015
// Bank bag slots are 2031->2190
// Shared bank slots
// Shared bank slots 1 through 2 are slots 2500->2501
// Shared bank bag slots are 2531->2550
// Trade session slots
// Trade slots 1 through 8 are slots 3000->3007
// Trade bag slots are technically 0->79 when passed to client,
// but in our code, we treat them as slots 3100->3179
// Slot used in OP_TradeSkillCombine for world tradeskill containers
SLOT_TRADESKILL = 1000,
SLOT_AUGMENT = 1001,
// Value recognized by client for destroying an item
SLOT_INVALID = (sint16)0xFFFF
};
And here are both _hasItem functions found in Item.cpp modified to check all augments slot for each item it checks.
First
Code:
sint16 Inventory::_HasItem(map<sint16, ItemInst*>& bucket, uint32 item_id, uint8 quantity)
{
iter_inst it;
iter_contents itb;
ItemInst* inst = NULL;
uint8 quantity_found = 0;
// Check item: After failed checks, check bag contents (if bag)
for (it=bucket.begin(); it!=bucket.end(); it++) {
inst = it->second;
if (inst) {
if (inst->GetID() == item_id) {
quantity_found += (inst->GetCharges()<=0) ? 1 : inst->GetCharges();
if (quantity_found >= quantity)
return it->first;
}
for(int i = 0; i < MAX_AUGMENT_SLOTS; i++) {
if (inst->GetAugmentItemID(i) == item_id && quantity <= 1)
return SLOT_AUGMENT; // Only one augment per slot.
}
}
// Go through bag, if bag
if (inst && inst->IsType(ItemClassContainer)) {
for (itb=inst->_begin(); itb!=inst->_end(); itb++) {
ItemInst* baginst = itb->second;
if (baginst->GetID() == item_id) {
quantity_found += (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges();
if (quantity_found >= quantity)
return Inventory::CalcSlotId(it->first, itb->first);
}
for(int i = 0; i < MAX_AUGMENT_SLOTS; i++) {
if (baginst->GetAugmentItemID(i) == item_id && quantity <= 1)
return SLOT_AUGMENT; // Only one augment per slot.
}
}
}
}
// Not found
return SLOT_INVALID;
}
Second
Code:
sint16 Inventory::_HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity)
{
iter_queue it;
iter_contents itb;
uint8 quantity_found = 0;
// Read-only iteration of queue
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;
}
for(int i = 0; i < MAX_AUGMENT_SLOTS; i++) {
if (inst->GetAugmentItemID(i) == item_id && quantity <= 1)
return SLOT_AUGMENT; // Only one augment per slot.
}
}
// Go through bag, if bag
if (inst && inst->IsType(ItemClassContainer)) {
for (itb=inst->_begin(); itb!=inst->_end(); itb++) {
ItemInst* baginst = itb->second;
if (baginst->GetID() == item_id) {
quantity_found += (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges();
if (quantity_found >= quantity)
return Inventory::CalcSlotId(SLOT_CURSOR, itb->first);
}
for(int i = 0; i < MAX_AUGMENT_SLOTS; i++) {
if (baginst->GetAugmentItemID(i) == item_id && quantity <= 1)
return SLOT_AUGMENT; // Only one augment per slot.
}
}
}
}
// Not found
return SLOT_INVALID;
}
--------
Pyronis/Kahel
Dev - Jest 3 Server