Tooltips for items with clickies with recast delays in bags

A forum for reporting bugs NOT related to custom plugins.

Moderator: MacroQuest Developers

QuestionTheAnswers
orc pawn
orc pawn
Posts: 20
Joined: Sun Mar 13, 2005 10:56 am

Tooltips for items with clickies with recast delays in bags

Post by QuestionTheAnswers » Fri Feb 23, 2007 5:37 am

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:

Code: Select all

SubSlot=(dwSlotID-2)%10

wassup
Official Guardian and Writer of TFM
Official Guardian and Writer of TFM
Posts: 1487
Joined: Sat Oct 26, 2002 5:15 pm

Post by wassup » Fri Feb 23, 2007 8:13 am

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.

QuestionTheAnswers
orc pawn
orc pawn
Posts: 20
Joined: Sun Mar 13, 2005 10:56 am

Post by QuestionTheAnswers » Fri Feb 23, 2007 11:18 am

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.

User avatar
dont_know_at_all
Developer
Developer
Posts: 5450
Joined: Sun Dec 01, 2002 4:15 am
Location: Florida, USA
Contact:

Post by dont_know_at_all » Fri Feb 23, 2007 12:40 pm

Technically, it should have been:

Code: Select all

SubSlot=(dwSlotID-251)%10
and after TBS it should be:

Code: Select all

SubSlot=(dwSlotID-262)%10
Good find. Fixed in next zip.

wassup
Official Guardian and Writer of TFM
Official Guardian and Writer of TFM
Posts: 1487
Joined: Sat Oct 26, 2002 5:15 pm

Post by wassup » Fri Feb 23, 2007 5:37 pm

dont_know_at_all wrote:Technically, it should have been:

Code: Select all

SubSlot=(dwSlotID-251)%10
and after TBS it should be:

Code: Select all

SubSlot=(dwSlotID-262)%10
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.

QuestionTheAnswers
orc pawn
orc pawn
Posts: 20
Joined: Sun Mar 13, 2005 10:56 am

Post by QuestionTheAnswers » Fri Feb 23, 2007 6:11 pm

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.

User avatar
dont_know_at_all
Developer
Developer
Posts: 5450
Joined: Sun Dec 01, 2002 4:15 am
Location: Florida, USA
Contact:

Post by dont_know_at_all » Fri Feb 23, 2007 6:37 pm

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.

User avatar
gimp
a grimling bloodguard
a grimling bloodguard
Posts: 584
Joined: Fri Oct 29, 2004 9:28 am
Location: internet

Post by gimp » Fri Feb 23, 2007 8:54 pm

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.

xyilla
naggy
naggy
Posts: 29514
Joined: Sun Feb 23, 2025 5:36 am

Re: Tooltips for items with clickies with recast delays in bags

Post by xyilla » Sat Aug 09, 2025 6:10 pm


xyilla
naggy
naggy
Posts: 29514
Joined: Sun Feb 23, 2025 5:36 am

Re: Tooltips for items with clickies with recast delays in bags

Post by xyilla » Sat Aug 09, 2025 6:47 pm


xyilla
naggy
naggy
Posts: 29514
Joined: Sun Feb 23, 2025 5:36 am

Re: Tooltips for items with clickies with recast delays in bags

Post by xyilla » Sat Aug 09, 2025 6:48 pm


xyilla
naggy
naggy
Posts: 29514
Joined: Sun Feb 23, 2025 5:36 am

Re: Tooltips for items with clickies with recast delays in bags

Post by xyilla » Sat Aug 09, 2025 6:49 pm


xyilla
naggy
naggy
Posts: 29514
Joined: Sun Feb 23, 2025 5:36 am

Re: Tooltips for items with clickies with recast delays in bags

Post by xyilla » Sat Aug 09, 2025 7:26 pm


xyilla
naggy
naggy
Posts: 29514
Joined: Sun Feb 23, 2025 5:36 am

Re: Tooltips for items with clickies with recast delays in bags

Post by xyilla » Sat Aug 09, 2025 7:27 pm


xyilla
naggy
naggy
Posts: 29514
Joined: Sun Feb 23, 2025 5:36 am

Re: Tooltips for items with clickies with recast delays in bags

Post by xyilla » Sat Aug 09, 2025 7:29 pm