Quantcast

Updated version to .13

pschifferer [10-15-09 - 04:26]
Updated version to .13
Changed the skill learner to batch skills learned in groups of 25, so that the client gets a
breather every so often when learning a large list of skills, and the UI doesn't become unresponsive.
Fixed a possible issue with horked reagent information that would cause the queue handler to
fail on some intermediate items.  A (hopefully) useful error is now given to the user to easily
identify the location of the problem.
Filename
Cauldron.toc
CauldronMain.lua
CauldronQueue.lua
CauldronTradeskill.lua
diff --git a/Cauldron.toc b/Cauldron.toc
index aa56e77..9363138 100755
--- a/Cauldron.toc
+++ b/Cauldron.toc
@@ -1,6 +1,6 @@
 ## Interface: 30100
 ## Title: Cauldron |cff7fff7f -Ace3-|r
-## Version: 0.9.12.@project-revision@
+## Version: 0.9.13.@project-revision@
 ## Author: Caendra of Silver Hand
 ## Notes: An improved interface for your trade skills
 ## RequiredDeps:
diff --git a/CauldronMain.lua b/CauldronMain.lua
index d67e062..599768c 100644
--- a/CauldronMain.lua
+++ b/CauldronMain.lua
@@ -4,7 +4,7 @@
 Cauldron = LibStub("AceAddon-3.0"):NewAddon("Cauldron", "AceEvent-3.0", "AceTimer-3.0", "AceConsole-3.0", "AceHook-3.0", "LibLogger-1.0");
 local L = LibStub("AceLocale-3.0"):GetLocale("Cauldron");

-Cauldron.version = "0.9.12.@project-revision@";
+Cauldron.version = "0.9.13.@project-revision@";
 Cauldron.date = string.sub("$Date$", 8, 17);

 -- key binding names
@@ -637,6 +637,17 @@ function Cauldron:ProcessQueue()
 		self:error("Can't process queue for linked tradeskill!");
 		return;
 	end
+
+	--[[ TODO: update queue logic
+	-- look at first item, if it can be made, make it (lower of queued quantity vs. quantity able to make)
+	-- if items other than first can be made and first can't, ask user if they want to make that instead
+	--]]
+
+	-- see if first item can be made
+	-- TODO
+
+	-- see if queue contains other items that can be made if the first can't be
+	-- TODO

 	-- find intermediate items that need to be crafted
 	local intQueue = CauldronQueue:GetIntermediates(self.db.realm.userdata[self.vars.playername].queue);
diff --git a/CauldronQueue.lua b/CauldronQueue.lua
index 7cf658f..ede9aab 100644
--- a/CauldronQueue.lua
+++ b/CauldronQueue.lua
@@ -271,7 +271,12 @@ function CauldronQueue:AddIntermediate(queue, reagent, amount)
 		local skillInfo = Cauldron:GetSkillInfoForItem(reagent.name);

 		-- it's not there, so create a new instance
-		queue.intermediate[reagent.name] = CauldronQueue:NewItem(reagent.name, reagent.icon, amount, nil, skillInfo.tradeskill, reagent.link);
+		if reagent.name then
+			queue.intermediate[reagent.name] = CauldronQueue:NewItem(reagent.name, reagent.icon, amount, nil, skillInfo.tradeskill, reagent.link);
+		else
+			-- this shouldn't occur unless there's something wrong with the reagent info, but if it does, the user can report this error
+			Cauldron:error("AddIntermediate: reagent.name is nil!");
+		end
 	end

 end
@@ -297,7 +302,12 @@ function CauldronQueue:AddReagent(queue, reagent, amount, tradeskill)
 		item.amount = (tonumber(item.amount) or 0) + amount;
 	else
 		-- it's not there, so create a new instance
-		queue.reagents[reagent.name] = CauldronQueue:NewReagent(reagent.name, reagent.icon, amount, tradeskill, reagent.link);
+		if reagent.name then
+			queue.reagents[reagent.name] = CauldronQueue:NewReagent(reagent.name, reagent.icon, amount, tradeskill, reagent.link);
+		else
+			-- this shouldn't occur unless there's something wrong with the reagent info, but if it does, the user can report this error
+			Cauldron:error("AddReagent: reagent.name is nil!");
+		end
 	end

 end
diff --git a/CauldronTradeskill.lua b/CauldronTradeskill.lua
index 21a1710..10bb100 100644
--- a/CauldronTradeskill.lua
+++ b/CauldronTradeskill.lua
@@ -56,9 +56,24 @@ function Cauldron:UpdateSkills()
 	SetTradeSkillItemNameFilter(nil);
 	SetTradeSkillItemLevelFilter(0, 0);

-	local category = "";
+	local category = self.skillCategory;
+	if not category then
+		category = "";
+	end
+
+	local first = self.skillStart;
+	if not first then
+		first = 1;
+	end
+	local last = self.skillEnd;
+	local total = GetNumTradeSkills();
+	local increment = 25;
+	if not last then
+		last = math.min(increment, total);
+	end

-	for i=1,GetNumTradeSkills() do
+--	for i=1,GetNumTradeSkills() do
+	for i=first,last do
 		local name, difficulty, avail, expanded, verb = GetTradeSkillInfo(i);
 --		self:debug("UpdateSkills: name="..name.."; difficulty="..difficulty.."; avail="..avail);

@@ -189,6 +204,21 @@ function Cauldron:UpdateSkills()
 			end
 		end
 	end
+
+	-- increment the counters
+	first = first + increment;
+	last = last + increment;
+	-- check if we need to queue the next batch
+	if first < total then
+		-- update the counter storage variables
+		self.skillStart = first;
+		self.skillEnd = last;
+		self.skillCategory = category;
+
+		-- set the timer
+		self:ScheduleTimer(self.UpdateSkills,1,self);
+--		self:UpdateSkillList();
+	end

 	self:debug("UpdateSkills exit");
 end