FindItemCount, counts two for every 1 when dealing with augments.
Issue template
- [] What - FindItemCount count is wrong.
- [] How - ${FindItemCount[Stone of the Landing]} reports 2 when you only have 1. Reproduce with any augment.
- [] When - Anytime using FindItemCountByName(pName, bExact) or FindItemCountByID(ID) functions in MQ2Utilities.cpp
Offending Code:
// Check for augs next
if (pItem->Contents.ContainedItems.pItems && pItem->Contents.ContainedItems.Size) {
for (unsigned long nAug = 0; nAug < pItem->Contents.ContainedItems.Size; nAug++) {
if (PCONTENTS pAugItem = pItem->Contents.ContainedItems.pItems->Item[nAug]) {
if (GetItemFromContents(pAugItem)->Type == ITEMTYPE_NORMAL && GetItemFromContents(pAugItem)->AugType) {
if (bExact) {
if (!_stricmp(Name, GetItemFromContents(pAugItem)->Name)) {
Count++;
}
}
else {
strcpy_s(Temp, GetItemFromContents(pAugItem)->Name);
_strlwr_s(Temp);
if (strstr(Temp, Name)) {
Count++;
}
}
}
}
}
}
Proposed Fix: add checking the type for top level slot checking to ensure ItemType is not ITEMTYPE_PACK.
// Check for augs next
if (GetItemFromContents(pItem)->Type != ITEMTYPE_PACK) {
if (pItem->Contents.ContainedItems.pItems && pItem->Contents.ContainedItems.Size) {
for (unsigned long nAug = 0; nAug < pItem->Contents.ContainedItems.Size; nAug++) {
if (PCONTENTS pAugItem = pItem->Contents.ContainedItems.pItems->Item[nAug]) {
if (GetItemFromContents(pAugItem)->Type == ITEMTYPE_NORMAL && GetItemFromContents(pAugItem)->AugType) {
if (bExact) {
if (!_stricmp(Name, GetItemFromContents(pAugItem)->Name)) {
Count++;
}
}
else {
strcpy_s(Temp, GetItemFromContents(pAugItem)->Name);
_strlwr_s(Temp);
if (strstr(Temp, Name)) {
Count++;
}
}
}
}
}
}
}
This requirement is only needed for top level inventory slots since pItem->Contents.ContainedItems.pItems will be true for both packs and items with augs. However, Packs contained items are checked after top level slots and will find the augments then. Currently we check the contents of bags twice for augs. Once in top level slot check, and again in checking in the bags. This is why the error only occurs when checking Augments for a count.
Edited by ChatWithThisName