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 percent progress validation and parsing #5381

Merged
merged 2 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions WeakAuras/Prototypes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -984,8 +984,8 @@ end
---@return boolean result
function WeakAuras.ValidateNumericOrPercent(info, val)
if val ~= nil and val ~= "" then
local percent = string.match(val, "(%d+)%%")
local number = percent and tonumber(percent) or tonumber(val)
local index = val:find("%% *$")
local number = index and tonumber(val:sub(1, index-1)) or tonumber(val)
if(not number or number >= 2^31) then
return false;
end
Expand Down
10 changes: 6 additions & 4 deletions WeakAuras/RegionTypes/RegionPrototype.lua
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,9 @@ local function SetProgressSource(self, progressSource)
end

local function SetAdjustedMin(self, adjustedMin)
local percent = string.match(adjustedMin, "(%d+)%%")
if percent then
local index = adjustedMin:find("%% *$")
if index then
local percent = adjustedMin:sub(1, index-1)
self.adjustedMinRelPercent = tonumber(percent) / 100
self.adjustedMin = nil
else
Expand All @@ -360,8 +361,9 @@ local function SetAdjustedMin(self, adjustedMin)
end

local function SetAdjustedMax(self, adjustedMax)
local percent = string.match(adjustedMax, "(%d+)%%")
if percent then
local index = adjustedMax:find("%% *$")
if index then
local percent = adjustedMax:sub(1, index-1)
self.adjustedMaxRelPercent = tonumber(percent) / 100
else
self.adjustedMax = tonumber(adjustedMax)
Expand Down