Page 1 of 2
Tooltips for items with clickies with recast delays in bags
Posted: Fri Feb 23, 2007 5:37 am
by QuestionTheAnswers
I noticed that when I placed an item with a clicky (say a wand of mystical transvergance) into a bag, and waved over the item, the item timer text wouldn't show up. When I wave over the item in the previous slot next to the wand, instead of the tooltip for that item coming up, it would display the wand of mystical transvergance, and it's clicky timer. I tracked down the problem to the following code...
MQ2Utilities.cpp:
Code: Select all
PCONTENTS GetItemContentsBySlotID(DWORD dwSlotID)
{
int InvSlot=-1;
int SubSlot=-1;
if(dwSlotID>=0 && dwSlotID<NUM_INV_SLOTS) InvSlot=dwSlotID;
else if(dwSlotID>=262 && dwSlotID<342) {
InvSlot=23+(dwSlotID-262)/10;
SubSlot=(dwSlotID-1)%10;
}
if(InvSlot>=0 && InvSlot<NUM_INV_SLOTS) {
if(PCONTENTS iSlot=GetCharInfo2()->InventoryArray[InvSlot]) {
if(SubSlot<0) return iSlot;
if(PCONTENTS sSlot=GetCharInfo2()->InventoryArray[InvSlot]->Contents[SubSlot]) return sSlot;
}
}
return NULL;
}
The math for the SubSlot calculation is incorrect. If you go through all the SlotIDs, the series will equal 1-9, then repeat with 0-9's the rest of the time. The sequence necessary is 0-9, every time. The correct math is as follows:
Posted: Fri Feb 23, 2007 8:13 am
by wassup
Or...
Whatever is calling GetItemContentsBySlotID(DWORD dwSlotID) is passing an incorrect value.
*EDIT*
After taking a quick look at the code, I believe your fix is correct.
Posted: Fri Feb 23, 2007 11:18 am
by QuestionTheAnswers
I checked to make sure it wasn't passing invalid SlotID's, the problem was the SubSlot calculation. I can only assume that whomever wrote it thought that it needed to be numbers 1 through 10, but even if that was the case, the calculation still doesn't work properly. It would have to be SubSlot=(dwSlotID-2)%10+1. The fix above is correct. It is being called by MQ2ItemDisplay, in the detour of the InvSlotWndHook class.
Posted: Fri Feb 23, 2007 12:40 pm
by dont_know_at_all
Technically, it should have been:
and after TBS it should be:
Good find. Fixed in next zip.
Posted: Fri Feb 23, 2007 5:37 pm
by wassup
dont_know_at_all wrote:Technically, it should have been:
and after TBS it should be:
Good find. Fixed in next zip.
The (dwSlotID-2)%10 does the same thing as (dwSlotID-262)%10 doesn't it?
But for convention I can see why 262 is used too.
Posted: Fri Feb 23, 2007 6:11 pm
by QuestionTheAnswers
They are functionally equivalent, just a matter of preference to start counting from zero or 260, either works, I figured that subtracting just 2 instead of 262 would be less processor intensive, as little as it is anyway. The only reason I can think of to start from zero is for clarity.
Posted: Fri Feb 23, 2007 6:37 pm
by dont_know_at_all
I should really change all the slot constants to #defines so that if it changes again, it will just work if we update the constants. However, the odds of me breaking something while doing this is probably greater than the odds of them changing it again.
Posted: Fri Feb 23, 2007 8:54 pm
by gimp
QuestionTheAnswers wrote:I figured that subtracting just 2 instead of 262 would be less processor intensive, as little as it is anyway.
That might be true if you are compiling for a 8 bit cpu.
In reality it makes absolutley no difference and only adds to confusing source code.
Re: Tooltips for items with clickies with recast delays in bags
Posted: Sat Aug 09, 2025 6:10 pm
by xyilla
Re: Tooltips for items with clickies with recast delays in bags
Posted: Sat Aug 09, 2025 6:47 pm
by xyilla
Re: Tooltips for items with clickies with recast delays in bags
Posted: Sat Aug 09, 2025 6:48 pm
by xyilla
Re: Tooltips for items with clickies with recast delays in bags
Posted: Sat Aug 09, 2025 6:49 pm
by xyilla
Re: Tooltips for items with clickies with recast delays in bags
Posted: Sat Aug 09, 2025 7:26 pm
by xyilla
Re: Tooltips for items with clickies with recast delays in bags
Posted: Sat Aug 09, 2025 7:27 pm
by xyilla
Re: Tooltips for items with clickies with recast delays in bags
Posted: Sat Aug 09, 2025 7:29 pm
by xyilla