Skip to content

Commit d58f147

Browse files
committed
Add epsilon for slider value to avoid ambiguous modId on range boundary
1 parent 70f804f commit d58f147

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/Classes/Item.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,7 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
837837
end
838838
end
839839
end
840+
-- Use rolling Delta/Range in case one range is 1-3 and another is 1-100 so we get the finest precision possible
840841
local bestPrecisionDelta = 0
841842
local bestPrecisionRange = 0
842843
for value, range in line:gmatch("(%-?%d+%.?%d*)%((%-?%d+%.?%d*%-%-?%d+%.?%d*)%)") do
@@ -855,6 +856,7 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
855856
})
856857
self.pendingAffixList = {}
857858
else
859+
-- Use rolling Delta/Range in case one range is 1-3 and another is 1-100 so we get the finest precision possible
858860
local bestPrecisionDelta = 0
859861
local bestPrecisionRange = 0
860862
for value, range in line:gmatch("(%-?%d+%.?%d*)%((%-?%d+%.?%d*%-%-?%d+%.?%d*)%)") do

src/Classes/ItemsTab.lua

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1904,7 +1904,14 @@ function ItemsTabClass:UpdateAffixControl(control, item, type, outputTable, outp
19041904
end
19051905
if control.list[control.selIndex].haveRange then
19061906
control.slider.divCount = #control.list[control.selIndex].modList
1907-
control.slider.val = (isValueInArray(control.list[control.selIndex].modList, selAffix) - 1 + (item[outputTable][outputIndex].range or 0.5)) / control.slider.divCount
1907+
local index = isValueInArray(control.list[control.selIndex].modList, selAffix)
1908+
local range = item[outputTable][outputIndex].range or 0.5
1909+
-- Avoid exact integer boundary that slider:GetDivVal's ceil would assign to the previous segment
1910+
if range == 0 and index > 1 then
1911+
range = 1e-4
1912+
end
1913+
control.slider.val = (index - 1 + range) / control.slider.divCount
1914+
ConPrintf("Setting slider div count to "..control.slider.divCount.." with val "..control.slider.val .. " for mod ID ".. selAffix)
19081915
if control.slider.divCount == 1 then
19091916
control.slider.divCount = nil
19101917
end

0 commit comments

Comments
 (0)