Skip to content

Commit

Permalink
Fix remaining time condition with modRate < 1
Browse files Browse the repository at this point in the history
If modRate is > 1 (time is slow down) checks at L151, L377 & L383 may skip the reschedule
  • Loading branch information
mrbuds committed Sep 29, 2023
1 parent 491e75a commit 6bb9252
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions WeakAuras/Conditions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ function Private.ExecEnv.CancelConditionCheck(uid, cloneId)
end
end

function Private.ExecEnv.ScheduleConditionCheck(time, uid, cloneId)
function Private.ExecEnv.ScheduleConditionCheck(time, uid, cloneId, modRate)
conditionChecksTimers.recheckTime[uid] = conditionChecksTimers.recheckTime[uid] or {}
conditionChecksTimers.recheckHandle[uid] = conditionChecksTimers.recheckHandle[uid] or {};

Expand All @@ -162,7 +162,7 @@ function Private.ExecEnv.ScheduleConditionCheck(time, uid, cloneId)
checkConditions[uid](region);
Private.ActivateAuraEnvironment()
end
end, time - GetTime())
end, (time - GetTime()) / (modRate or 1.0))
conditionChecksTimers.recheckTime[uid][cloneId] = time;
end
end
Expand Down Expand Up @@ -375,11 +375,13 @@ local function CreateTestForCondition(uid, input, allConditionsTemplate, usedSta
.. " and state[" .. trigger .. "]" .. string.format("[%q]", variable)
.. " and (state[" .. trigger .. "]" .. string.format("[%q]", variable) .. " - " .. value .. ")\n"
recheckCode = recheckCode .. " if (nextTime and (not recheckTime or nextTime < recheckTime) and nextTime >= now) then\n"
recheckCode = recheckCode .. " modRate = (state[" .. trigger .. "].modRate or 1.0)\n";
recheckCode = recheckCode .. " recheckTime = nextTime\n";
recheckCode = recheckCode .. " end\n"
elseif (cType == "elapsedTimer" and value) then
recheckCode = " nextTime = state[" .. trigger .. "] and state[" .. trigger .. "]" .. string.format("[%q]", variable) .. " and (state[" .. trigger .. "]" .. string.format("[%q]", variable) .. " +" .. value .. ")\n";
recheckCode = recheckCode .. " if (nextTime and (not recheckTime or nextTime < recheckTime) and nextTime >= now) then\n"
recheckCode = recheckCode .. " modRate = (state[" .. trigger .. "].modRate or 1.0)\n";
recheckCode = recheckCode .. " recheckTime = nextTime\n";
recheckCode = recheckCode .. " end\n"
end
Expand Down Expand Up @@ -675,7 +677,7 @@ local function ConstructConditionFunction(data)
ret = ret .. " local state = region.states\n"
ret = ret .. " local activatedConditions = WeakAuras.GetActiveConditions(id, cloneId)\n";
ret = ret .. " wipe(newActiveConditions)\n";
ret = ret .. " local recheckTime;\n"
ret = ret .. " local recheckTime, modRate;\n"
ret = ret .. " local now = GetTime();\n"

-- First Loop gather which conditions are active
Expand All @@ -696,7 +698,7 @@ local function ConstructConditionFunction(data)
ret = ret .. " end\n";

ret = ret .. " if (recheckTime) then\n"
ret = ret .. " Private.ExecEnv.ScheduleConditionCheck(recheckTime, uid, cloneId);\n"
ret = ret .. " Private.ExecEnv.ScheduleConditionCheck(recheckTime, uid, cloneId, modRate);\n"
ret = ret .. " else\n"
ret = ret .. " Private.ExecEnv.CancelConditionCheck(uid, cloneId)"
ret = ret .. " end\n"
Expand Down

0 comments on commit 6bb9252

Please sign in to comment.