From 59baeff2bd9bda6987d04db35518a94830313560 Mon Sep 17 00:00:00 2001 From: "Johnny C. Lam" Date: Thu, 28 Mar 2013 04:34:49 +0000 Subject: [PATCH] Defer creating strings until the actual Print/Log/Error methods. Add new methods to Ovale -- Logf, Errorf, DebugPrintf -- that take a format string and arguments for interpolation, much like the standard AceConsole-3.0 Printf method. Use the new methods in place of Log, Error, DebugPrintf so that the actual creation of strings is deferred until the arguments are interpolated into the format string within the new methods. git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@843 d5049fe3-3747-40f7-a4b5-f36d6801af5f --- Ovale.lua | 49 ++++++++++++++------- OvaleActionBar.lua | 4 +- OvaleAura.lua | 12 +++--- OvaleBestAction.lua | 117 +++++++++++++++++++++++--------------------------- OvaleComboPoints.lua | 2 +- OvaleCompile.lua | 35 ++++++++------- OvaleCondition.lua | 23 +++++----- OvaleEnemies.lua | 18 ++++---- OvaleEquipement.lua | 8 ++-- OvaleFrame.lua | 10 ++--- OvaleFuture.lua | 37 ++++++++-------- OvaleGUID.lua | 4 +- OvaleIcone.lua | 4 +- OvalePaperDoll.lua | 32 +++++++------- OvalePool.lua | 2 +- OvaleStance.lua | 2 +- OvaleState.lua | 29 ++++++------- 17 files changed, 193 insertions(+), 195 deletions(-) diff --git a/Ovale.lua b/Ovale.lua index 79318fb..1ae4afc 100644 --- a/Ovale.lua +++ b/Ovale.lua @@ -15,6 +15,7 @@ local L = LibStub("AceLocale-3.0"):GetLocale("Ovale") local OvaleGUID = nil local OvaleOptions = nil +local format = string.format local pairs = pairs local wipe = table.wipe local API_GetTime = GetTime @@ -62,13 +63,6 @@ BINDING_NAME_OVALE_CHECKBOX3 = L["Inverser la boîte à cocher "].."(4)" BINDING_NAME_OVALE_CHECKBOX4 = L["Inverser la boîte à cocher "].."(5)" -- -function Ovale:DebugPrint(flag, ...) - local profile = OvaleOptions:GetProfile() - if profile and profile.debug and profile.debug[flag] then - self:Print("[" .. flag .. "]", ...) - end -end - function Ovale:OnEnable() -- Called when the addon is enabled OvaleGUID = Ovale:GetModule("OvaleGUID") @@ -119,12 +113,6 @@ function Ovale:PLAYER_REGEN_DISABLED() self:UpdateVisibility() end -function Ovale:Log(text) - if self.trace then - self:Print(text) - end -end - local function OnCheckBoxValueChanged(widget) OvaleOptions:GetProfile().check[widget.userdata.k] = widget:GetValue() if Ovale.casesACocher[widget.userdata.k].compile then @@ -244,8 +232,39 @@ function Ovale:ToggleCheckBox(v) end end -function Ovale:Error(text) - self:Print("Fatal error: " .. text) +function Ovale:DebugPrint(flag, ...) + local profile = OvaleOptions:GetProfile() + if profile and profile.debug and profile.debug[flag] then + self:Print("[" .. flag .. "]", ...) + end +end + +function Ovale:DebugPrintf(flag, ...) + local profile = OvaleOptions:GetProfile() + if profile and profile.debug and profile.debug[flag] then + self:Printf("[%s] %s", flag, format(...)) + end +end + +function Ovale:Error(...) + self:Print("Fatal error: ", ...) + self.bug = true +end + +function Ovale:Errorf(...) + self:Printf("Fatal error: %s", format(...)) self.bug = true end + +function Ovale:Log(...) + if self.trace then + self:Print(...) + end +end + +function Ovale:Logf(...) + if self.trace then + return self:Printf(...) + end +end -- diff --git a/OvaleActionBar.lua b/OvaleActionBar.lua index 9cf2569..451009d 100644 --- a/OvaleActionBar.lua +++ b/OvaleActionBar.lua @@ -49,12 +49,12 @@ function OvaleActionBar:ACTIONBAR_SLOT_CHANGED(event, slot, unknown) elseif (slot) then -- on reçoit aussi si c'est une macro avec mouseover à chaque fois que la souris passe sur une cible! self:FillActionIndex(tonumber(slot)) - Ovale:DebugPrint("action_bar", "Mapping button " ..tonumber(slot).." to spell/macro") + Ovale:DebugPrintf("action_bar", "Mapping button %s to spell/macro", slot) end end function OvaleActionBar:FillActionIndexes(event) - Ovale:DebugPrint("action_bar", "Mapping buttons to spells/macros for " ..event) + Ovale:DebugPrintf("action_bar", "Mapping buttons to spells/macros for %s", event) wipe(self_actionSpell) wipe(self_actionMacro) wipe(self_actionItem) diff --git a/OvaleAura.lua b/OvaleAura.lua index 4a035cc..c32212a 100644 --- a/OvaleAura.lua +++ b/OvaleAura.lua @@ -129,7 +129,7 @@ end local function RemoveAurasForGUID(guid) -- Return all auras for the given GUID to the aura pool. if not guid or not self_aura[guid] then return end - Ovale:DebugPrint("aura", "Removing auras for guid " .. guid) + Ovale:DebugPrintf("aura", "Removing auras for guid %s", guid) for filter, auraList in pairs(self_aura[guid]) do for spellId, whoseTable in pairs(auraList) do for whose, aura in pairs(whoseTable) do @@ -205,7 +205,7 @@ function UpdateAuras(unitId, unitGUID) for spellId, whoseTable in pairs(auraList) do for whose, aura in pairs(whoseTable) do if aura.serial ~= self_serial then - Ovale:DebugPrint("aura", "Removing " ..filter.. " " ..aura.name.. " from " ..whose.. ", serial = " ..self_serial.. " aura.serial = " ..aura.serial) + Ovale:DebugPrintf("aura", "Removing %s %s from %s, serial=%d aura.serial=%d", filter, aura.name, whose, self_serial, aura.serial) whoseTable[whose] = nil self_pool:Release(aura) end @@ -276,7 +276,7 @@ end function OvaleAura:GetAuraByGUID(guid, spellId, filter, mine, unitId) if not guid then - Ovale:Log(tostring(guid) .. " does not exists in OvaleAura") + Ovale:Log("nil guid does not exist in OvaleAura") return nil end @@ -286,14 +286,14 @@ function OvaleAura:GetAuraByGUID(guid, spellId, filter, mine, unitId) unitId = OvaleGUID:GetUnitId(guid) end if not unitId then - Ovale:Log("Unable to get unitId from " .. tostring(guid)) + Ovale:Logf("Unable to get unitId from %s", guid) return nil end UpdateAuras(unitId, guid) auraTable = self_aura[guid] if not auraTable then -- no aura on target - Ovale:Log("Target " .. guid .. " has no aura") + Ovale:Logf("Target %s has no aura", guid) return nil end end @@ -438,7 +438,7 @@ function OvaleAura:Debug() for filter, auraList in pairs(auraTable) do for spellId, whoseTable in pairs(auraList) do for whose, aura in pairs(whoseTable) do - Ovale:Print(guid.. " " ..filter.. " " ..whose.. " " ..spellId.. " " ..aura.name.. " stacks=" ..aura.stacks.. " tick=" ..tostring(aura.tick)) + Ovale:Printf("%s %s %s %s %s stacks=%d tick=%s", guid, filter, whose, spellId, aura.name, aura.stacks, aura.tick) end end end diff --git a/OvaleBestAction.lua b/OvaleBestAction.lua index 8e1472b..c61b493 100644 --- a/OvaleBestAction.lua +++ b/OvaleBestAction.lua @@ -45,14 +45,6 @@ local OVALE_DEFAULT_PRIORITY = 3 -- -- -local function printTime(temps) - if (temps == nil) then - Ovale:Print("> nil") - else - Ovale:Print("> "..temps) - end -end - local function addTime(time1, duration) if not time1 then return nil @@ -116,15 +108,15 @@ local function ComputeAfter(element) end local function ComputeAnd(element) - Ovale:Log(element.type .. " [" .. element.nodeId .. "]") + Ovale:Logf("%s [%d]", element.type, element.nodeId) local self = OvaleBestAction local startA, endA, priorityA, elementA = self:ComputeBool(element.a) if not startA then - Ovale:Log(element.type .. " return nil [" .. element.nodeId .. "]") + Ovale:Logf("%s return nil [%d]", element.type, element.nodeId) return nil end if startA == endA then - Ovale:Log(element.type .. " return startA=endA [" .. element.nodeId .. "]") + Ovale:Logf("%s return startA=endA [%d]", element.type, element.nodeId) return nil end local startB, endB, prioriteB, elementB @@ -138,7 +130,7 @@ local function ComputeAnd(element) elementB.wait = nil end if isAfter(startB, endA) or isAfter(startA, endB) then - Ovale:Log(element.type .. " return nil [" .. element.nodeId .. "]") + Ovale:Logf("%s return nil [%d]", element.type, element.nodeId) return nil end if isBefore(startB, startA) then @@ -147,7 +139,7 @@ local function ComputeAnd(element) if isAfter(endB, endA) then endB = endA end - Ovale:Log(element.type .. " return " .. tostring(startB) .. "," .. tostring(endB) .. " [" .. element.nodeId .. "]") + Ovale:Logf("%s return %s, %s [%d]", element.type, startB, endB, element.nodeId) return startB, endB, prioriteB, elementB end @@ -164,11 +156,11 @@ local function ComputeBetween(element) local tempsA = self:Compute(element.a) local tempsB = self:Compute(element.b) if not tempsA and not tempsB then - Ovale:Log("diff returns 0 because the two nodes are nil") + Ovale:Logf("%s returns 0 because the two nodes are nil", element.type) return 0 end if not tempsA or not tempsB then - Ovale:Log(element.type .. " return nil") + Ovale:Logf("%s return nil", element.type) return nil end local diff @@ -177,27 +169,27 @@ local function ComputeBetween(element) else diff = tempsB - tempsA end - Ovale:Log("diff returns "..diff) + Ovale:Logf("%s returns %f", element.type, diff) return diff end local function ComputeCompare(element) - Ovale:Log("compare " .. element.comparison) + Ovale:Logf("compare %s", element.comparison) local self = OvaleBestAction local tempsA = self:Compute(element.a) local timeB = self:Compute(element.time) - Ovale:Log(tostring(tempsA) .. " " .. element.comparison .. " " .. tostring(timeB)) + Ovale:Logf("%s %s %s", tempsA, element.comparison, timeB) if element.comparison == "more" and (not tempsA or tempsA > timeB) then - Ovale:Log(element.type .. " return 0") + Ovale:Logf("%s return 0", element.type) return 0 elseif element.comparison == "less" and tempsA and tempsA < timeB then - Ovale:Log(element.type .. " return 0") + Ovale:Logf("%s return 0", element.type) return 0 elseif element.comparison == "at most" and tempsA and tempsA <= timeB then - Ovale:Log(element.type .. " return 0") + Ovale:Logf("%s return 0", element.type) return 0 elseif element.comparison == "at least" and (not tempsA or tempsA >= timeB) then - Ovale:Log(element.type .. " return 0") + Ovale:Logf("%s return 0", element.type) return 0 end return nil @@ -208,15 +200,15 @@ local function ComputeFromUntil(element) local self = OvaleBestAction local tempsA = self:Compute(element.a) if not tempsA then - Ovale:Log(element.type .. " return nil") + Ovale:Logf("%s return nil", element.type) return nil end local tempsB = self:Compute(element.b) if not tempsB then - Ovale:Log(element.type .. " return nil") + Ovale:Logf("%s return nil", element.type) return nil end - Ovale:Log("fromuntil returns " .. (tempsB - tempsA)) + Ovale:Logf("%s returns %f", element.type, tempsB - tempsA) return tempsB - tempsA end @@ -228,11 +220,11 @@ local function ComputeFunction(element) actionUsable, actionShortcut, actionIsCurrent, actionEnable, spellId = self:GetActionInfo(element) if not actionTexture then - Ovale:Log("Action "..element.params[1].." not found") + Ovale:Logf("Action %s not found", element.params[1]) return nil end if element.params.usable == 1 and not actionUsable then - Ovale:Log("Action "..element.params[1].." not usable") + Ovale:Logf("Action %s not usable", element.params[1]) return nil end if spellId and OvaleData.spellInfo[spellId] and OvaleData.spellInfo[spellId].casttime then @@ -249,7 +241,7 @@ local function ComputeFunction(element) end --TODO: not useful anymore? if spellId and OvaleData.spellInfo[spellId] and OvaleData.spellInfo[spellId].toggle and actionIsCurrent then - Ovale:Log("Action "..element.params[1].." is current action") + Ovale:Logf("Action %s is current action", element.params[1]) return nil end if actionEnable and actionEnable > 0 then @@ -259,7 +251,7 @@ local function ComputeFunction(element) else remaining = actionCooldownDuration + actionCooldownStart end - Ovale:Log("remaining = " .. remaining .. " attenteFinCast=" .. tostring(OvaleState.attenteFinCast)) + Ovale:Logf("remaining=%f attenteFinCast=%s", remaining, OvaleState.attenteFinCast) if remaining < OvaleState.attenteFinCast then if not OvaleData.spellInfo[OvaleState.currentSpellId] or not OvaleData.spellInfo[OvaleState.currentSpellId].canStopChannelling then @@ -267,11 +259,10 @@ local function ComputeFunction(element) else --TODO: pas exact, parce que si ce sort est reporté de par exemple 0,5s par un debuff --ça tombera entre deux ticks - local ticks = floor(OvalePaperDoll:GetSpellHasteMultiplier() * OvaleData.spellInfo[OvaleState.currentSpellId].canStopChannelling + 0.5) - local tickLength = (OvaleState.attenteFinCast - OvaleState.startCast) / ticks - local tickTime = OvaleState.startCast + tickLength - Ovale:Log(spellId .. " remaining = " .. remaining) - Ovale:Log("ticks = "..ticks.." tickLength="..tickLength.." tickTime="..tickTime) + local numTicks = floor(OvalePaperDoll:GetSpellHasteMultiplier() * OvaleData.spellInfo[OvaleState.currentSpellId].canStopChannelling + 0.5) + local tick = (OvaleState.attenteFinCast - OvaleState.startCast) / numTicks + local tickTime = OvaleState.startCast + tick + Ovale:Logf("%s remaining=%f", spellId, remaining) for i=1, ticks do if remaining <= tickTime then remaining = tickTime @@ -279,30 +270,30 @@ local function ComputeFunction(element) end tickTime = tickTime + tickLength end - Ovale:Log(spellId .. " remaining = " .. remaining) + Ovale:Logf("%s remaining=%f, numTicks=%d, tick=%f, tickTime=%f", spellId, remaining, numTicks, tick, tickTime) end end - Ovale:Log("Action "..element.params[1].." remains "..remaining) + Ovale:Logf("Action %s remains %f", element.params[1], remaining) local priority = element.params.priority or OVALE_DEFAULT_PRIORITY return remaining, nil, priority, element else - Ovale:Log("Action "..element.params[1].." not enabled") + Ovale:Logf("Action %s not enabled", element.params[1]) end else local condition = OvaleCondition.conditions[element.func] if not condition then - Ovale.bug = true - Ovale:Print("Function "..element.func.." not found") + Ovale:Errorf("Function %s not found", element.func) return nil end local start, ending, value, origin, rate = condition(element.params) if Ovale.trace then - local parameterList = element.func.."(" - for k,v in pairs(element.params) do - parameterList = parameterList..k.."="..v.."," + local conditionCall = element.func .. "(" + for k, v in pairs(element.params) do + conditionCall = parameterList .. k .. "=" .. v .. "," end - Ovale:Print("Function "..parameterList..") returned "..tostring(start)..","..tostring(ending)..","..tostring(value)..","..tostring(origin)..","..tostring(rate)) + conditionCall = conditionCall .. ")" + Ovale:Printf("Condition %s returned %s, %s, %s, %s, %s", conditionCall, start, ending, value, origin, rate) end if value then @@ -322,7 +313,7 @@ local function ComputeGroup(element) local bestElement local bestCastTime - Ovale:Log(element.type .. " [" .. element.nodeId .. "]") + Ovale:Logf("%s [%d]", element.type, element.nodeId) if #element.nodes == 1 then return self:Compute(element.nodes[1]) @@ -352,7 +343,7 @@ local function ComputeGroup(element) -- Maximum time between the best spell and the current spell. local maxDiff if priority and not bestPriority then - Ovale:Error("Internal error: bestPriority=nil and priority=" .. priority) + Ovale:Errorf("Internal error: bestPriority=nil and priority=%d", priority) return nil elseif priority and priority > bestPriority then -- Si le nouveau sort est plus prioritaire que le précédent, on le lance @@ -391,16 +382,16 @@ local function ComputeGroup(element) if bestElement.params then id = bestElement.params[1] end - Ovale:Log("group best action " .. tostring(id) .. " remains " .. bestStart .. "," .. tostring(bestEnding) .. " [" .. element.nodeId .. "]") + Ovale:Logf("group best action %s remains %s, %s [%d]", id, bestStart, bestEnding, element.nodeId) else - Ovale:Log("group no best action returns " .. bestStart .. "," .. tostring(bestEnding) .. " [" .. element.nodeId .. "]") + Ovale:Logf("group no best action returns %s, %s [%d]", bestStart, bestEnding, element.nodeId) end return bestStart, bestEnding, bestPriority, bestElement end local function ComputeLua(element) local ret = loadstring(element.lua)() - Ovale:Log("lua "..tostring(ret)) + Ovale:Logf("lua %s", ret) return 0, nil, OVALE_DEFAULT_PRIORITY, PutValue(element, ret, 0, 0) end @@ -444,7 +435,7 @@ local function ComputeOperator(element) local startA, endA, prioA, elementA = self:Compute(element.a) local startB, endB, prioB, elementB = self:Compute(element.b) if not elementA or not elementB then - Ovale:Log("operator " .. element.operator .. ": elementA or elementB is nil") + Ovale:Logf("operator %s: elementA or elementB is nil", element.operator) return nil end @@ -490,11 +481,11 @@ local function ComputeOperator(element) end if not a or not x or not b or not y then - Ovale:Log("operator " .. element.operator .. ": a or x is nil") + Ovale:Logf("operator %s: a or x is nil", element.operator) return nil end - Ovale:Log(a .. "+(t-" .. b .. ")*" .. c .. " " .. element.operator .. " " .. x .. "+(t-" .. y .. ")*" .. z) + Ovale:Logf("%f+(t-%f)*%f %s %f+(t-%f)*%f", a, b, c, element.operator, x, y, z) -- result(t) = l + (t - m) * n local l, m, n @@ -620,7 +611,7 @@ local function ComputeOperator(element) end end - Ovale:Log("result = " .. tostring(l) .. "+(t-" .. tostring(m) .. ")*" .. tostring(n)) + Ovale:Logf("result = %f+(t-%f)*%f", l, m, n) return startA, endA, OVALE_DEFAULT_PRIORITY, PutValue(element, l, m, n) end @@ -639,11 +630,11 @@ local function ComputeUnless(element) end if isBeforeEqual(startA, startB) and isAfterEqual(endA, endB) then - Ovale:Log(element.type .. " return nil") + Ovale:Logf("%s return nil", element.type) return nil end if isAfterEqual(startA, startB) and isBefore(endA, endB) then - Ovale:Log(element.type .. " return " .. tostring(endA) .. "," .. tostring(endB)) + Ovale:Logf("%s return %s, %s", element.type, endA, endB) return endA, endB, prioriteB, elementB end if isAfter(startA, startB) and isBefore(startA, endB) then @@ -652,22 +643,22 @@ local function ComputeUnless(element) if isAfter(endA, startB) and isBefore(endA, endB) then startB = endA end - Ovale:Log(element.type .. " return " .. tostring(startB) .. "," .. tostring(endB)) + Ovale:Logf("%s return %s, %s", element.type, startB, endB) return startB, endB, prioriteB, elementB end local function ComputeValue(element) - Ovale:Log("value " .. element.value) + Ovale:Logf("value %s", element.value) return 0, nil, OVALE_DEFAULT_PRIORITY, element end local function ComputeWait(element) - Ovale:Log(element.type .. " [" .. element.nodeId .. "]") + Ovale:Logf("%s [%d]", element.type, element.nodeId) local self = OvaleBestAction local startA, endA, prioriteA, elementA = self:Compute(element.a) if elementA then elementA.wait = true - Ovale:Log(element.type .. " return " .. tostring(startA) .. "," .. tostring(endA) .. " [" .. element.nodeId .. "]") + Ovale:Logf("%s return %s, %s [%d]", element.type, startA, endA, element.nodeId) end return startA, endA, prioriteA, elementA end @@ -720,13 +711,13 @@ function OvaleBestAction:GetActionInfo(element) if (element.func == "spell" ) then action = OvaleActionBar:GetForSpell(spellId) if not OvaleData.spellList[spellId] and not action then - Ovale:Log("Spell "..spellId.." not learnt") + Ovale:Logf("Spell %s not learnt", spellId) return nil end actionCooldownStart, actionCooldownDuration, actionEnable = OvaleState:GetComputedSpellCD(spellId) if not actionCooldownStart or not actionCooldownDuration then - Ovale:DebugPrint("unknown_spells", "No cooldown data for spell "..spellId) + Ovale:DebugPrintf("unknown_spells", "No cooldown data for spell %s\n", spellId) end local si = OvaleData.spellInfo[spellId] @@ -767,7 +758,7 @@ function OvaleBestAction:GetActionInfo(element) actionShortcut = OvaleActionBar:GetBinding(action) actionIsCurrent = API_IsCurrentAction(action) else - Ovale:Log("Unknown macro "..element.params[1]) + Ovale:Logf("Unknown macro %s", element.params[1]) end elseif (element.func=="item") then local itemId = element.params[1] @@ -778,7 +769,7 @@ function OvaleBestAction:GetActionInfo(element) return nil end - Ovale:Log("Item "..tostring(itemId)) + Ovale:Logf("Item %s", itemId) local spellName = API_GetItemSpell(itemId) actionUsable = (spellName~=nil) @@ -824,7 +815,7 @@ function OvaleBestAction:Compute(element) return visitor(element) end - Ovale:Log("unknown element " .. element.type .. ", return nil") + Ovale:Logf("unknown element %s, return nil", element.type) return nil end diff --git a/OvaleComboPoints.lua b/OvaleComboPoints.lua index 1d20692..349f3b7 100644 --- a/OvaleComboPoints.lua +++ b/OvaleComboPoints.lua @@ -81,6 +81,6 @@ function OvaleComboPoints:Refresh() end function OvaleComboPoints:Debug() - Ovale:Print("Player has " .. self.combo .. " combo points on target " .. OvaleGUID:GetGUID("target") .. ".") + Ovale:Printf("Player has %d combo points on target %s.", self.combo, OvaleGUID:GetGUID("target")) end -- diff --git a/OvaleCompile.lua b/OvaleCompile.lua index 1b4feb9..73f08f9 100644 --- a/OvaleCompile.lua +++ b/OvaleCompile.lua @@ -95,7 +95,7 @@ local function HasTalent(talentId) if OvaleData.pointsTalent[talentId]~=nil then return OvaleData.pointsTalent[talentId]>0 else - Ovale:Print("Unknown talent "..talentId) + Ovale:Printf("Unknown talent %s", talentId) return false end else @@ -237,11 +237,11 @@ local function ParseFunction(prefix, func, params) end if spellName then if spellName == API_GetSpellInfo(spellName) then - Ovale:DebugPrint("missing_spells", "Learning spell "..tostring(spellName).." with ID "..spellId) + Ovale:DebugPrintf("missing_spells", "Learning spell %s with ID %d", spellName, spellId) self_missingSpellList[spellId] = spellName end else - Ovale:DebugPrint("unknown_spells", "Unknown spell with ID "..spellId) + Ovale:DebugPrintf("unknown_spells", "Unknown spell with ID %d", spellId) end end end @@ -325,10 +325,10 @@ local function ParseScoreSpells(params) for v in strgmatch(params, "(%d+)") do local spellId = tonumber(v) if spellId then - --Ovale:Print("Add spell to score "..spellId) + --Ovale:Printf("Add spell to score %d", spellId) OvaleData.scoreSpell[spellId] = true else - Ovale:Print("unknown spell "..v) + Ovale:Printf("ScoreSpell with unknown spell %s", v) end end end @@ -457,7 +457,7 @@ local function ParseGroup(text) text = strgsub(text, "node%d+", "") if (strmatch(text,"[^ ]")) then - Ovale:Print("syntax error:"..text) + Ovale:Printf("syntax error: %s", text) return nil end @@ -516,7 +516,7 @@ end local function ParseCommands(text) local original = text text = strgsub(text,"(%b[])", ParseLua) - while (1==1) do + while true do local was = text text = strgsub(text, "(%w+)%.?(%w*)%s*%((.-)%)", ParseFunction) text = strgsub(text, "(%d+%.?%d*)s", ParseTime) @@ -529,7 +529,7 @@ local function ParseCommands(text) end end - while (1==1) do + while true do local was = text text = strgsub(text, "node(%d+)%s*([%>%<]=?)%s*node(%d+)", ParseOp) text = strgsub(text, "node(%d+)%s*(==)%s*node(%d+)", ParseOp) @@ -539,7 +539,7 @@ local function ParseCommands(text) end end - while (1==1) do + while true do local was = text text = strgsub(text, "not%s+node(%d+)", ParseNot) text = strgsub(text, "between%s+node(%d+)%s+and%s+node(%d+)", ParseBetween) @@ -550,12 +550,12 @@ local function ParseCommands(text) text = strgsub(text, "(at most)%s+node(%d+)%s+node(%d+)", ParseCompare) text = strgsub(text, "node(%d+)%s+before%s+node(%d+)", ParseBefore) text = strgsub(text, "node(%d+)%s+after%s+node(%d+)", ParseAfter) - if (was == text) then + if was == text then break end end - while (1==1) do + while true do local was = text text = strgsub(text, "not%s+node(%d+)", ParseNot) text = strgsub(text, "node(%d+)%s*([%*%+%-%/%>%<]=?|==)%s*node(%d+)", ParseOp) @@ -565,12 +565,11 @@ local function ParseCommands(text) text = strgsub(text, "unless%s+node(%d+)%s+node(%d+)",ParseUnless) text = strgsub(text, "wait%s+node(%d+)",ParseWait) text = strgsub(text, "{([node%d ]*)}", ParseGroup) - if (was == text) then + if was == text then break end end - local masterNode if (text) then masterNode = strmatch(text, "node(%d+)") @@ -582,9 +581,9 @@ local function ParseCommands(text) -- Si il reste autre chose que des espaces, c'est une erreur de syntaxe text = strgsub(text, "node%d+", "", 1) - if (strmatch(text,"[^ ]")) then - Ovale:Print("Group:"..original) - Ovale:Print("syntax error:"..text) + if strmatch(text,"[^ ]") then + Ovale:Printf("Group: %s", original) + Ovale:Printf("syntax error: %s", text) return nil end return masterNode @@ -608,7 +607,7 @@ local function ParseCanStopChannelling(text) if spellId then OvaleData:GetSpellInfo(spellId).canStopChannelling = true else - Ovale:Print("CanStopChannelling with unknown spell "..spellId) + Ovale:Printf("CanStopChannelling with unknown spell %s", text) end return "" end @@ -630,7 +629,7 @@ local function ParseSpellName(text) if spell then return '"' .. spell .. '"' else - Ovale:Print("SpellName of " .. text .. " unknown") + Ovale:Printf("SpellName of %s unknown", text) return nil end end diff --git a/OvaleCondition.lua b/OvaleCondition.lua index a987178..a4f4f87 100644 --- a/OvaleCondition.lua +++ b/OvaleCondition.lua @@ -152,7 +152,7 @@ local function compare(a, comparison, b) return nil end else - Ovale:Error("unknown compare term "..comparison.." (should be more, equal, or less)") + Ovale:Errorf("unknown compare term %s (should be more, equal, or less)", comparison) end end @@ -280,14 +280,14 @@ local function testValue(comparator, limit, value, atTime, rate) elseif comparator == "less" then if value < limit then return 0 else return nil end else - Ovale:Error("Unknown operator "..comparator) + Ovale:Errorf("Unknown operator %s", comparator) end elseif (comparator == "more" and rate > 0) or (comparator == "less" and rate < 0) then return (limit - value) / rate + atTime elseif (comparator == "more" and rate < 0) or (comparator == "less" and rate > 0) then return 0, (limit - value) / rate + atTime else - Ovale:Error("Unknown operator "..comparator) + Ovale:Errorf("Unknown operator %s", comparator) end end end @@ -325,15 +325,15 @@ local function GetAura(condition) local start, ending, stacks, tick, value, gain = OvaleState:GetAura(unitId, spellId, filter, mine) if not start then - Ovale:Log("GetAura: aura " .. tostring(spellId) .. " not found on " .. unitId .. " filter=" .. tostring(filter) .. " mine=" .. tostring(mine)) + Ovale:Logf("GetAura: aura %s not found on %s filter=%s mine=%s", spellId, unitId, filter, mine) return nil end local conditionStacks = condition.stacks or 1 if stacks and stacks < conditionStacks then - Ovale:Log("GetAura: aura " .. tostring(spellId) .. " found on " .. unitId .. " but stacks " .. stacks .. " < " .. conditionStacks) + Ovale:Logf("GetAura: aura %s found on %s but stacks %d < %d", spellId, unitId, stacks, conditionStacks) return nil end - Ovale:Log("GetAura: aura " .. tostring(spellId) .. " found on " .. unitId .. " start=" .. tostring(start) .. " ending=" .. tostring(ending) .. " stacks=" .. tostring(stacks) .. "/" .. conditionStacks) + Ovale:Logf("GetAura: aura %s found on %s start=%s ending=%s stacks=%s/%d", spellId, unitId, start, ending, stacks, conditionStacks) return start, ending, stacks, tick, value, gain end @@ -356,7 +356,7 @@ local function TimeToDie(unitId) local health = API_UnitHealth(unitId) local maxHealth = API_UnitHealthMax(unitId) or 1 if health then - Ovale:Log("target = " .. tostring(self_lastTTDguid[unitId]) .. ", health = " .. health .. ", maxHealth = " .. maxHealth) + Ovale:Logf("target = %s, health = %d, maxHealth = %d", self_lastTTDguid[unitId], health, maxHealth) end if maxHealth < health then maxHealth = health @@ -383,7 +383,7 @@ local function TimeToDie(unitId) end if prevHealth and prevHealth > health then self_lastTTDdps[unitId] = (prevHealth - health) / delta - Ovale:Log("prevHealth = " .. prevHealth .. ", health = " .. health .. ", delta = " .. delta .. ", dps = " .. self_lastTTDdps[unitId]) + Ovale:Logf("prevHealth = %d, health = %d, delta = %d, dps = %d", prevHealth, health, delta, self_lastTTDdps[unitId]) break end end @@ -566,10 +566,7 @@ OvaleCondition.conditions.buffexpires = function(condition) ending = 0 end local timeBefore = avecHate(condition[2], condition.haste) - if Ovale.trace then - Ovale:Print("timeBefore = " .. tostring(timeBefore)) - Ovale:Print("ending = " .. tostring(ending)) - end + Ovale:Logf("timeBefore = %s, ending = %s", timeBefore, ending) return addTime(ending, -timeBefore) end OvaleCondition.conditions.debuffexpires = OvaleCondition.conditions.buffexpires @@ -813,7 +810,7 @@ OvaleCondition.conditions.casttime = function(condition) castTime = select(7, API_GetSpellInfo(condition[1])) if castTime then castTime = castTime / 1000 - Ovale:Log("castTime = " .. castTime .. " " .. tostring(condition[2]) .. " " .. tostring(condition[3])) + Ovale:Logf("castTime = %f %s %s", castTime, condition[2], condition[3]) end end return compare(castTime, condition[2], condition[3]) diff --git a/OvaleEnemies.lua b/OvaleEnemies.lua index 6efe61d..bc00983 100644 --- a/OvaleEnemies.lua +++ b/OvaleEnemies.lua @@ -38,31 +38,33 @@ OvaleEnemies.activeEnemies = 0 -- local function AddEnemy(guid, name, timestamp) if not guid then return end + local self = OvaleEnemies local seen = self_enemyLastSeen[guid] self_enemyLastSeen[guid] = timestamp self_enemyName[guid] = name if not seen then - OvaleEnemies.activeEnemies = OvaleEnemies.activeEnemies + 1 - Ovale:DebugPrint("enemy", "New enemy (" .. OvaleEnemies.activeEnemies .. " total): " .. guid .. "(" .. tostring(name) .. ")") + self.activeEnemies = self.activeEnemies + 1 + Ovale:DebugPrintf("enemy", "New enemy (%d total): %s (%s)", self.activeEnemies, guid, name) Ovale.refreshNeeded["player"] = true end end local function RemoveEnemy(guid, isDead) if not guid then return end + local self = OvaleEnemies local seen = self_enemyLastSeen[guid] local name = self_enemyName[guid] self_enemyLastSeen[guid] = nil if seen then - if OvaleEnemies.activeEnemies > 0 then - OvaleEnemies.activeEnemies = OvaleEnemies.activeEnemies - 1 + if self.activeEnemies > 0 then + self.activeEnemies = self.activeEnemies - 1 end if isDead then - Ovale:DebugPrint("enemy", "Enemy died (" .. OvaleEnemies.activeEnemies .. " total): " .. guid .. " (" .. tostring(name) .. ")") + Ovale:DebugPrintf("enemy", "Enemy died (%d total): %s (%s)", self.activeEnemies, guid, name) else - Ovale:DebugPrint("enemy", "Enemy removed: (" .. OvaleEnemies.activeEnemies .. " total): " .. guid .. " (" .. tostring(name) .. "), last seen at " .. seen) + Ovale:DebugPrintf("enemy", "Enemy removed (%d total): %s (%s), last seen at %f", self.activeEnemies, guid, name, seen) end - OvaleEnemies:SendMessage("Ovale_InactiveUnit", guid) + self:SendMessage("Ovale_InactiveUnit", guid) Ovale.refreshNeeded["player"] = true end end @@ -122,7 +124,7 @@ end function OvaleEnemies:Debug() for guid, timestamp in pairs(self_enemyLastSeen) do - Ovale:Print("enemy " .. guid .. " (" .. tostring(self_enemyName[guid]) .. ") last seen at " .. timestamp) + Ovale:Printf("enemy %s (%s) last seen at %f", guid, self_enemyName[guid], timestamp) end end -- diff --git a/OvaleEquipement.lua b/OvaleEquipement.lua index 73f95f9..18fba02 100644 --- a/OvaleEquipement.lua +++ b/OvaleEquipement.lua @@ -1065,12 +1065,12 @@ end function OvaleEquipement:Debug() for slotId = INVSLOT_FIRST_EQUIPPED, INVSLOT_LAST_EQUIPPED do - Ovale:Print("Slot " ..slotId.. " = " .. tostring(self:GetEquippedItem(slotId))) + Ovale:Printf("Slot %d = %s", slotId, self:GetEquippedItem(slotId)) end - Ovale:Print("Main-hand item type: " .. tostring(self_mainHandItemType)) - Ovale:Print("Off-hand item type: " .. tostring(self_offHandItemType)) + Ovale:Printf("Main-hand item type: %s", self_mainHandItemType) + Ovale:Printf("Off-hand item type: %s", self_offHandItemType) for k, v in pairs(self_armorSetCount) do - Ovale:Print("Player has " ..v.. "piece(s) of " ..k.. " armor set") + Ovale:Printf("Player has %d piece(s) of %s armor set.", v, k) end end -- diff --git a/OvaleFrame.lua b/OvaleFrame.lua index 5ce79cf..66b9fb0 100644 --- a/OvaleFrame.lua +++ b/OvaleFrame.lua @@ -179,13 +179,11 @@ do OvaleCondition.defaultTarget = target if forceRefresh or Ovale.refreshNeeded[target] or Ovale.refreshNeeded["player"] or Ovale.refreshNeeded["pet"] then - if Ovale.trace then - Ovale:Print("****Master Node "..k) - end + Ovale:Logf("****Master Node %d", k) OvaleBestAction:StartNewAction() local start, ending, priorite, element = OvaleBestAction:Compute(node) if start then - Ovale:Log("Compute start = "..start) + Ovale:Logf("Compute start = %f", start) end local action = self.actions[k] local icons @@ -265,9 +263,7 @@ do else nextCast = start + gcd end - if Ovale.trace then - Ovale:Print("****Second icon " .. start) - end + Ovale:Logf("****Second icon %f", start) local spellTarget if element then spellTarget = element.params.target diff --git a/OvaleFuture.lua b/OvaleFuture.lua index 44bbd76..a037a8c 100644 --- a/OvaleFuture.lua +++ b/OvaleFuture.lua @@ -66,7 +66,7 @@ local function ScoreSpell(spellId) local si = OvaleData.spellInfo[spellId] if Ovale.enCombat and not (si and si.toggle) and OvaleData.scoreSpell[spellId] then local scored = Ovale.frame:GetScore(spellId) - Ovale:Log("Scored " .. scored) + Ovale:Logf("Scored %s", scored) if scored then Ovale.score = Ovale.score + scored Ovale.maxScore = Ovale.maxScore + 1 @@ -86,16 +86,15 @@ local function AddSpellToQueue(spellId, lineId, startTime, endTime, channeled, a spellcast.allowRemove = allowRemove --TODO unable to know what is the real target if lineId == self_lastLineID and self_lastTarget then - -- Ovale:Print("found lineId " .. lineId .. " target is " .. self_lastTarget) + -- Ovale:Printf("found lineId %d, target is %s", lineId, self_lastTarget) spellcast.target = self_lastTarget else spellcast.target = API_UnitGUID("target") end if self.traceSpellId and self.traceSpellId == spellId then local spellName = OvaleData.spellList[spellId] or API_GetSpellInfo(spellId) - Ovale:Print(" AddSpellToList: " ..Ovale.now.. " " ..spellName.. " (" ..spellId.. "), lineId = " ..lineId) - Ovale:Print(" startTime = " ..startTime.. ", endTime = " ..endTime) - Ovale:Print(" target = " ..spellcast.target.. (channeled and "(channeled)" or "") .. (allowRemove and "(allowRemove)" or "")) + Ovale:Printf(" AddSpellToQueue: %f %s (%d), lineId = %d", Ovale.now, spellName, spellId, lineId) + Ovale:Printf(" startTime = %f, endTime = %f, target = %s", startTime, endTime, spellcast.target) end -- Snapshot the current stats for the spellcast. @@ -159,7 +158,7 @@ local function RemoveSpellFromQueue(spellId, lineId) if spellcast.lineId == lineId then if self.traceSpellId and self.traceSpellId == spellId then local spellName = OvaleData.spellList[spellId] or API_GetSpellInfo(spellId) - Ovale:Print(" RemoveSpellFromList: " .. Ovale.now .. " " .. tostring(spellName) .. " (" .. spellId .. ")") + Ovale:Printf(" RemoveSpellFromQueue: %f %s (%d)", Ovale.now, spellName, spellId) end tremove(self_activeSpellcast, index) self_pool:Release(spellcast) @@ -196,8 +195,8 @@ function OvaleFuture:UNIT_SPELLCAST_CHANNEL_START(event, unit, name, rank, lineI if unit == "player" then local startTime, endTime = select(5, API_UnitChannelInfo("player")) if self.traceSpellId and self.traceSpellId == spellId then - Ovale:Print(event.. ": " ..Ovale.now.. " " ..name.. " (" ..spellId.. "), lineId = " ..lineId) - Ovale:Print(" startTime = " ..startTime.. ", endTime = " ..endTime) + Ovale:Printf("%s: %f %s (%d), lineId = %d", event, Ovale.now, spellName, spellId, lineId) + Ovale:Printf(" startTime = %f, endTime = %f", startTime, endTime) end AddSpellToQueue(spellId, lineId, startTime/1000, endTime/1000, true, false) end @@ -206,7 +205,7 @@ end function OvaleFuture:UNIT_SPELLCAST_CHANNEL_STOP(event, unit, name, rank, lineId, spellId) if unit == "player" then if self.traceSpellId and self.traceSpellId == spellId then - Ovale:Print(event.. ": " ..Ovale.now.. " " ..name.. " (" ..spellId.. "), lineId = " ..lineId) + Ovale:Printf("%s: %f %s (%d), lineId = %d", event, Ovale.now, spellName, spellId, lineId) end RemoveSpellFromQueue(spellId, lineId) end @@ -217,8 +216,8 @@ function OvaleFuture:UNIT_SPELLCAST_START(event, unit, name, rank, lineId, spell if unit == "player" then local startTime, endTime = select(5, API_UnitCastingInfo("player")) if self.traceSpellId and self.traceSpellId == spellId then - Ovale:Print(event.. ": " ..Ovale.now.. " " ..name.. " (" ..spellId.. "), lineId = " ..lineId) - Ovale:Print(" startTime = " ..startTime.. ", endTime = " ..endTime) + Ovale:Printf("%s: %f %s (%d), lineId = %d", event, Ovale.now, spellName, spellId, lineId) + Ovale:Printf(" startTime = %f, endTime = %f", startTime, endTime) end AddSpellToQueue(spellId, lineId, startTime/1000, endTime/1000, false, false) end @@ -228,7 +227,7 @@ end function OvaleFuture:UNIT_SPELLCAST_INTERRUPTED(event, unit, name, rank, lineId, spellId) if unit == "player" then if self.traceSpellId and self.traceSpellId == spellId then - Ovale:Print(event.. ": " ..Ovale.now.. " " ..name.. " (" ..spellId.. "), lineId = " ..lineId) + Ovale:Printf("%s: %f %s (%d), lineId = %d", event, Ovale.now, spellName, spellId, lineId) end RemoveSpellFromQueue(spellId, lineId) end @@ -249,8 +248,8 @@ function OvaleFuture:UNIT_SPELLCAST_SENT(event, unit, spell, rank, target, lineI self_lastTarget = targetGUID self_lastLineID = lineId if self.traceSpellId and self.traceSpellId == spellId then - Ovale:Print(event.. ": " ..Ovale.now.. " " ..name.. " (" ..spellId.. "), lineId = " ..lineId) - Ovale:Print(" targetGUID = " ..targetGUID) + Ovale:Printf("%s: %f %s (%d), lineId = %d", event, Ovale.now, spellName, spellId, lineId) + Ovale:Printf(" targetGUID = %s", targetGUID) end for _, spellcast in ipairs(self_activeSpellcast) do if spellcast.lineId == lineId then @@ -263,7 +262,7 @@ end function OvaleFuture:UNIT_SPELLCAST_SUCCEEDED(event, unit, name, rank, lineId, spellId) if unit == "player" then if self.traceSpellId and self.traceSpellId == spellId then - Ovale:Print(event.. ": " ..Ovale.now.. " " ..name.. " (" ..spellId.. "), lineId = " ..lineId) + Ovale:Printf("%s: %f %s (%d), lineId = %d", event, Ovale.now, spellName, spellId, lineId) end -- Search for a cast-time spell matching this spellcast that was added by UNIT_SPELLCAST_START. for _, spellcast in ipairs(self_activeSpellcast) do @@ -338,14 +337,14 @@ function OvaleFuture:COMBAT_LOG_EVENT_UNFILTERED(event, ...) or strfind(event, "SPELL_MISSED") == 1 then local spellId, spellName = select(12, ...) if self.traceSpellId and self.traceSpellId == spellId then - Ovale:Print(event.. ": " ..Ovale.now.. " " ..spellName.. " (" ..spellId.. ")") + Ovale:Printf("%s: %f %s (%d), lineId = %d", event, Ovale.now, spellName, spellId, lineId) end for index, spellcast in ipairs(self_activeSpellcast) do if spellcast.allowRemove and (spellcast.spellId == spellId or spellcast.auraSpellId == spellId) then if not spellcast.channeled and (spellcast.removeOnSuccess or strfind(event, "SPELL_CAST_SUCCESS") ~= 1) then if self.traceSpellId and self.traceSpellId == spellId then local spellName = OvaleData.spellList[spellId] or API_GetSpellInfo(spellId) - Ovale:Print(" Spell finished: " ..Ovale.now.. " " ..spellName.. " (" ..spellId.. ")") + Ovale:Printf(" Spell finished: %f %s (%d)", Ovale.now, spellName, spellId) end tremove(self_activeSpellcast, index) self_pool:Release(spellcast) @@ -382,7 +381,7 @@ function OvaleFuture:InFlightSpells(now) si = OvaleData.spellInfo[spellcast.spellId] -- skip over spells that are toggles for other spells if not (si and si.toggle) then - Ovale:Log("now = " .. now .. " spellId = " .. spellcast.spellId .. " endCast = " .. spellcast.stop) + Ovale:Logf("now = %f, spellId = %d, endCast = %f", now, spellcast.spellId, spellcast.stop) if now - spellcast.stop < 5 then return spellcast.spellId, spellcast.lineId, spellcast.start, spellcast.stop, spellcast.stop, spellcast.nocd, spellcast.target else @@ -434,7 +433,7 @@ function OvaleFuture:Debug() end for spellId, lineId in self:InFlightSpells(Ovale.now) do local spellName = OvaleData.spellList[spellId] or API_GetSpellInfo(spellId) - Ovale:Print(" " ..spellName.. " (" ..spellId.. "), lineId = " ..tostring(lineId)) + Ovale:Printf(" %s (%d), lineId = %s", spellName, spellId, lineId) end end -- diff --git a/OvaleGUID.lua b/OvaleGUID.lua index 53a17e7..1669bcf 100644 --- a/OvaleGUID.lua +++ b/OvaleGUID.lua @@ -54,7 +54,7 @@ function OvaleGUID:OnDisable() end function OvaleGUID:Update(unitId) - --self:Print("Update " .. unitId) + --self:Printf("OvaleGUID:Update %s", unitId) local guid = API_UnitGUID(unitId) local previousGuid = self_guid[unitId] if previousGuid ~= guid then @@ -69,7 +69,7 @@ function OvaleGUID:Update(unitId) if not self_unitId[guid] then self_unitId[guid] = {} end - Ovale:DebugPrint("guid", "GUID "..guid.." is ".. unitId) + Ovale:DebugPrintf("guid", "GUID %s is %s", guid, unitId) self_unitId[guid][unitId] = true end end diff --git a/OvaleIcone.lua b/OvaleIcone.lua index f2a31b6..94ac94e 100644 --- a/OvaleIcone.lua +++ b/OvaleIcone.lua @@ -202,8 +202,8 @@ local function SetParams(self, params, secure) local prefix = strsub(k, 1, f-1) local suffix = strsub(k, f + 5) local param - Ovale:Print(prefix.."type"..suffix) - self:SetAttribute(prefix.."type"..suffix, "spell") + Ovale:Printf("%stype%s", prefix, suffix) + self:SetAttribute(prefix .. "type" .. suffix, "spell") self:SetAttribute("unit", self.params.target or "target") self:SetAttribute(k, OvaleData.spellList[v]) self.actionButton = true diff --git a/OvalePaperDoll.lua b/OvalePaperDoll.lua index bef4ded..2f00dbd 100644 --- a/OvalePaperDoll.lua +++ b/OvalePaperDoll.lua @@ -202,21 +202,21 @@ function OvalePaperDoll:GetSpellHasteMultiplier() end function OvalePaperDoll:Debug() - Ovale:Print("Class: " .. self.class) - Ovale:Print("Level: " .. self.level) - Ovale:Print("Specialization: " .. self.specialization) - Ovale:Print("Agility: " ..self.agility) - Ovale:Print("Intellect: " ..self.intellect) - Ovale:Print("Spirit: " ..self.spirit) - Ovale:Print("Stamina: " ..self.stamina) - Ovale:Print("Strength: " ..self.strength) - Ovale:Print("AP: " ..self.attackPower) - Ovale:Print("RAP: " ..self.rangedAttackPower) - Ovale:Print("Spell bonus damage: " ..self.spellBonusDamage) - Ovale:Print("Spell bonus healing: " ..self.spellBonusHealing) - Ovale:Print("Spell haste effect: " ..self.spellHaste.. "%") - Ovale:Print("Melee haste effect: " ..self.meleeHaste.. "%") - Ovale:Print("Ranged haste effect: " ..self.rangedHaste.. "%") - Ovale:Print("Mastery effect: " ..self.masteryEffect.. "%") + Ovale:Printf("Class: %s", self.class) + Ovale:Printf("Level: %d", self.level) + Ovale:Printf("Specialization: %s", self.specialization) + Ovale:Printf("Agility: %d", self.agility) + Ovale:Printf("Intellect: %d", self.intellect) + Ovale:Printf("Spirit: %d", self.spirit) + Ovale:Printf("Stamina: %d", self.stamina) + Ovale:Printf("Strength: %d", self.strength) + Ovale:Printf("AP: %d", self.attackPower) + Ovale:Printf("RAP: %d", self.rangedAttackPower) + Ovale:Printf("Spell bonus damage: %d", self.spellBonusDamage) + Ovale:Printf("Spell bonus healing: %d", self.spellBonusHealing) + Ovale:Printf("Spell haste effect: %f%%", self.spellHaste) + Ovale:Printf("Melee haste effect: %f%%", self.meleeHaste) + Ovale:Printf("Ranged haste effect: %f%%", self.rangedHaste) + Ovale:Printf("Mastery effect: %f%%", self.masteryEffect) end -- diff --git a/OvalePool.lua b/OvalePool.lua index d305d74..7e51e09 100644 --- a/OvalePool.lua +++ b/OvalePool.lua @@ -57,6 +57,6 @@ function OvalePool:Drain() end function OvalePool:Debug() - Ovale:Print("Pool " .. tostring(self.name) .. " has size " .. self.size .. " with " .. self.unused .. " item(s).") + Ovale:Printf("Pool %s has size %d with %d item(s).", self.name, self.size, self.unused) end -- diff --git a/OvaleStance.lua b/OvaleStance.lua index af6b04e..2741b42 100644 --- a/OvaleStance.lua +++ b/OvaleStance.lua @@ -129,7 +129,7 @@ function OvaleStance:DebugStances() end function OvaleStance:Debug() - Ovale:Print("current stance: " .. self_stance) + Ovale:Printf("current stance: %s", self_stance) end -- Return true if the current stance matches the given name. diff --git a/OvaleState.lua b/OvaleState.lua index c52d377..fd22296 100644 --- a/OvaleState.lua +++ b/OvaleState.lua @@ -133,7 +133,7 @@ function OvaleState:Reset() self.lastSpellId = OvaleFuture.lastSpellId self.serial = self.serial + 1 self.currentTime = self.maintenant - Ovale:Log("Reset state with current time = " .. self.currentTime) + Ovale:Logf("Reset state with current time = %f", self.currentTime) self.currentSpellId = nil self.attenteFinCast = self.maintenant self.state.combo = OvaleComboPoints.combo @@ -217,9 +217,7 @@ function OvaleState:ApplySpell(spellId, startCast, endCast, nextCast, nocd, targ self.currentTime = self.maintenant end - if Ovale.trace then - Ovale:Print("add spell "..spellId.." at "..startCast.." currentTime = "..self.currentTime.. " nextCast="..self.attenteFinCast .. " endCast="..endCast .. " targetGUID = " .. tostring(targetGUID)) - end + Ovale:Logf("add spell %d at %f currentTime = %f nextCast=%f endCast=%f targetGUID=%s", spellId, startCast, self.currentTime, self.attenteFinCast, endCast, targetGUID) --Effet du sort au moment du début du cast --(donc si cast déjà commencé, on n'en tient pas compte) @@ -330,8 +328,7 @@ function OvaleState:ApplySpell(spellId, startCast, endCast, nextCast, nocd, targ if si.buffnocd then local buffStart, buffEnding, buffStacks = self:GetAura("player", si.buffnocd) if buffStart then - Ovale:Print("buffnocd stacks = "..tostring(buffStacks).." start="..tostring(buffStart).." ending = "..tostring(buffEnding)) - Ovale:Print("startCast = "..startCast) + Ovale:Logf("buffnocd stacks = %s, start = %s, ending = %s, startCast = %f", buffStacks, buffStart, buffEnding, startCast) end if buffStacks and buffStacks > 0 and buffStart and buffStart <= startCast and (not buffEnding or buffEnding > startCast) then cd.duration = 0 @@ -409,16 +406,16 @@ function OvaleState:ApplySpell(spellId, startCast, endCast, nextCast, nocd, targ newAura.mine = true if stacks ~= "refresh" and stacks == 0 then - Ovale:Log("Aura "..auraSpellId.." is completely removed") + Ovale:Logf("Aura %d is completely removed", auraSpellId) newAura.stacks = 0 newAura.ending = 0 -- self.currentTime? elseif oldEnding and oldEnding >= endCast then if stacks == "refresh" or stacks > 0 then if stacks == "refresh" then - Ovale:Log("Aura "..auraSpellId.." is refreshed") + Ovale:Logf("Aura %d is refreshed", auraSpellId) newAura.stacks = oldStacks else -- if stacks > 0 - Ovale:Log("Aura "..auraSpellId.." gain stacks (ending was " .. tostring(newAura.ending)..")") + Ovale:Logf("Aura %d gains stacks (ending was %s)", auraSpellId, newAura.ending) newAura.stacks = oldStacks + stacks end newAura.start = oldStart @@ -429,13 +426,11 @@ function OvaleState:ApplySpell(spellId, startCast, endCast, nextCast, nocd, targ else newAura.ending = endCast + duration end - Ovale:Log("Aura "..auraSpellId.." ending is now "..newAura.ending) + Ovale:Logf("Aura %d ending is now %f", auraSpellId, newAura.ending) elseif stacks < 0 then - Ovale:Log("Aura "..auraSpellId.." loses stacks") + Ovale:Logf("Aura %d loses stacks", auraSpellId) newAura.stacks = oldStacks + stacks - if Ovale.trace then - Ovale:Print("removing one stack of "..auraSpellId.." because of ".. spellId.." to ".. newAura.stacks) - end + Ovale:Logf("removing one stack of %d because of %d to %d", auraSpellId, spellId, newAura.stacks) newAura.start = oldStart newAura.ending = oldEnding if newAura.stacks <= 0 then @@ -445,7 +440,7 @@ function OvaleState:ApplySpell(spellId, startCast, endCast, nextCast, nocd, targ end end else - Ovale:Log("New aura "..auraSpellId.." at " .. endCast .." on " .. target .. " " .. auraGUID) + Ovale:Logf("New aura %d at %f on %s %s", auraSpellId, endCast, target, auraGUID) newAura.stacks = stacks newAura.start = endCast newAura.ending = endCast + duration @@ -547,10 +542,10 @@ function OvaleState:GetAuraByGUID(guid, spellId, filter, mine, unitId) end end if aura then - Ovale:Log("Found " .. filter .. " aura " .. spellId .. " on " .. tostring(guid)) + Ovale:Logf("Found %s aura %s on %s", filter, spellId, guid) return aura.start, aura.ending, aura.stacks, aura.tick, aura.value, aura.gain else - Ovale:Log("Aura " .. spellId .. " not found in state for " .. tostring(guid)) + Ovale:Logf("Aura %s not found in state for %s", spellId, guid) return OvaleAura:GetAuraByGUID(guid, spellId, filter, mine, unitId) end end -- 1.7.9.5