From 0a5857b320b253834fe087f8818155f3793b925f Mon Sep 17 00:00:00 2001 From: Regisle Date: Wed, 8 Feb 2023 21:20:54 +1030 Subject: [PATCH 1/8] implement culling of variants while saving items --- src/Classes/Item.lua | 117 +++++++++++++++++++++++++++++++++------ src/Classes/ItemsTab.lua | 2 +- 2 files changed, 101 insertions(+), 18 deletions(-) diff --git a/src/Classes/Item.lua b/src/Classes/Item.lua index 7f11f0ee33..be445e5208 100644 --- a/src/Classes/Item.lua +++ b/src/Classes/Item.lua @@ -138,6 +138,7 @@ function ItemClass:ParseRaw(raw) local deferJewelRadiusIndexAssignment local gameModeStage = "FINDIMPLICIT" local foundExplicit, foundImplicit + local culledVariantsTemplate = nil local function processInfluenceLine(line) for i, curInfluenceInfo in ipairs(influenceInfo) do @@ -245,12 +246,17 @@ function ItemClass:ParseRaw(raw) if not self.variantList then self.variantList = { } end - -- This has to be kept for backwards compatibility - local ver, name = specVal:match("{([%w_]+)}(.+)") - if ver then - t_insert(self.variantList, name) + if specVal == "RebuildCulledVariants" and main.uniqueDB.list[self.name..", "..self.baseName] then + culledVariantsTemplate = main.uniqueDB.list[self.name..", "..self.baseName] + self.variantList = copyTable(culledVariantsTemplate.variantList) else - t_insert(self.variantList, specVal) + -- This has to be kept for backwards compatibility + local ver, name = specVal:match("{([%w_]+)}(.+)") + if ver then + t_insert(self.variantList, name) + else + t_insert(self.variantList, specVal) + end end elseif specName == "Talisman Tier" then self.talismanTier = tonumber(specVal) @@ -589,6 +595,47 @@ function ItemClass:ParseRaw(raw) self.requirements.level = self.base.req.level end end + -- rebuild mods list from template item + if culledVariantsTemplate then + if #self.implicitModLines > 0 then + local replacerModline = self.implicitModLines + self.implicitModLines = copyTable(culledVariantsTemplate.implicitModLines) + for _, modLine in ipairs(replacerModline) do + local modLineFound = false + for _, modLine2 in ipairs(self.implicitModLines) do + if modLine.line == modLine2.line then + modLine2.range = modLine.range + modLineFound = true + break + end + end + if not modLineFound then + t_insert(self.implicitModLines, modLine) + end + end + else + self.implicitModLines = culledVariantsTemplate.implicitModLines + end + if #self.explicitModLines > 0 then + local replacerModline = self.explicitModLines + self.explicitModLines = copyTable(culledVariantsTemplate.explicitModLines) + for _, modLine in ipairs(replacerModline) do + local modLineFound = false + for _, modLine2 in ipairs(self.explicitModLines) do + if modLine.line == modLine2.line then + modLine2.range = modLine.range + modLineFound = true + break + end + end + if not modLineFound then + t_insert(self.explicitModLines, modLine) + end + end + else + self.explicitModLines = culledVariantsTemplate.explicitModLines + end + end self.affixLimit = 0 if self.crafted then if not self.affixes then @@ -711,8 +758,9 @@ function ItemClass:CheckIfModIsDelve(mod) end -function ItemClass:BuildRaw() +function ItemClass:BuildRaw(cullVariants) local rawLines = { } + local cullVariantsTemplate = nil t_insert(rawLines, "Rarity: " .. self.rarity) if self.title then t_insert(rawLines, self.title) @@ -773,7 +821,24 @@ function ItemClass:BuildRaw() if self.itemLevel then t_insert(rawLines, "Item Level: " .. self.itemLevel) end - local function writeModLine(modLine) + local function variantValid(variantList) + for varId in pairs(variantList) do + if self.variant == varId then + return true + end + for _, AltVariant in ipairs({"", "2", "3", "4", "5"}) do + if self["hasAltVariant"..AltVariant] then + if self["variantAlt"..AltVariant] == varId then + return true + end + else + break + end + end + end + return false + end + local function writeModLine(modLine, modLineType) local line = modLine.line if modLine.range and line:match("%(%-?[%d%.]+%-%-?[%d%.]+%)") then line = "{range:" .. round(modLine.range, 3) .. "}" .. line @@ -804,6 +869,19 @@ function ItemClass:BuildRaw() for varId in pairs(modLine.variantList) do varSpec = (varSpec and varSpec .. "," or "") .. varId end + if cullVariantsTemplate then + if not variantValid(modLine.variantList) and ((not modLine.range) or modLine.range == main.defaultItemAffixQuality) then + if modLineType == "implicit" or modLineType == "explicit" then + for _, templateLine in ipairs(cullVariantsTemplate[modLineType.."ModLines"]) do + if templateLine.line == modLine.line then + return + end + end + else + return + end + end + end line = "{variant:" .. varSpec .. "}" .. line end if modLine.modTags and #modLine.modTags > 0 then @@ -812,13 +890,18 @@ function ItemClass:BuildRaw() t_insert(rawLines, line) end if self.variantList then - for _, variantName in ipairs(self.variantList) do - t_insert(rawLines, "Variant: " .. variantName) + if cullVariants and main.uniqueDB.list[self.title..", "..self.baseName] then + t_insert(rawLines, "Variant: " .. "RebuildCulledVariants") + cullVariantsTemplate = main.uniqueDB.list[self.title..", "..self.baseName] + else + for _, variantName in ipairs(self.variantList) do + t_insert(rawLines, "Variant: " .. variantName) + end end t_insert(rawLines, "Selected Variant: " .. self.variant) for _, baseLine in pairs(self.baseLines) do - writeModLine(baseLine) + writeModLine(baseLine, "baseLine") end if self.hasAltVariant then t_insert(rawLines, "Has Alt Variant: true") @@ -868,19 +951,19 @@ function ItemClass:BuildRaw() end t_insert(rawLines, "Implicits: " .. (#self.enchantModLines + #self.implicitModLines + #self.scourgeModLines)) for _, modLine in ipairs(self.enchantModLines) do - writeModLine(modLine) + writeModLine(modLine, "enchant") end for _, modLine in ipairs(self.scourgeModLines) do - writeModLine(modLine) + writeModLine(modLine, "scourge") end for _, modLine in ipairs(self.classRequirementModLines) do - writeModLine(modLine) + writeModLine(modLine, "classRequirement") end for _, modLine in ipairs(self.implicitModLines) do - writeModLine(modLine) + writeModLine(modLine, "implicit") end for _, modLine in ipairs(self.explicitModLines) do - writeModLine(modLine) + writeModLine(modLine, "explicit") end if self.split then t_insert(rawLines, "Split") @@ -894,8 +977,8 @@ function ItemClass:BuildRaw() return table.concat(rawLines, "\n") end -function ItemClass:BuildAndParseRaw() - local raw = self:BuildRaw() +function ItemClass:BuildAndParseRaw(cullVariants) + local raw = self:BuildRaw(cullVariants) self:ParseRaw(raw) end diff --git a/src/Classes/ItemsTab.lua b/src/Classes/ItemsTab.lua index 3ab3cb560c..b4811d6450 100644 --- a/src/Classes/ItemsTab.lua +++ b/src/Classes/ItemsTab.lua @@ -969,7 +969,7 @@ function ItemsTabClass:Save(xml) variantAlt5 = item.variantAlt5 and tostring(item.variantAlt5) } } - item:BuildAndParseRaw() + item:BuildAndParseRaw(true) t_insert(child, item.raw) local id = #item.buffModLines + 1 for _, modLine in ipairs(item.enchantModLines) do From 5fa0a4d60e1daa1905be3ff805740dca9befd7f5 Mon Sep 17 00:00:00 2001 From: Regisle Date: Wed, 8 Feb 2023 22:06:11 +1030 Subject: [PATCH 2/8] check that no mods have been changed before culling --- src/Classes/Item.lua | 45 ++++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/src/Classes/Item.lua b/src/Classes/Item.lua index be445e5208..62f2c1c610 100644 --- a/src/Classes/Item.lua +++ b/src/Classes/Item.lua @@ -821,6 +821,24 @@ function ItemClass:BuildRaw(cullVariants) if self.itemLevel then t_insert(rawLines, "Item Level: " .. self.itemLevel) end + local function templateItemMatchesCurrent() + if not main.uniqueDB.list[self.title..", "..self.baseName] or (#self.variantList ~= #main.uniqueDB.list[self.title..", "..self.baseName].variantList) then + return false + end + local templateItem = main.uniqueDB.list[self.title..", "..self.baseName] + for _, modLineType in ipairs({"enchant", "scourge", "classRequirement", "implicit", "explicit"}) do + if #self[modLineType.."ModLines"] ~= #templateItem[modLineType.."ModLines"] then + return false + end + for i, modLine in ipairs(self[modLineType.."ModLines"]) do + if templateItem[modLineType.."ModLines"][i].line ~= modLine.line then + return false + end + end + end + cullVariantsTemplate = templateItem + return true + end local function variantValid(variantList) for varId in pairs(variantList) do if self.variant == varId then @@ -838,7 +856,7 @@ function ItemClass:BuildRaw(cullVariants) end return false end - local function writeModLine(modLine, modLineType) + local function writeModLine(modLine) local line = modLine.line if modLine.range and line:match("%(%-?[%d%.]+%-%-?[%d%.]+%)") then line = "{range:" .. round(modLine.range, 3) .. "}" .. line @@ -871,15 +889,7 @@ function ItemClass:BuildRaw(cullVariants) end if cullVariantsTemplate then if not variantValid(modLine.variantList) and ((not modLine.range) or modLine.range == main.defaultItemAffixQuality) then - if modLineType == "implicit" or modLineType == "explicit" then - for _, templateLine in ipairs(cullVariantsTemplate[modLineType.."ModLines"]) do - if templateLine.line == modLine.line then - return - end - end - else - return - end + return end end line = "{variant:" .. varSpec .. "}" .. line @@ -890,9 +900,8 @@ function ItemClass:BuildRaw(cullVariants) t_insert(rawLines, line) end if self.variantList then - if cullVariants and main.uniqueDB.list[self.title..", "..self.baseName] then + if cullVariants and templateItemMatchesCurrent() then t_insert(rawLines, "Variant: " .. "RebuildCulledVariants") - cullVariantsTemplate = main.uniqueDB.list[self.title..", "..self.baseName] else for _, variantName in ipairs(self.variantList) do t_insert(rawLines, "Variant: " .. variantName) @@ -901,7 +910,7 @@ function ItemClass:BuildRaw(cullVariants) t_insert(rawLines, "Selected Variant: " .. self.variant) for _, baseLine in pairs(self.baseLines) do - writeModLine(baseLine, "baseLine") + writeModLine(baseLine) end if self.hasAltVariant then t_insert(rawLines, "Has Alt Variant: true") @@ -951,19 +960,19 @@ function ItemClass:BuildRaw(cullVariants) end t_insert(rawLines, "Implicits: " .. (#self.enchantModLines + #self.implicitModLines + #self.scourgeModLines)) for _, modLine in ipairs(self.enchantModLines) do - writeModLine(modLine, "enchant") + writeModLine(modLine) end for _, modLine in ipairs(self.scourgeModLines) do - writeModLine(modLine, "scourge") + writeModLine(modLine) end for _, modLine in ipairs(self.classRequirementModLines) do - writeModLine(modLine, "classRequirement") + writeModLine(modLine) end for _, modLine in ipairs(self.implicitModLines) do - writeModLine(modLine, "implicit") + writeModLine(modLine) end for _, modLine in ipairs(self.explicitModLines) do - writeModLine(modLine, "explicit") + writeModLine(modLine) end if self.split then t_insert(rawLines, "Split") From 59056dd8b3ae72caf7218b049c95767682248637 Mon Sep 17 00:00:00 2001 From: Regisle Date: Wed, 8 Feb 2023 23:06:01 +1030 Subject: [PATCH 3/8] fix catalyst --- src/Classes/Item.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Classes/Item.lua b/src/Classes/Item.lua index 62f2c1c610..ed1afc995d 100644 --- a/src/Classes/Item.lua +++ b/src/Classes/Item.lua @@ -605,6 +605,7 @@ function ItemClass:ParseRaw(raw) for _, modLine2 in ipairs(self.implicitModLines) do if modLine.line == modLine2.line then modLine2.range = modLine.range + modLine2.valueScalar = modLine.valueScalar modLineFound = true break end @@ -614,7 +615,7 @@ function ItemClass:ParseRaw(raw) end end else - self.implicitModLines = culledVariantsTemplate.implicitModLines + self.implicitModLines = copyTable(culledVariantsTemplate.implicitModLines) end if #self.explicitModLines > 0 then local replacerModline = self.explicitModLines @@ -624,6 +625,7 @@ function ItemClass:ParseRaw(raw) for _, modLine2 in ipairs(self.explicitModLines) do if modLine.line == modLine2.line then modLine2.range = modLine.range + modLine2.valueScalar = modLine.valueScalar modLineFound = true break end @@ -633,7 +635,7 @@ function ItemClass:ParseRaw(raw) end end else - self.explicitModLines = culledVariantsTemplate.explicitModLines + self.explicitModLines = copyTable(culledVariantsTemplate.explicitModLines) end end self.affixLimit = 0 From 02eceb2fc273aa2771bbddf8ac06879b2ebb259e Mon Sep 17 00:00:00 2001 From: Regisle Date: Thu, 9 Feb 2023 00:10:04 +1030 Subject: [PATCH 4/8] update variants so it can match updated variants --- src/Classes/Item.lua | 92 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 73 insertions(+), 19 deletions(-) diff --git a/src/Classes/Item.lua b/src/Classes/Item.lua index ed1afc995d..a7577f5cef 100644 --- a/src/Classes/Item.lua +++ b/src/Classes/Item.lua @@ -301,16 +301,76 @@ function ItemClass:ParseRaw(raw) self.hasAltVariant5 = true elseif specName == "Selected Variant" then self.variant = tonumber(specVal) + elseif specName == "Selected Variant Name" then + -- item varaints have changed, find same variant + if self.variantList[self.variant] ~= specVal then + for i, variantName in ipairs(self.variantList) do + if variantName == specVal then + self.variant = i + break + end + end + end elseif specName == "Selected Alt Variant" then self.variantAlt = tonumber(specVal) + elseif specName == "Selected Alt Variant Name" then + -- item varaints have changed, find same variant + if self.variantList[self.variantAlt] ~= specVal then + for i, variantName in ipairs(self.variantList) do + if variantName == specVal then + self.variantAlt = i + break + end + end + end elseif specName == "Selected Alt Variant Two" then self.variantAlt2 = tonumber(specVal) + elseif specName == "Selected Alt Variant Two Name" then + -- item varaints have changed, find same variant + if self.variantList[self.variantAlt2] ~= specVal then + for i, variantName in ipairs(self.variantList) do + if variantName == specVal then + self.variantAlt2 = i + break + end + end + end elseif specName == "Selected Alt Variant Three" then self.variantAlt3 = tonumber(specVal) + elseif specName == "Selected Alt Variant Three Name" then + -- item varaints have changed, find same variant + if self.variantList[self.variantAlt3] ~= specVal then + for i, variantName in ipairs(self.variantList) do + if variantName == specVal then + self.variantAlt3 = i + break + end + end + end elseif specName == "Selected Alt Variant Four" then self.variantAlt4 = tonumber(specVal) + elseif specName == "Selected Alt Variant Four Name" then + -- item varaints have changed, find same variant + if self.variantList[self.variantAlt4] ~= specVal then + for i, variantName in ipairs(self.variantList) do + if variantName == specVal then + self.variantAlt4 = i + break + end + end + end elseif specName == "Selected Alt Variant Five" then self.variantAlt5 = tonumber(specVal) + elseif specName == "Selected Alt Variant Five Name" then + -- item varaints have changed, find same variant + if self.variantList[self.variantAlt5] ~= specVal then + for i, variantName in ipairs(self.variantList) do + if variantName == specVal then + self.variantAlt5 = i + break + end + end + end elseif specName == "Has Variants" or specName == "Selected Variants" then -- Need to skip this line for backwards compatibility -- with builds that used an old Watcher's Eye implementation @@ -910,29 +970,23 @@ function ItemClass:BuildRaw(cullVariants) end end t_insert(rawLines, "Selected Variant: " .. self.variant) + if cullVariantsTemplate and self.variantList[#self.variantList] ~= "Current" then + t_insert(rawLines, "Selected Variant Name: " .. self.variantList[self.variant]) + end for _, baseLine in pairs(self.baseLines) do writeModLine(baseLine) end - if self.hasAltVariant then - t_insert(rawLines, "Has Alt Variant: true") - t_insert(rawLines, "Selected Alt Variant: " .. self.variantAlt) - end - if self.hasAltVariant2 then - t_insert(rawLines, "Has Alt Variant Two: true") - t_insert(rawLines, "Selected Alt Variant Two: " .. self.variantAlt2) - end - if self.hasAltVariant3 then - t_insert(rawLines, "Has Alt Variant Three: true") - t_insert(rawLines, "Selected Alt Variant Three: " .. self.variantAlt3) - end - if self.hasAltVariant4 then - t_insert(rawLines, "Has Alt Variant Four: true") - t_insert(rawLines, "Selected Alt Variant Four: " .. self.variantAlt4) - end - if self.hasAltVariant5 then - t_insert(rawLines, "Has Alt Variant Five: true") - t_insert(rawLines, "Selected Alt Variant Five: " .. self.variantAlt5) + for _, AltVariant in ipairs({{"", ""}, {"2", " Two"}, {"3", " Three"}, {"4", " Four"}, {"5", " Five"}}) do + if self["hasAltVariant" .. AltVariant[1]] then + t_insert(rawLines, "Has Alt Variant" .. AltVariant[2] .. ": true") + t_insert(rawLines, "Selected Alt Variant" .. AltVariant[2] .. ": " .. self["variantAlt" .. AltVariant[1]]) + if cullVariantsTemplate and self.variantList[#self.variantList] ~= "Current" then + t_insert(rawLines, "Selected Alt Variant" .. AltVariant[2] .. " Name: " .. self.variantList[self["variantAlt" .. AltVariant[1]]]) + end + else + break + end end end if self.quality then From 1b04e184870390ebc8d228ba6139e506db6b367a Mon Sep 17 00:00:00 2001 From: Regisle Date: Thu, 9 Feb 2023 00:28:34 +1030 Subject: [PATCH 5/8] apply cull to copying items --- src/Classes/ItemListControl.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Classes/ItemListControl.lua b/src/Classes/ItemListControl.lua index 40260af50f..3adebc8463 100644 --- a/src/Classes/ItemListControl.lua +++ b/src/Classes/ItemListControl.lua @@ -193,7 +193,7 @@ end function ItemListClass:OnSelCopy(index, itemId) local item = self.itemsTab.items[itemId] - Copy(item:BuildRaw():gsub("\n", "\r\n")) + Copy(item:BuildRaw(true):gsub("\n", "\r\n")) end function ItemListClass:OnSelDelete(index, itemId) From 8aaef80800ca634de68f1759a4b7c140c4d6bb5f Mon Sep 17 00:00:00 2001 From: Regisle Date: Thu, 9 Feb 2023 10:01:59 +1030 Subject: [PATCH 6/8] record last legacy variant and update variant to be legacy if it can --- src/Classes/Item.lua | 85 +++++++++++++++++--------------------------- 1 file changed, 32 insertions(+), 53 deletions(-) diff --git a/src/Classes/Item.lua b/src/Classes/Item.lua index a7577f5cef..2d153e611e 100644 --- a/src/Classes/Item.lua +++ b/src/Classes/Item.lua @@ -311,65 +311,36 @@ function ItemClass:ParseRaw(raw) end end end - elseif specName == "Selected Alt Variant" then - self.variantAlt = tonumber(specVal) - elseif specName == "Selected Alt Variant Name" then - -- item varaints have changed, find same variant - if self.variantList[self.variantAlt] ~= specVal then - for i, variantName in ipairs(self.variantList) do - if variantName == specVal then - self.variantAlt = i - break - end - end + elseif specName == "Selected Variant Last Legacy Variant" then + local curVariantName = self.variantList[self.variant] + while self.variant ~= 1 and self.variantList[self.variant - 1] ~= specVal and self.variantList[self.variant - 1]:match(curVariantName) do + self.variant = self.variant - 1 end - elseif specName == "Selected Alt Variant Two" then - self.variantAlt2 = tonumber(specVal) - elseif specName == "Selected Alt Variant Two Name" then - -- item varaints have changed, find same variant - if self.variantList[self.variantAlt2] ~= specVal then - for i, variantName in ipairs(self.variantList) do - if variantName == specVal then - self.variantAlt2 = i - break - end + elseif specName:match("Selected Alt Variant") then + local altVariantNumber = "" + for _, AltVariant in ipairs({{"2", " Two"}, {"3", " Three"}, {"4", " Four"}, {"5", " Five"}}) do + if specName:match(AltVariant[2]) then + altVariantNumber = AltVariant[1] + break end end - elseif specName == "Selected Alt Variant Three" then - self.variantAlt3 = tonumber(specVal) - elseif specName == "Selected Alt Variant Three Name" then - -- item varaints have changed, find same variant - if self.variantList[self.variantAlt3] ~= specVal then - for i, variantName in ipairs(self.variantList) do - if variantName == specVal then - self.variantAlt3 = i - break + if specName:match("Name") then + -- item varaints have changed, find same variant + if self.variantList[self["variantAlt"..altVariantNumber]] ~= specVal then + for i, variantName in ipairs(self.variantList) do + if variantName == specVal then + self["variantAlt"..altVariantNumber] = i + break + end end end - end - elseif specName == "Selected Alt Variant Four" then - self.variantAlt4 = tonumber(specVal) - elseif specName == "Selected Alt Variant Four Name" then - -- item varaints have changed, find same variant - if self.variantList[self.variantAlt4] ~= specVal then - for i, variantName in ipairs(self.variantList) do - if variantName == specVal then - self.variantAlt4 = i - break - end - end - end - elseif specName == "Selected Alt Variant Five" then - self.variantAlt5 = tonumber(specVal) - elseif specName == "Selected Alt Variant Five Name" then - -- item varaints have changed, find same variant - if self.variantList[self.variantAlt5] ~= specVal then - for i, variantName in ipairs(self.variantList) do - if variantName == specVal then - self.variantAlt5 = i - break - end + elseif specName:match("Last Legacy Variant") then + local curVariantName = self.variantList[self["variantAlt"..altVariantNumber]] + while self["variantAlt"..altVariantNumber] ~= 1 and self.variantList[self["variantAlt"..altVariantNumber] - 1] ~= specVal and self.variantList[self["variantAlt"..altVariantNumber] - 1]:match(curVariantName) do + self["variantAlt"..altVariantNumber] = self["variantAlt"..altVariantNumber] - 1 end + else + self["variantAlt"..altVariantNumber] = tonumber(specVal) end elseif specName == "Has Variants" or specName == "Selected Variants" then -- Need to skip this line for backwards compatibility @@ -972,6 +943,10 @@ function ItemClass:BuildRaw(cullVariants) t_insert(rawLines, "Selected Variant: " .. self.variant) if cullVariantsTemplate and self.variantList[#self.variantList] ~= "Current" then t_insert(rawLines, "Selected Variant Name: " .. self.variantList[self.variant]) + if not self.variantList[self.variant]:match(" %(Pre ") then + local lastVariant = self.variant ~= 1 and (self.variantList[self.variant - 1]:match(self.variantList[self.variant]) and self.variantList[self.variant - 1] or self.variantList[self.variant]) or self.variantList[self.variant] + t_insert(rawLines, "Selected Variant Last Legacy Variant: " .. lastVariant) + end end for _, baseLine in pairs(self.baseLines) do @@ -983,6 +958,10 @@ function ItemClass:BuildRaw(cullVariants) t_insert(rawLines, "Selected Alt Variant" .. AltVariant[2] .. ": " .. self["variantAlt" .. AltVariant[1]]) if cullVariantsTemplate and self.variantList[#self.variantList] ~= "Current" then t_insert(rawLines, "Selected Alt Variant" .. AltVariant[2] .. " Name: " .. self.variantList[self["variantAlt" .. AltVariant[1]]]) + if not self.variantList[self["variantAlt" .. AltVariant[1]]]:match(" %(Pre ") then + local lastVariant = self["variantAlt" .. AltVariant[1]] ~= 1 and (self.variantList[self["variantAlt" .. AltVariant[1]] - 1]:match(self.variantList[self["variantAlt" .. AltVariant[1]]]) and self.variantList[self["variantAlt" .. AltVariant[1]] - 1] or self.variantList[self["variantAlt" .. AltVariant[1]]]) or self.variantList[self["variantAlt" .. AltVariant[1]]] + t_insert(rawLines, "Selected Alt Variant" .. AltVariant[2] .. " Last Legacy Variant: " .. lastVariant) + end end else break From cc4fd96022c83169307d5de880ac19801d61c374 Mon Sep 17 00:00:00 2001 From: Regisle Date: Thu, 9 Feb 2023 10:06:30 +1030 Subject: [PATCH 7/8] dont save modrange anymore as its legacy --- src/Classes/ItemsTab.lua | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/src/Classes/ItemsTab.lua b/src/Classes/ItemsTab.lua index b4811d6450..916b54d855 100644 --- a/src/Classes/ItemsTab.lua +++ b/src/Classes/ItemsTab.lua @@ -971,31 +971,6 @@ function ItemsTabClass:Save(xml) } item:BuildAndParseRaw(true) t_insert(child, item.raw) - local id = #item.buffModLines + 1 - for _, modLine in ipairs(item.enchantModLines) do - if modLine.range then - t_insert(child, { elem = "ModRange", attrib = { id = tostring(id), range = tostring(modLine.range) } }) - end - id = id + 1 - end - for _, modLine in ipairs(item.scourgeModLines) do - if modLine.range then - t_insert(child, { elem = "ModRange", attrib = { id = tostring(id), range = tostring(modLine.range) } }) - end - id = id + 1 - end - for _, modLine in ipairs(item.implicitModLines) do - if modLine.range then - t_insert(child, { elem = "ModRange", attrib = { id = tostring(id), range = tostring(modLine.range) } }) - end - id = id + 1 - end - for _, modLine in ipairs(item.explicitModLines) do - if modLine.range then - t_insert(child, { elem = "ModRange", attrib = { id = tostring(id), range = tostring(modLine.range) } }) - end - id = id + 1 - end t_insert(xml, child) end for _, itemSetId in ipairs(self.itemSetOrderList) do From 0ef096c9e220d7fe1c795dbf47a8bed48f0b2a66 Mon Sep 17 00:00:00 2001 From: Regisle Date: Thu, 9 Feb 2023 10:22:07 +1030 Subject: [PATCH 8/8] fix spelling --- src/Classes/Item.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Classes/Item.lua b/src/Classes/Item.lua index 2d153e611e..693b142495 100644 --- a/src/Classes/Item.lua +++ b/src/Classes/Item.lua @@ -302,7 +302,7 @@ function ItemClass:ParseRaw(raw) elseif specName == "Selected Variant" then self.variant = tonumber(specVal) elseif specName == "Selected Variant Name" then - -- item varaints have changed, find same variant + -- item variants have changed, find same variant if self.variantList[self.variant] ~= specVal then for i, variantName in ipairs(self.variantList) do if variantName == specVal then @@ -325,7 +325,7 @@ function ItemClass:ParseRaw(raw) end end if specName:match("Name") then - -- item varaints have changed, find same variant + -- item variants have changed, find same variant if self.variantList[self["variantAlt"..altVariantNumber]] ~= specVal then for i, variantName in ipairs(self.variantList) do if variantName == specVal then @@ -629,9 +629,9 @@ function ItemClass:ParseRaw(raw) -- rebuild mods list from template item if culledVariantsTemplate then if #self.implicitModLines > 0 then - local replacerModline = self.implicitModLines + local replacerModLine = self.implicitModLines self.implicitModLines = copyTable(culledVariantsTemplate.implicitModLines) - for _, modLine in ipairs(replacerModline) do + for _, modLine in ipairs(replacerModLine) do local modLineFound = false for _, modLine2 in ipairs(self.implicitModLines) do if modLine.line == modLine2.line then @@ -649,9 +649,9 @@ function ItemClass:ParseRaw(raw) self.implicitModLines = copyTable(culledVariantsTemplate.implicitModLines) end if #self.explicitModLines > 0 then - local replacerModline = self.explicitModLines + local replacerModLine = self.explicitModLines self.explicitModLines = copyTable(culledVariantsTemplate.explicitModLines) - for _, modLine in ipairs(replacerModline) do + for _, modLine in ipairs(replacerModLine) do local modLineFound = false for _, modLine2 in ipairs(self.explicitModLines) do if modLine.line == modLine2.line then