Skip to content

Commit d550ec2

Browse files
LocalIdentityLocalIdentity
andauthored
Fix crash on adding legacy shared items (#2280)
Some base types have changed names between updates so the old item no longer works. We were not checking that the base still exists before trying to render the tooltip for them Now adds specific popup just for these items so that it doesn't run the other tooltip code and cause a crash Co-authored-by: LocalIdentity <localidentity2@gmail.com>
1 parent 3c2612f commit d550ec2

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

spec/System/TestItemMods_spec.lua

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,20 @@ describe("TetsItemMods", function()
3333
assert.are.equals(2, legacyLines)
3434
end)
3535

36+
it("shows a fallback tooltip when an item's base is no longer supported", function()
37+
local item = new("Item", [[
38+
Rarity: Unique
39+
Legacy Item
40+
Removed Base
41+
]])
42+
local tooltip = new("Tooltip")
43+
44+
assert.has_no.errors(function()
45+
build.itemsTab:AddItemTooltip(tooltip, item)
46+
end)
47+
assert.is_truthy(tooltip.lines[#tooltip.lines].text:find("Item base is not supported", 1, true))
48+
end)
49+
3650
it("aggregates matching ring item rarity lines before applying ring bonus effect", function()
3751
build.configTab.input.customMods = "30% increased bonuses gained from left Equipped Ring"
3852
build.configTab:BuildModList()

src/Classes/ItemsTab.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3232,6 +3232,13 @@ function ItemsTabClass:AddItemTooltip(tooltip, item, slot, dbMode, maxWidth)
32323232
tooltip.tooltipHeader = item.rarity
32333233
tooltip.center = true
32343234
tooltip.color = rarityCode
3235+
-- Shared items can use old base names that no longer exist. Add a tooltip so they can be copied or removed without causing a crash.
3236+
if not item.base or not item.baseName then
3237+
tooltip:AddLine(fontSizeTitle, rarityCode..(item.title or item.name or "Unknown Item"), "FONTIN SC")
3238+
tooltip:AddSeparator(30)
3239+
tooltip:AddLine(fontSizeTitle, colorCodes.NEGATIVE.."Item base is not supported by the current version.", "FONTIN SC")
3240+
return
3241+
end
32353242
-- Item name
32363243
if item.title then
32373244
tooltip:AddLine(fontSizeTitle, rarityCode..item.title, "FONTIN SC")

0 commit comments

Comments
 (0)