Reply
Thread Tools Display Modes
Unread 01-09-14, 08:13 PM   #1
Simca
A Deviate Faerie Dragon
 
Simca's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2012
Posts: 12
GetLootSourceInfo() Partially Broken in 5.4.2?

Hi all,

I do occasional dev work on an addon that deals with looting, and I've noticed some odd occurrences since Patch 5.4.2 under one specific scenario: when a player opens an item container from their inventory, sometimes GetLootSourceInfo(slot) will return 'nil' for argument 1 instead of a GUID.

I'm having a lot of difficulty replicating this error though. When I first log in, normally everything works fine. When I try containers that only have money after a few hours, they're fine too. After I loot a container with only an item (or multiple items) after several hours of playing (inevitably triggering whatever causes this bug in the meantime), then all containers forwards will be bugged as described in the first paragraph.

The code I'm using isn't really mine to post otherwise I would, but it's fairly simple. It securely hooks "UseContainerItem" and "UseItemByName". If the function hooked is UseItemByName, it converts the argument from an item link to an item ID. It looks through your bags with a loop to find the first bag_index and slot_index with the same item ID. UseContainerItem natively returns bag_index and slot_index. All of my testing is done by UseContainerItem anyway. Afterwards, it checks the "is_lootable" arg of GetContainerItemInfo. If it is lootable, it looks for the next "LOOT_OPENED" event to fire. When that fires, it looks at GetItemSourceInfo(), and the bug can occur.

Not sure if anyone else has encountered this or not - you would only notice this problem if you had an addon that watched every loot event, and you had extensive debugging code. If you have, it'd be a relief - the only two results on Google are completely unrelated.

Thanks!

P.S. While rapidly clicking boxes to attempt to replicate the bug, I managed some magic. I guess "AoE looting" truly does work for everything: http://i.imgur.com/ZizbwoQ.jpg
__________________
Global Moderator for MMO-Champion
Simca is offline   Reply With Quote
Unread 01-09-14, 08:32 PM   #2
semlar
A Molten Giant
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 623
GetLootSourceInfo returns the GUID of the corpse in an AOE loot situation and I don't know why it would have a value for a container from your inventory.
semlar is offline   Reply With Quote
Unread 01-09-14, 08:47 PM   #3
Simca
A Deviate Faerie Dragon
 
Simca's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2012
Posts: 12
Originally Posted by semlar View Post
GetLootSourceInfo returns the GUID of the corpse in an AOE loot situation and I don't know why it would have a value for a container from your inventory.
It returns a GUID for the containers in your inventory as well. The GUIDs it returns in that case are actually just your own character's GUID with the 'identifier' (middle 6 hex digits) being the number of item containers you have opened since login (000001, 000002, etc).

What would you use this information for? I don't really want the GUID to learn anything from it like you would with other GUIDs. I want the GUID so that if I see the same GUID again this session, I know that the user is looting the same box as they did before (and that I should ignore this loot event's set of data).

Creating a workaround to catch players opening the same box many times in many different situations would be challenging.
__________________
Global Moderator for MMO-Champion
Simca is offline   Reply With Quote
Unread 01-09-14, 09:00 PM   #4
Phanx
A Pyroguard Emberseer
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 4,571
I doubt it's really intentional that openable containers in your inventory pass a value where a GUID should be, especially if the behavior is not consistent.

Originally Posted by Simca View Post
Creating a workaround to catch players opening the same box many times in many different situations would be challenging.
Why exactly do you need to keep track of this? You didn't say what your addon does, and neither of the addons you are listed as an author for appear to be related to looting, but I can't imagine it's a common scenario for users to open the same box over and over again without looting its contents.
__________________
Author/maintainer of Grid, PhanxChat, ShieldsUp, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
Phanx is offline   Reply With Quote
Unread 01-09-14, 09:48 PM   #5
Simca
A Deviate Faerie Dragon
 
Simca's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2012
Posts: 12
Originally Posted by Phanx View Post
I doubt it's really intentional that openable containers in your inventory pass a value where a GUID should be, especially if the behavior is not consistent.
Possibly, but it seems like a particularly specific value (number of boxes opened) to be contained within a GUID, so somebody at Blizzard must have at least considered this possibility.

Originally Posted by Phanx View Post
Why exactly do you need to keep track of this? You didn't say what your addon does, and neither of the addons you are listed as an author for appear to be related to looting, but I can't imagine it's a common scenario for users to open the same box over and over again without looting its contents.
Mainly, it's because I just want to cover every base, really. Users always come to me with the most bizarre bugs, and it's usually because they're doing something highly abnormal (that they don't realize is highly abnormal).

I may be able to find an entirely different method of doing what I want for this specific addon, but I was curious about this bug, primarily because if it does exist and the problem is not mine, then it has reprocussions for database sites like Wowhead and WoWDB who most likely use this method of tracking opened containers as well.
__________________
Global Moderator for MMO-Champion
Simca is offline   Reply With Quote
Unread 01-09-14, 11:19 PM   #6
Phanx
A Pyroguard Emberseer
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 4,571
Originally Posted by Simca View Post
Mainly, it's because I just want to cover every base, really. Users always come to me with the most bizarre bugs, and it's usually because they're doing something highly abnormal (that they don't realize is highly abnormal). I may be able to find an entirely different method of doing what I want for this specific addon, ...
Again, without knowing what you want to do it's basically impossible to offer any useful suggestions on how you might solve your problem.
__________________
Author/maintainer of Grid, PhanxChat, ShieldsUp, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
Phanx is offline   Reply With Quote
Unread 01-10-14, 01:34 PM   #7
Simca
A Deviate Faerie Dragon
 
Simca's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2012
Posts: 12
Originally Posted by Phanx View Post
Again, without knowing what you want to do it's basically impossible to offer any useful suggestions on how you might solve your problem.
I intended this thread to be more like "Has anyone seen this bug?" rather than "Help me with my addon!", but it's clear that most people probably haven't seen this bug.

At the very least, this bug is now on Google, and it wasn't before this. Hopefully it helps somebody in the future who comes here from a search engine like I would have.

I'll post back if I find any workaround, if I find that the problem was entirely (or partially) on my end, or if I manage to find the trigger for the bug. Overflow of the 6 hex segment is a potential possibility if they have changed the way those numbers are generated. In Patch 5.4.1, there was a bug with the 'double' variables in Lua overflowing when Blizzard passed massive integer values from C code. This could cause odd results if the game (or in some cases the server) had been running for a long time. I'm not sure how they handled the resolution of that issue, but it could have impacted this in some bizarre way.
__________________
Global Moderator for MMO-Champion

Last edited by Simca : 01-10-14 at 01:40 PM.
Simca is offline   Reply With Quote
Unread 01-10-14, 04:51 PM   #8
semlar
A Molten Giant
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 623
I'm pretty sure the item link contains a unique ID for the container.

You could try something like this..
Lua Code:
  1. local uniqueID = GetContainerItemLink(0,1):match('item:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:([^:]+)')

And then cache that in a table to keep track of what's been opened.

The ID seems to persist between sessions so it shouldn't change while you're playing, but of course you'll need to do some testing to make sure.

Also, after some brief testing with a Bag of Shiny Things, the GUID from GetLootSourceInfo is completely unrelated to the player's GUID (0x4480000418D9CC0B for the bag and 0x0480000002D6F631 for the player). It's also not the GUID of the unit that gave me the item as a quest reward, so I'm not sure what it represents.

It's possible the containers you were checking were created by the player and retained that information for a while before being discarded by the server.

Last edited by semlar : 01-10-14 at 05:07 PM.
semlar is offline   Reply With Quote
Unread 01-10-14, 06:18 PM   #9
Simca
A Deviate Faerie Dragon
 
Simca's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2012
Posts: 12
Originally Posted by semlar View Post
I'm pretty sure the item link contains a unique ID for the container.

You could try something like this..
Lua Code:
  1. local uniqueID = GetContainerItemLink(0,1):match('item:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:([^:]+)')

And then cache that in a table to keep track of what's been opened.

The ID seems to persist between sessions so it shouldn't change while you're playing, but of course you'll need to do some testing to make sure.

Also, after some brief testing with a Bag of Shiny Things, the GUID from GetLootSourceInfo is completely unrelated to the player's GUID (0x4480000418D9CC0B for the bag and 0x0480000002D6F631 for the player). It's also not the GUID of the unit that gave me the item as a quest reward, so I'm not sure what it represents.

It's possible the containers you were checking were created by the player and retained that information for a while before being discarded by the server.
Interesting. I never actually checked the GUID against my own character's GUID - I just made the assumption because the third hex digit of both GUID is '8', which when you apply the proper bit mask is the identifier for 'players'.

I assumed this meant that you were just 'looting yourself' since you owned the bag. It seemed like the kind of simple workaround that Blizzard would use for an edge case scenario like this.

Also, items have a unique identifier built into the item links?! Mind = blown. Hero!

Edit: Looking on WoWProgramming, they list the field for uniqueID as 'optional' and say that the WoW server uses it for 'some items'. Any idea how extensive this use is?
__________________
Global Moderator for MMO-Champion

Last edited by Simca : 01-10-14 at 06:35 PM.
Simca is offline   Reply With Quote
Unread 01-10-14, 07:03 PM   #10
semlar
A Molten Giant
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 623
The unique ID field is mentioned on the itemString page on wowpedia with some theories about how it works and what it represents.

From my own observances it seems to be capable of identifying a particular stack of cloth in my inventory as it's moved around with a clearly distinct ID from other stacks. Splitting the stack results in 2 stacks with the same ID and dropping new items onto an existing stack kept the existing stack's ID.

As long as the containers aren't stackable I doubt any two will have the same ID, and I don't think any containers that produce a loot window can be stacked. Clams can be stacked but simply dump their contents into your inventory when clicked.

I have a feeling that containers will all have a unique ID because of their unique contents, but I really can't say definitively.

If all else fails, it should be possible to uniquely identify an item by its slot if you keep track of what's in every inventory slot and compare it to the previous entries every time it's updated.

For example, if I know which slots are containers and I loot a new container that's identical to an existing one, I can still tell the difference between them because the new one is in a different slot than the existing one.

When the bag update event fires I can check my table of known container slots to see if any are missing, then check the rest of the inventory slots to see if it's been moved (same container that's missing is in another slot) or destroyed (no other slots contain the missing container).

Last edited by semlar : 01-10-14 at 07:21 PM.
semlar is offline   Reply With Quote
Unread 01-10-14, 11:10 PM   #11
Simca
A Deviate Faerie Dragon
 
Simca's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2012
Posts: 12
Originally Posted by semlar View Post
The unique ID field is mentioned on the itemString page on wowpedia with some theories about how it works and what it represents.

From my own observances it seems to be capable of identifying a particular stack of cloth in my inventory as it's moved around with a clearly distinct ID from other stacks. Splitting the stack results in 2 stacks with the same ID and dropping new items onto an existing stack kept the existing stack's ID.

As long as the containers aren't stackable I doubt any two will have the same ID, and I don't think any containers that produce a loot window can be stacked. Clams can be stacked but simply dump their contents into your inventory when clicked.

I have a feeling that containers will all have a unique ID because of their unique contents, but I really can't say definitively.
Still, this is great. I don't have to entirely abandon the way I currently do it by GUID; I can set up code to always track the unique IDs (which will only take one additional table and one additional API command - not a big performance hit at all). Then, I can always look for the bug (if this is a locked item, we're looting it, and the GUID entry is blank, then...), and if it exists, I can fall back onto the unique ID system.

Even if the unique ID system isn't 100% present on every item, it will be accurate enough to cover these edge cases.

Cheers!
__________________
Global Moderator for MMO-Champion
Simca is offline   Reply With Quote
Unread 01-12-14, 10:38 AM   #12
pelf
Sentient Plasmoid
 
pelf's Avatar
Premium Member
Join Date: May 2008
Posts: 128
Did you put in a report with Blizzard?
pelf is offline   Reply With Quote
Unread 01-12-14, 04:35 PM   #13
Simca
A Deviate Faerie Dragon
 
Simca's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2012
Posts: 12
I haven't yet, but I'm considering it because I believe I found the 'real problem'. Sometimes in 5.4.2, LOOT_OPENED fires twice in a row. I don't know the cause of the double loot events.

Example series of events and why I thought the problem was different at first:
>0 ms: Beginning
>300 ms: I right-click corpse, some related events fire
>500 ms: LOOT_OPENED fires, loot window appears to me (but it is empty!), addon code runs here (since it is empty, the GUID is nil)
>700 ms: LOOT_OPENED fires again, loot appears in the window, addon code runs again here (but my code fails my own verification checks since LOOT_OPENED already fired and variables were reset)
>1500 ms: I decide to close the loot window
>1501 ms: LOOT_CLOSED fires
>1502 ms: LOOT_CLOSED fires (yes, a second time)

To the user, nothing really will seem amiss except for a split second (could be extremely small window at low latency) where the window will be blank.

This behavior may not be limited to items either. Because of my reliance on the GUID, the addon can account for 'weird' scenarios for objects and NPCs by extracting the objectID or NPCID from the GUID (so it will fail on the first LOOT_OPENED, but LOOT_OPENED #2 will process successfully because it can reconstruct the preset variables, even though they were reset by the first event). Since item container GUIDs do not contain the itemID of the container, my code there is different and is only able to fire on the first LOOT_OPENED event, which is why I had a problem because I never expected a bug which caused 'blank' duplicate events.
__________________
Global Moderator for MMO-Champion

Last edited by Simca : 01-12-14 at 04:39 PM.
Simca is offline   Reply With Quote
Unread 01-12-14, 04:39 PM   #14
semlar
A Molten Giant
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 623
I would assume LOOT_OPENED might fire for every corpse in range for AOE loot when it populates the window with their items.

It could very well fire simply from opening the loot window and again when it's populated.

If you know it has the potential to fire multiple times you'll just have to code around that.

Last edited by semlar : 01-12-14 at 04:47 PM.
semlar is offline   Reply With Quote
Unread 01-12-14, 04:52 PM   #15
Simca
A Deviate Faerie Dragon
 
Simca's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2012
Posts: 12
Originally Posted by semlar View Post
I would assume LOOT_OPENED might fire for every corpse in range for AOE loot when it populates the window with their items.

It could very well fire simply from opening the loot window and again when it's populated.

If you know it has the potential to fire multiple times you'll just have to code around that.
Yes, I should able to just use the 'backup' system that reconstructs NPCID/objectID and other variables from GUIDs for NPCs and objects, in a slightly modified form. Though you can't get the itemID of the container from the GUID, the item container will be 'locked' because it is in use, so the addon could scan the inventory for the locked item and get the itemID from that.

Still, I should make a bug report thread about this on the official forums now that I know what is happening (even if I don't know why).
__________________
Global Moderator for MMO-Champion
Simca is offline   Reply With Quote
Unread 01-12-14, 10:42 PM   #16
pelf
Sentient Plasmoid
 
pelf's Avatar
Premium Member
Join Date: May 2008
Posts: 128
Agreed .
pelf is offline   Reply With Quote
Unread 01-14-14, 10:29 PM   #17
Simca
A Deviate Faerie Dragon
 
Simca's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2012
Posts: 12
I just made the thread.

In case anyone wants to follow along: http://us.battle.net/wow/en/forum/topic/11223882881
__________________
Global Moderator for MMO-Champion
Simca is offline   Reply With Quote
Reply

Go BackWoWInterface » Developer Discussions » General Authoring Discussion » GetLootSourceInfo() Partially Broken in 5.4.2?

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off