Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue parsing certain item bases #5452

Merged
merged 1 commit into from
Dec 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions src/Classes/Item.lua
Original file line number Diff line number Diff line change
Expand Up @@ -398,19 +398,22 @@ function ItemClass:ParseRaw(raw)
if data.itemBases[self.name] then
baseName = self.name
else
local bestMatch = {length = -1}
-- Partial match (magic items with affixes)
for itemBaseName, baseData in pairs(data.itemBases) do
local s, e = self.name:find(itemBaseName, 1, true)
if s then
-- Set the base name if it isn't there, or we found a better match, so replace it
if (baseName and string.len(self.namePrefix) > string.len(self.name:sub(1, s - 1)))
or baseName == nil then
self.namePrefix = self.name:sub(1, s - 1)
self.nameSuffix = self.name:sub(e + 1)
baseName = itemBaseName
end
if s and e and (e-s > bestMatch.length) then
bestMatch.match = itemBaseName
bestMatch.length = e-s
bestMatch.e = e
bestMatch.s = s
end
end
if bestMatch.match then
self.namePrefix = self.name:sub(1, bestMatch.s - 1)
self.nameSuffix = self.name:sub(bestMatch.e + 1)
baseName = bestMatch.match
end
end
if not baseName then
local s, e = self.name:find("Two-Toned Boots", 1, true)
Expand Down