Thread Tools Display Modes
04-22-09, 09:01 AM   #1
Telarin
A Murloc Raider
Join Date: Apr 2009
Posts: 8
GetTradeSkillReagentInfo freezes client

Ok, I am trying to do what should be a relatively simple task, which is iterate through a set of tradeskill reagents, and calculate some information based off them. Here is what I have:

The variable "i" is an index that goes through each TradeSkill line, excluding headers.

Code:
numReagent = GetTradeSkillNumReagents(i)
for r = 1, numReagents do
  local reagentLink = GetTradeSkillReagentItemLink(i,r);
  local _,_,reagentCount = GetTradeSkillReagentInfo(i,r);
end
This little bit of code locks the client up completely, and I have to do an "End Task" from the Task Manager. If I comment out the second line inside the loop (local _,_,reagentcount = GetTradeSkillReagentInfo(i,r); ), then the code runs through within a few seconds, and there are no problems.

Any idea what might be causing this to happen? Any idea if there are any workarounds for this problem that will allow me to get the reagentCount for a particular Trade Skill Reagent?
  Reply With Quote
04-22-09, 12:31 PM   #2
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
I'm wondering why you need to look up the reagent's itemlink, when you're not using it at all inside the loop, and using it outside of the loop is impossible since it's been declared as local.

As to your problem: This may be due to the fact that you're not accounting for all of the return values - you're catching three of four. They are:

Code:
reagentName, reagentTexture, reagentCount, playerReagentCount = GetTradeSkillReagentInfo(tradeSkillRecipeId, reagentId);
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
04-22-09, 01:52 PM   #3
Telarin
A Murloc Raider
Join Date: Apr 2009
Posts: 8
I actually am using all of the values that I have retrieved there. However, everything except those two lines of code is currently commented out in order to narrow down the problem function.

Apparently it has something to do with calling GetTradeSkillReagentItemLink and GetTradeSkillReagentInfo so close together with the same indexes. I worked around it by calling GetTradeSkillReagentInfo first, then calling GetItemInfo with the reagent name returned by GetTradeSkillReagentInfo. Not exactly elegant, but it seems to work without freezing the client.
  Reply With Quote
04-22-09, 03:19 PM   #4
Telarin
A Murloc Raider
Join Date: Apr 2009
Posts: 8
Nevermind, the GetItemInfo method does not work as well as it first appeared, since it returns nil for any reagents that aren't currently in the clients item cache.
  Reply With Quote
04-22-09, 03:51 PM   #5
Telarin
A Murloc Raider
Join Date: Apr 2009
Posts: 8
Ok, basically what was happening is that this code was triggered by the TRADESKILL_UPDATE event. If there was already an update in progress, and WoW fired a second update, things went horribly wrong. I simply added some basic locking code so that it could only run the updates one at a time.

essentially:

Code:
if (isLocked) return; end
isLocked = true;
-- update code here
isLocked = false;
This seems to have solved the issue.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » GetTradeSkillReagentInfo freezes client


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