Skip to content

Commit

Permalink
Core: debug timer refreshes accounting for variance
Browse files Browse the repository at this point in the history
  • Loading branch information
Zidras committed Dec 8, 2024
1 parent 80f86f0 commit 7b7ccd1
Showing 1 changed file with 53 additions and 15 deletions.
68 changes: 53 additions & 15 deletions DBM-Core/DBM-Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ local function currentFullDate()
end

DBM = {
Revision = parseCurseDate("20241208193735"),
Revision = parseCurseDate("20241208222924"),
DisplayVersion = "10.1.13 alpha", -- the string that is shown as version
ReleaseRevision = releaseDate(2024, 07, 20) -- the date of the latest stable version that is available, optionally pass hours, minutes, and seconds for multiple releases in one day
}
Expand Down Expand Up @@ -10009,6 +10009,20 @@ do
return -- Invalid input
end

local function correctWithVarianceDuration(numberToCorrect, timerBar)
if not numberToCorrect then
DBM:Debug("|cffff0000No number passed to correctWithVarianceDuration function.|r")
return
end

if not timerBar then
DBM:Debug("|cffff0000No timerBar passed to correctWithVarianceDuration function.|r")
return numberToCorrect
end

return timerBar.hasVariance and (numberToCorrect + timerBar.varianceDuration) or numberToCorrect
end

function timerPrototype:Start(timer, ...)
if not self.mod.isDummyMod then--Don't apply following rulesets to pull timers and such
if DBM.Options.DontShowBossTimers and not self.mod.isTrashMod then return end
Expand All @@ -10029,17 +10043,29 @@ do
local bar = DBT:GetBar(self.startedTimers[i])
if bar then
local remaining = ("%.2f"):format(bar.timer)
local deltaFromVarianceMinTimer = ("%.2f"):format(bar.hasVariance and bar.timer - bar.varianceDuration or bar.timer)
local ttext = _G[bar.frame:GetName().."BarName"]:GetText() or ""
ttext = ttext.."("..self.id..")"
if mabs(bar.timer) > 0.1 then -- Positive and Negative ("keep") timers. Also shortened time window
local phaseText = self.mod.vb.phase and " ("..L.SCENARIO_STAGE:format(self.mod.vb.phase)..")" or ""
if DBM.Options.BadTimerAlert and bar.timer > 1 then--If greater than 1 seconds off, report this out of debug mode to all users
DBM:AddMsg("Timer "..ttext..phaseText.. " refreshed before expired. Remaining time is : "..remaining..". Please report this bug")
fireEvent("DBM_Debug", "Timer "..ttext..phaseText.. " refreshed before expired. Remaining time is : "..remaining..". Please report this bug", 2)
elseif bar.timer < -5 then
DBM:Debug("Timer "..ttext..phaseText.. " refreshed after zero. Remaining time is : "..remaining, 2)
elseif bar.timer > 0.1 then
DBM:Debug("Timer "..ttext..phaseText.. " refreshed before expired. Remaining time is : "..remaining, 2)
if bar.hasVariance then
if DBM.Options.BadTimerAlert and bar.timer > correctWithVarianceDuration(1, bar) then--If greater than 1 seconds off, report this out of debug mode to all users
DBM:AddMsg("Timer "..ttext..phaseText.. " refreshed before expired, outside known variance window. Remaining time is : "..remaining.." (until variance minimum timer: "..deltaFromVarianceMinTimer.."). Please report this bug")
fireEvent("DBM_Debug", "Timer "..ttext..phaseText.. " refreshed before expired, outside known variance window. Remaining time is : "..remaining.." (until variance minimum timer: "..deltaFromVarianceMinTimer.."). Please report this bug", 2)
elseif bar.timer < correctWithVarianceDuration(-5, bar) then -- arbitrary limit. Would be useful to implement a variance detector, and report outside the known variance, however this would need to happen on a timer after it was refreshed.
DBM:Debug("Timer "..ttext..phaseText.. " refreshed after zero. Remaining time is : "..remaining, 2)
elseif bar.timer > correctWithVarianceDuration(0.1, bar) then
DBM:Debug("Timer "..ttext..phaseText.. " refreshed before expired. Remaining time is : "..remaining.." (until variance minimum timer: "..deltaFromVarianceMinTimer..")", 2)
end
else -- duplicated code, should be refactored
if DBM.Options.BadTimerAlert and bar.timer > 1 then--If greater than 1 seconds off, report this out of debug mode to all users
DBM:AddMsg("Timer "..ttext..phaseText.. " refreshed before expired. Remaining time is : "..remaining..". Please report this bug")
fireEvent("DBM_Debug", "Timer "..ttext..phaseText.. " refreshed before expired. Remaining time is : "..remaining..". Please report this bug", 2)
elseif bar.timer < -5 then
DBM:Debug("Timer "..ttext..phaseText.. " refreshed after zero. Remaining time is : "..remaining, 2)
elseif bar.timer > 0.1 then
DBM:Debug("Timer "..ttext..phaseText.. " refreshed before expired. Remaining time is : "..remaining, 2)
end
end
end
end
Expand Down Expand Up @@ -10106,17 +10132,29 @@ do
local bar = DBT:GetBar(id)
if bar then
local remaining = ("%.2f"):format(bar.timer)
local deltaFromVarianceMinTimer = ("%.2f"):format(bar.hasVariance and bar.timer - bar.varianceDuration or bar.timer)
local ttext = _G[bar.frame:GetName().."BarName"]:GetText() or ""
ttext = ttext.."("..self.id..")"
if mabs(bar.timer) > 0.1 then -- Positive and Negative ("keep") timers. Also shortened time window
local phaseText = self.mod.vb.phase and " ("..L.SCENARIO_STAGE:format(self.mod.vb.phase)..")" or ""
if DBM.Options.BadTimerAlert and bar.timer > 1 then--If greater than 1 seconds off, report this out of debug mode to all users
DBM:AddMsg("Timer "..ttext..phaseText.. " refreshed before expired. Remaining time is : "..remaining..". Please report this bug")
fireEvent("DBM_Debug", "Timer "..ttext..phaseText.. " refreshed before expired. Remaining time is : "..remaining..". Please report this bug", 2)
elseif bar.timer < -5 then
DBM:Debug("Timer "..ttext..phaseText.. " refreshed after zero. Remaining time is : "..remaining, 2)
elseif bar.timer > 0.1 then
DBM:Debug("Timer "..ttext..phaseText.. " refreshed before expired. Remaining time is : "..remaining, 2)
if bar.hasVariance then
if DBM.Options.BadTimerAlert and bar.timer > correctWithVarianceDuration(1, bar) then--If greater than 1 seconds off, report this out of debug mode to all users
DBM:AddMsg("Timer "..ttext..phaseText.. " refreshed before expired, outside known variance window. Remaining time is : "..remaining.." (until variance minimum timer: "..deltaFromVarianceMinTimer.."). Please report this bug")
fireEvent("DBM_Debug", "Timer "..ttext..phaseText.. " refreshed before expired, outside known variance window. Remaining time is : "..remaining.." (until variance minimum timer: "..deltaFromVarianceMinTimer.."). Please report this bug", 2)
elseif bar.timer < correctWithVarianceDuration(-5, bar) then -- arbitrary limit. Would be useful to implement a variance detector, and report outside the known variance, however this would need to happen on a timer after it was refreshed.
DBM:Debug("Timer "..ttext..phaseText.. " refreshed after zero. Remaining time is : "..remaining, 2)
elseif bar.timer > correctWithVarianceDuration(0.1, bar) then
DBM:Debug("Timer "..ttext..phaseText.. " refreshed before expired. Remaining time is : "..remaining.." (until variance minimum timer: "..deltaFromVarianceMinTimer..")", 2)
end
else -- duplicated code, should be refactored
if DBM.Options.BadTimerAlert and bar.timer > 1 then--If greater than 1 seconds off, report this out of debug mode to all users
DBM:AddMsg("Timer "..ttext..phaseText.. " refreshed before expired. Remaining time is : "..remaining..". Please report this bug")
fireEvent("DBM_Debug", "Timer "..ttext..phaseText.. " refreshed before expired. Remaining time is : "..remaining..". Please report this bug", 2)
elseif bar.timer < -5 then
DBM:Debug("Timer "..ttext..phaseText.. " refreshed after zero. Remaining time is : "..remaining, 2)
elseif bar.timer > 0.1 then
DBM:Debug("Timer "..ttext..phaseText.. " refreshed before expired. Remaining time is : "..remaining, 2)
end
end
end
end
Expand Down

0 comments on commit 7b7ccd1

Please sign in to comment.