Skip to content

Commit

Permalink
Modify ScanTrade missing reagent link code
Browse files Browse the repository at this point in the history
  • Loading branch information
b-morgan committed Mar 20, 2024
1 parent 9bb653f commit 9b05ebe
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 23 deletions.
41 changes: 26 additions & 15 deletions Skillet.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,15 @@ Skillet.L = L
local GetAddOnMetadata = C_AddOns and C_AddOns.GetAddOnMetadata or GetAddOnMetadata
Skillet.version = GetAddOnMetadata("Skillet-Classic", "Version")
Skillet.interface = select(4, GetBuildInfo())
Skillet.build = (Skillet.interface < 11404 and "Classic") or (Skillet.interface < 20000 and "Classic2") or (Skillet.interface < 30000 and "BCC") or (Skillet.interface < 40000 and "Wrath") or "Retail"
Skillet.build = (Skillet.interface < 20000 and "Classic") or (Skillet.interface < 30000 and "BCC") or
(Skillet.interface < 40000 and "Wrath") or (Skillet.interface < 50000 and "Cata") or "Retail"
Skillet.project = WOW_PROJECT_ID
local isRetail = WOW_PROJECT_ID == WOW_PROJECT_MAINLINE
local isClassic = WOW_PROJECT_ID == WOW_PROJECT_CLASSIC
local isBCC = WOW_PROJECT_ID == WOW_PROJECT_BURNING_CRUSADE_CLASSIC
local isWrath = WOW_PROJECT_ID == WOW_PROJECT_WRATH_CLASSIC
-- local isCata = WOW_PROJECT_ID == WOW_PROJECT_CATA_CLASSIC
local isCata = true

Skillet.isCraft = false -- true for the Blizzard Craft UI, false for the Blizzard TradeSkill UI
Skillet.lastCraft = false -- help events know when to call ConfigureRecipeControls()
Expand Down Expand Up @@ -140,6 +143,7 @@ Skillet.unknownRecipe = {

function Skillet:DisableBlizzardFrame()
DA.DEBUG(0,"DisableBlizzardFrame()")
-- if isCata then return end
if self.BlizzardTradeSkillFrame == nil then
if (not IsAddOnLoaded("Blizzard_TradeSkillUI")) then
LoadAddOn("Blizzard_TradeSkillUI");
Expand All @@ -162,6 +166,7 @@ end

function Skillet:EnableBlizzardFrame()
DA.DEBUG(0,"EnableBlizzardFrame()")
-- if isCata then return end
if self.BlizzardTradeSkillFrame ~= nil then
if (not IsAddOnLoaded("Blizzard_TradeSkillUI")) then
LoadAddOn("Blizzard_TradeSkillUI");
Expand Down Expand Up @@ -1289,21 +1294,27 @@ function Skillet:SkilletShowWindow()
self.db.realm.skillDB[self.currentPlayer][self.currentTrade] = {}
end
if not self:RescanTrade() then
if TSM_API or ZygorGuidesViewerClassicSettings then
if TSM_API then
DA.MARK3(L["Conflict with the addon TradeSkillMaster"])
self.db.profile.TSM_API = true
end
if ZygorGuidesViewerClassicSettings then
DA.MARK3(L["Conflict with the addon Zygor Guides"])
self.db.profile.ZYGOR = true
if self.scanTradeReason == 1 then
if TSM_API or ZygorGuidesViewerClassicSettings then
if TSM_API then
DA.MARK3(L["Conflict with the addon TradeSkillMaster"])
self.db.profile.TSM_API = true
end
if ZygorGuidesViewerClassicSettings then
DA.MARK3(L["Conflict with the addon Zygor Guides"])
self.db.profile.ZYGOR = true
end
else
--
-- Changed from DA.CHAT because this state can happen before enough
-- TRADE_SKILL_UPDATE or CRAFT_UPDATE events have occurred.
--
DA.WARN(L["No headers, try again"])
end
else
--
-- Changed from DA.CHAT because this state can happen before enough
-- TRADE_SKILL_UPDATE or CRAFT_UPDATE events have occurred.
--
DA.WARN(L["No headers, try again"])
elseif self.scanTradeReason == 2 then
DA.WARN("Missing Reagent Links, try again")
elseif self.scanTradeReason == 3 then
DA.WARN("Missing Reagent Names, try again")
end
return
end
Expand Down
51 changes: 43 additions & 8 deletions SkilletData.lua
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,6 @@ local function ScanTrade()
return false
end
local lastHeader = nil
local gotNil = false
local currentGroup = nil
local mainGroup = Skillet:RecipeGroupNew(player,tradeID,"Blizzard")
mainGroup.locked = true
Expand Down Expand Up @@ -894,6 +893,8 @@ local function ScanTrade()
-- s = 0
-- end
local skillNameSeen = {}
local missingReagentLink = {}
local missingReagentName = {}
for i = s, numSkills, 1 do
local skillName, craftSubSpellName, skillType, numAvailable, isExpanded, subSpell, extra
if Skillet.isCraft then
Expand Down Expand Up @@ -1149,10 +1150,24 @@ local function ScanTrade()
reagentLink = GetTradeSkillReagentItemLink(i,j)
end
--DA.DEBUG(2,"ScanTrade: i= "..tostring(i)..", reagentLink= "..DA.PLINK(reagentLink))
reagentID = Skillet:GetItemIDFromLink(reagentLink)
--
-- If the reagent is not in the client's cache, the link will be nil.
-- This failure could be recovered with some fancy coding.
--
if reagentLink then
reagentID = Skillet:GetItemIDFromLink(reagentLink)
else
missingReagentLink[reagentName] = {}
missingReagentLink[reagentName].skillId = i
missingReagentLink[reagentName].reagentId = j
end
else
gotNil = true
break
--
-- The ...ReagentInfo call failed. Not sure if this can be recovered.
--
missingReagentName[recipeID] = {}
missingReagentName[recipeID].skillId = i
missingReagentName[recipeID].reagentId = j
end
reagentData[j] = {}
reagentData[j].id = reagentID
Expand All @@ -1173,14 +1188,24 @@ local function ScanTrade()
recipeDB[recipeID] = recipeString
elseif recipeDB[recipeID] ~= recipeString then
--
-- Another sanity check. A change of tradeID should have already been caught.
-- This entry doesn't match an existing entry. Check to see what is different
--
local oldTradeID, oldItemString, oldReagentString, oldToolString = string.split(" ",recipeDB[recipeID])
if oldItemString == itemString and oldReagentString == reagentString and oldToolString == toolString then
--
-- TradeID is different but everything else is the same
--
DA.WARN("ScanTrade: recipeID="..tostring(recipeID)..", oldTradeID="..tostring(oldTradeID)..", tradeID="..tostring(tradeID).." (match)")
elseif oldTradeID ~= tostring(tradeID) then
--
-- TradeID and something else is different
--
DA.WARN("ScanTrade: recipeID="..tostring(recipeID)..", oldTradeID="..tostring(oldTradeID)..", tradeID="..tostring(tradeID).." (no match)")
end
--
-- TradeID is good but something else is different.
-- This happens most often when a previous scan encountered a reagent item not cached yet
--
DA.WARN("ScanTrade: replacing recipeID="..tostring(recipeID)..", '"..tostring(recipeDB[recipeID]).."' with '"..tostring(recipeString).."'")
recipeDB[recipeID] = recipeString
end
Expand All @@ -1206,14 +1231,24 @@ local function ScanTrade()
--
-- return a boolean:
-- true means we got good data for this profession (skill)
-- false means there was no data available
-- false means there was no data available or missing data
-- Note: Enchanting (the only Craft) has no headers
--
if not Skillet.isCraft and numHeaders == 0 then
skillData.scanned = false
Skillet.scanTradeReason = 1
return false
end
if #missingReagentLink > 0 then
DA.DEBUG(2,"ScanTrade: missingReagentLink= "..DA.DUMP(missingReagentLink))
Skillet.scanTradeReason = 2
return false
end
if #missingReagentName > 0 then
DA.DEBUG(2,"ScanTrade: missingReagentName= "..DA.DUMP(missingReagentName))
Skillet.scanTradeReason = 3
return false
end
skillData.scanned = true
Skillet.scanTradeReason = nil
return true
end

Expand Down

0 comments on commit 9b05ebe

Please sign in to comment.