From 63f55940b532834792ecf1016c9cca4536bde285 Mon Sep 17 00:00:00 2001 From: torhal Date: Fri, 29 May 2009 10:14:35 +0000 Subject: [PATCH] Fixed waypoint generation. --- ARLFrame.lua | 27 +++++++++++++++++---------- AckisRecipeList.lua | 39 ++++++++++++++++++++++++++------------- 2 files changed, 43 insertions(+), 23 deletions(-) diff --git a/ARLFrame.lua b/ARLFrame.lua index 8e4fc81..8ec15c2 100644 --- a/ARLFrame.lua +++ b/ARLFrame.lua @@ -69,7 +69,7 @@ local IsControlKeyDown = IsControlKeyDown local currentProfIndex = 0 local currentProfession = "" local maxVisibleRecipes = 24 -local FilterValueMap -- Assigned in InitializeFrame() +local FilterValueMap = {} -- Assigned in InitializeFrame() local DisplayStrings = {} local myFaction = "" @@ -77,12 +77,18 @@ local myFaction = "" -- Tables assigned in addon:DisplayFrame() ------------------------------------------------------------------------------- -- local versions of the databases storing the recipe information, trainers, vendors, etc -local recipeDB, trainerDB, vendorDB -local questDB, repDB, seasonDB -local customDB, mobDB, allSpecTable -local playerData +local recipeDB = {} +local trainerDB = {} +local vendorDB = {} +local questDB = {} +local repDB = {} +local seasonDB = {} +local customDB = {} +local mobDB = {} +local allSpecTable = {} +local playerData = {} -local sortedRecipeIndex +local sortedRecipeIndex = {} local seasonal = GetCategoryInfo(155) @@ -426,7 +432,7 @@ do TomTom:RemoveWaypoint(iconlist[i]) end -- Nuke our own internal table - twipe(iconlist) + iconlist = twipe(iconlist) end end @@ -454,8 +460,6 @@ do -- Expected result: Icons are added to the world map and mini-map. -- Input: An optional recipe ID -- Output: Points are added to the maps - local maplist = {} - function addon:SetupMap(singlerecipe) if (not TomTom) then --@debug@ @@ -480,7 +484,7 @@ do break end end - twipe(maplist) + local maplist = {} -- We're only getting a single recipe, not a bunch if (singlerecipe) then @@ -4863,6 +4867,9 @@ function addon:DisplayFrame( -- Set the texture on our switcher button correctly SetSwitcherTexture(SortedProfessions[currentProfIndex].texture) + -- Sort the list + sortedRecipeIndex = addon:SortMissingRecipes(recipeDB) + -- Take our sorted list, and fill up DisplayStrings initDisplayStrings() diff --git a/AckisRecipeList.lua b/AckisRecipeList.lua index 403adfc..29ade10 100644 --- a/AckisRecipeList.lua +++ b/AckisRecipeList.lua @@ -464,9 +464,6 @@ do local CollapseFactionHeader = CollapseFactionHeader local ExpandFactionHeader = ExpandFactionHeader - local t = {} - - -- Description: Scans all reputations to get reputation levels to determine if the player can learn a reputation recipe function addon:GetFactionLevels(RepTable) @@ -475,6 +472,7 @@ do if (not RepTable) then return end + local t = {} -- Number of factions before we expand local numfactions = GetNumFactions() @@ -603,7 +601,7 @@ function addon:addTradeSkill(RecipeDB, SpellID, SkillLevel, ItemID, Rarity, Prof --]] -- Creates a table in the RecipeListing table storing all information about a recipe - RecipeDB[SpellID] = RecipeDB[SpellID] or {} + RecipeDB[SpellID] = {} local recipeentry = RecipeDB[SpellID] @@ -819,7 +817,7 @@ function addon:addLookupList(DB, ID, Name, Loc, Coordx, Coordy, Faction) For individual database structures, see Documentation.lua ]]-- - DB[ID] = DB[ID] or {} + DB[ID] = {} DB[ID]["Name"] = Name if (Loc) then @@ -933,7 +931,7 @@ end do - local reptable + local reptable = nil local function CreateRepTable() @@ -1646,8 +1644,8 @@ do local tradewindowopened = false -- Variables for getting the locations - local locationlist = {} - local locationchecklist = {} + local locationlist = nil + local locationchecklist = nil -- Description: Determines all the locations a given recipe can be obtained @@ -1655,8 +1653,8 @@ do if (RecipeList) and (RecipeList[SpellID]) then - twipe(locationlist) - twipe(locationchecklist) + locationlist = {} + locationchecklist = {} local recipeacquire = RecipeList[SpellID]["Acquire"] @@ -2053,8 +2051,8 @@ end ]]-- do - local sortFuncs -- Sorting functions - local SortedRecipeIndex = {} -- Array for the sorted index + -- Sorting functions + local sortFuncs = nil -- Description: Sorts the recipe Database depending on the settings defined in the database. function addon:SortMissingRecipes(RecipeDB) @@ -2094,8 +2092,23 @@ do return not not reca end end + + -- Will only sort based off of the first acquire type + sortFuncs["Location"] = function (a, b) + -- We do the or "" because of nil's, I think this would be better if I just left it as a table which was returned + local reca = RecipeDB[a]["Locations"] or "" + local recb = RecipeDB[b]["Locations"] or "" + reca = smatch(reca,"(%w+),") or "" + recb = smatch(recb,"(%w+),") or "" + if (reca == recb) then + return RecipeDB[a]["Name"] < RecipeDB[b]["Name"] + else + return (reca < recb) + end + end end - twipe(SortedRecipeIndex) + -- Create a new array for the sorted index + local SortedRecipeIndex = {} -- Get all the indexes of the RecipeListing for n, v in pairs(RecipeDB) do -- 1.7.9.5