Skip to content

Commit

Permalink
fix: lua errors in wpn imbue suggestion list
Browse files Browse the repository at this point in the history
  • Loading branch information
ascott18 committed Aug 24, 2024
1 parent bc385cb commit 7a86551
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 22 deletions.
10 changes: 9 additions & 1 deletion Components/Core/Common/Item.lua
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,16 @@ function ItemByID:GetName()
end
end
function ItemByID:GetLink()
-- It seems that around WoW 11.0, the game will "forget"
-- about items that it previously had returns for from GetItemInfo,
-- so use a cached return here if it comes back nil.
local _, itemLink = GetItemInfo(self.itemID)
return itemLink
if itemLink then
self.link = itemLink
return itemLink
else
return self.link
end
end


Expand Down
44 changes: 24 additions & 20 deletions Components/IconTypes/IconType_wpnenchant/Config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ Module.SpellIDs = TMW.isRetail and {
-- Shaman Enchants
318038, --Flametongue Weapon
33757, --Windfury Weapon
462757, -- Thunderstrike Ward
} or {}

local CurrentItems
Expand All @@ -130,27 +131,27 @@ function Module:OnInitialize()

for _, id in pairs(self.SpellIDs) do
local name = TMW.GetSpellName(id)
for _, enchant in TMW:Vararg(strsplit("|", L["SUG_MATCH_WPNENCH_ENCH"])) do
local dobreak
enchant = name:match(enchant)
local found = false
for _, enchantMatch in TMW:Vararg(strsplit("|", L["SUG_MATCH_WPNENCH_ENCH"])) do
local enchant = name:match(enchantMatch)
if enchant then
for ench in pairs(TMW.db.locale.WpnEnchDurs) do
if ench:lower():find(enchant:gsub("([%%%[%]%-%+])", "%%%1"):lower()) then
-- the enchant was found in the list of known enchants, so add it
self.Spells[ench] = id
dobreak = 1
found = true
break
end
end
if dobreak then
break
elseif GetLocale() ~= "ruRU" or (GetLocale() == "koKR" and id ~= 51730) then
-- the enchant was not found in the list of known enchants, so take a guess and add it (but not for ruRU because it is just screwed up
-- koKR is screwed up for earthliving, so dont try it either
self.Spells[enchant] = id
if not found then
self.Spells[enchant] = id
found = true
end
end
end
if not found then
self.Spells[name] = id
end
end

for k, v in pairs(self.Spells) do
Expand Down Expand Up @@ -188,10 +189,11 @@ function Module:GET_ITEM_INFO_RECEIVED(event, id)
-- This prevents the infinite loop.
if gotItemInfo[id] then return end
gotItemInfo[id] = true

local name, link = GetItemInfo(id)
if name then
self.Items[name] = link

local item = TMW.C.Item:GetRepresentation(id)
if item:GetLink() then
local name = item:GetName()
self.Items[name] = item
self.Table[name] = id
else
print("wpnenchant SUG: WoW Server seems to think that item doesn't exist", id)
Expand All @@ -202,9 +204,10 @@ function Module:Etc_DoItemLookups()
self:UnregisterEvent("GET_ITEM_INFO_RECEIVED")

for k, id in pairs(self.ItemIDs) do
local name, link = GetItemInfo(id)
if name then
self.Items[name] = link
local item = TMW.C.Item:GetRepresentation(id)
if item:GetLink() then
local name = item:GetName()
self.Items[name] = item
else
self:RegisterEvent("GET_ITEM_INFO_RECEIVED")
end
Expand Down Expand Up @@ -235,8 +238,9 @@ function Module:Entry_AddToList_1(f, name)

f.insert = name
elseif self.Items[name] then
local link = CurrentItems[strlowerCache[name]] or self.Items[name]
local name, link = GetItemInfo(link)
local item = self.Items[name]
local name = item:GetName()
local link = item:GetLink()

f.Name:SetText(link:gsub("[%[%]]", ""))
f.ID:SetText(nil)
Expand All @@ -261,7 +265,7 @@ function Module:Etc_GetTexture(name)
if self.Spells[name] then
tex = TMW.GetSpellTexture(self.Spells[name])
elseif self.Items[name] then
tex = GetItemIcon(self.Items[name])
tex = self.Items[name]:GetIcon()
else
if name:match(L["SUG_PATTERNMATCH_FISHINGLURE"]) then
tex = "Interface\\Icons\\inv_fishingpole_02"
Expand Down
2 changes: 1 addition & 1 deletion Components/IconTypes/IconType_wpnenchant/wpnenchant.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ local Type = TMW.Classes.IconType:New("wpnenchant")
LibStub("AceTimer-3.0"):Embed(Type)
Type.name = L["ICONMENU_WPNENCHANT"]
Type.desc = L["ICONMENU_WPNENCHANT_DESC"]
Type.menuIcon = TMW.GetSpellTexture(8024)
Type.menuIcon = TMW.GetSpellTexture(8024) or TMW.GetSpellTexture(318038)
Type.AllowNoName = true
Type.menuSpaceAfter = true

Expand Down

0 comments on commit 7a86551

Please sign in to comment.