Johnny C. Lam [09-26-13 - 05:34]
diff --git a/Ovale.lua b/Ovale.lua
index ddd2041..877e027 100644
--- a/Ovale.lua
+++ b/Ovale.lua
@@ -73,20 +73,6 @@ BINDING_NAME_OVALE_CHECKBOX3 = L["Inverser la boîte à cocher "].."(4)"
BINDING_NAME_OVALE_CHECKBOX4 = L["Inverser la boîte à cocher "].."(5)"
--<private-static-methods>
--- format() wrapper that turns nil arguments into tostring(nil)
-local function Format(...)
- local arg = {}
- for i = 1, select("#", ...) do
- local v = select(i, ...)
- if type(v) == "boolean" then
- arg[i] = v and OVALE_TRUE_STRING or OVALE_FALSE_STRING
- else
- arg[i] = v or OVALE_NIL_STRING
- end
- end
- return format(unpack(arg))
-end
-
local function OnCheckBoxValueChanged(widget)
OvaleOptions:GetProfile().check[widget.userdata.k] = widget:GetValue()
if Ovale.casesACocher[widget.userdata.k].compile then
@@ -321,8 +307,22 @@ function Ovale:SendScoreToDamageMeter(name, guid, scored, scoreMax)
end
-- Debugging methods.
+-- format() wrapper that turns nil arguments into tostring(nil)
+function Ovale:Format(...)
+ local arg = {}
+ for i = 1, select("#", ...) do
+ local v = select(i, ...)
+ if type(v) == "boolean" then
+ arg[i] = v and OVALE_TRUE_STRING or OVALE_FALSE_STRING
+ else
+ arg[i] = v or OVALE_NIL_STRING
+ end
+ end
+ return format(unpack(arg))
+end
+
function Ovale:FormatPrint(...)
- self:Print(Format(...))
+ self:Print(self:Format(...))
end
function Ovale:DebugPrint(flag, ...)
@@ -335,7 +335,17 @@ 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(...))
+ local addTimestamp = select(1, ...)
+ if type(addTimestamp) == "boolean" or type(addTimestamp) == "nil" then
+ if addTimestamp then
+ local now = API_GetTime()
+ self:Printf("[%s] @%f %s", flag, now, self:Format(select(2, ...)))
+ else
+ self:Printf("[%s] %s", flag, self:Format(select(2, ...)))
+ end
+ else
+ self:Printf("[%s] %s", flag, self:Format(...))
+ end
end
end
@@ -345,7 +355,7 @@ function Ovale:Error(...)
end
function Ovale:Errorf(...)
- self:Printf("Fatal error: %s", Format(...))
+ self:Printf("Fatal error: %s", self:Format(...))
self.bug = true
end
@@ -357,7 +367,7 @@ end
function Ovale:Logf(...)
if self.trace then
- return self:Printf(Format(...))
+ return self:FormatPrint(...)
end
end
--</public-static-methods>
diff --git a/OvaleAura.lua b/OvaleAura.lua
index 98dac63..b6a832b 100644
--- a/OvaleAura.lua
+++ b/OvaleAura.lua
@@ -299,7 +299,6 @@ local function UpdateAuraTick(guid, spellId, timestamp)
end
end
if aura and aura.tick then
- local now = API_GetTime()
local tick = aura.tick
local ticksSeen = aura.ticksSeen or 0
if not aura.lastTickTime then
@@ -317,7 +316,7 @@ local function UpdateAuraTick(guid, spellId, timestamp)
aura.lastTickTime = timestamp
aura.tick = tick
aura.ticksSeen = ticksSeen
- Ovale:DebugPrintf(OVALE_AURA_DEBUG, "Updating %s %s (%s) on %s at %f, tick=%f", filter, aura.name, spellId, guid, now, tick)
+ Ovale:DebugPrintf(OVALE_AURA_DEBUG, "Updating %s %s (%s) on %s, tick=%f", filter, aura.name, spellId, guid, tick)
end
end
--</private-static-methods>
diff --git a/OvaleDamageTaken.lua b/OvaleDamageTaken.lua
index 0ef528d..58ae81d 100644
--- a/OvaleDamageTaken.lua
+++ b/OvaleDamageTaken.lua
@@ -41,7 +41,7 @@ local function AddDamageTaken(timestamp, damage)
event.timestamp = timestamp
event.damage = damage
self_damageEvent:InsertFront(event)
- self:RemoveExpiredEvents()
+ self:RemoveExpiredEvents(timestamp)
end
--</private-static-methods>
@@ -85,7 +85,7 @@ function OvaleDamageTaken:GetRecentDamage(interval, lagCorrection)
if lagCorrection then
lowerBound = lowerBound - OvaleLatency:GetLatency()
end
- self:RemoveExpiredEvents()
+ self:RemoveExpiredEvents(now)
local total = 0
for i, event in self_damageEvent:FrontToBackIterator() do
@@ -97,13 +97,13 @@ function OvaleDamageTaken:GetRecentDamage(interval, lagCorrection)
return total
end
-function OvaleDamageTaken:RemoveExpiredEvents()
- local now = API_GetTime()
+-- Remove all events that are more than DAMAGE_TAKEN_WINDOW seconds before the given timestamp.
+function OvaleDamageTaken:RemoveExpiredEvents(timestamp)
while true do
local event = self_damageEvent:Back()
if not event then break end
if event then
- if now - event.timestamp < DAMAGE_TAKEN_WINDOW then
+ if timestamp - event.timestamp < DAMAGE_TAKEN_WINDOW then
break
end
self_damageEvent:RemoveBack()
diff --git a/OvaleFuture.lua b/OvaleFuture.lua
index 528f0e7..827a869 100644
--- a/OvaleFuture.lua
+++ b/OvaleFuture.lua
@@ -79,7 +79,8 @@ local function TracePrintf(spellId, ...)
name = OvaleData:GetSpellName(spellId)
end
if self.traceSpellList[spellId] or self.traceSpellList[name] then
- Ovale:FormatPrint(...)
+ local now = API_GetTime()
+ Ovale:Printf("[trace] @%f %s", now, Ovale:Format(...))
end
end
end
@@ -136,9 +137,8 @@ local function AddSpellToQueue(spellId, lineId, startTime, endTime, channeled, a
else
spellcast.target = API_UnitGUID("target")
end
- local now = API_GetTime()
- TracePrintf(spellId, " AddSpellToQueue: %f %s (%d), lineId=%d, startTime=%f, endTime=%f, target=%s",
- now, OvaleData:GetSpellName(spellId), spellId, lineId, startTime, endTime, spellcast.target)
+ TracePrintf(spellId, " AddSpellToQueue: %s (%d), lineId=%d, startTime=%f, endTime=%f, target=%s",
+ OvaleData:GetSpellName(spellId), spellId, lineId, startTime, endTime, spellcast.target)
-- Snapshot the current stats for the spellcast.
OvalePaperDoll:SnapshotStats(spellcast)
@@ -194,10 +194,9 @@ end
local function RemoveSpellFromQueue(spellId, lineId)
local self = OvaleFuture
- local now = API_GetTime()
for index, spellcast in ipairs(self_activeSpellcast) do
if spellcast.lineId == lineId then
- TracePrintf(spellId, " RemoveSpellFromQueue: %f %s (%d)", now, OvaleData:GetSpellName(spellId), spellId)
+ TracePrintf(spellId, " RemoveSpellFromQueue: %s (%d)", OvaleData:GetSpellName(spellId), spellId)
tremove(self_activeSpellcast, index)
self_pool:Release(spellcast)
break
@@ -301,17 +300,15 @@ end
function OvaleFuture:UNIT_SPELLCAST_CHANNEL_START(event, unit, name, rank, lineId, spellId)
if unit == "player" then
local startTime, endTime = select(5, API_UnitChannelInfo("player"))
- local now = API_GetTime()
- TracePrintf(spellId, "%s: %f %d, lineId=%d, startTime=%f, endTime=%f",
- event, now, spellId, lineId, startTime, endTime)
+ TracePrintf(spellId, "%s: %d, lineId=%d, startTime=%f, endTime=%f",
+ event, spellId, lineId, startTime, endTime)
AddSpellToQueue(spellId, lineId, startTime/1000, endTime/1000, true, false)
end
end
function OvaleFuture:UNIT_SPELLCAST_CHANNEL_STOP(event, unit, name, rank, lineId, spellId)
if unit == "player" then
- local now = API_GetTime()
- TracePrintf(spellId, "%s: %f %d, lineId=%d", event, now, spellId, lineId)
+ TracePrintf(spellId, "%s: %d, lineId=%d", event, spellId, lineId)
RemoveSpellFromQueue(spellId, lineId)
end
end
@@ -320,9 +317,8 @@ end
function OvaleFuture:UNIT_SPELLCAST_START(event, unit, name, rank, lineId, spellId)
if unit == "player" then
local startTime, endTime = select(5, API_UnitCastingInfo("player"))
- local now = API_GetTime()
- TracePrintf(spellId, "%s: %f %d, lineId=%d, startTime=%f, endTime=%f",
- event, now, spellId, lineId, startTime, endTime)
+ TracePrintf(spellId, "%s: %d, lineId=%d, startTime=%f, endTime=%f",
+ event, spellId, lineId, startTime, endTime)
AddSpellToQueue(spellId, lineId, startTime/1000, endTime/1000, false, false)
end
end
@@ -330,8 +326,7 @@ end
--Called if the player interrupted early his cast
function OvaleFuture:UNIT_SPELLCAST_INTERRUPTED(event, unit, name, rank, lineId, spellId)
if unit == "player" then
- local now = API_GetTime()
- TracePrintf(spellId, "%s: %f %d, lineId=%d", event, now, spellId, lineId)
+ TracePrintf(spellId, "%s: %d, lineId=%d", event, spellId, lineId)
RemoveSpellFromQueue(spellId, lineId)
end
end
@@ -354,8 +349,7 @@ function OvaleFuture:UNIT_SPELLCAST_SENT(event, unit, spell, rank, target, lineI
else
self_lastTarget = OVALE_UNKNOWN_GUID
end
- local now = API_GetTime()
- TracePrintf(spell, "%s: %f %s on %s, lineId=%d", event, now, spell, self_lastTarget, lineId)
+ TracePrintf(spell, "%s: %s on %s, lineId=%d", event, spell, self_lastTarget, lineId)
end
end
@@ -371,8 +365,7 @@ end
]]--
function OvaleFuture:UNIT_SPELLCAST_SUCCEEDED(event, unit, name, rank, lineId, spellId)
if unit == "player" then
- local now = API_GetTime()
- TracePrintf(spellId, "%s: %f %d, lineId=%d", event, now, spellId, lineId)
+ TracePrintf(spellId, "%s: %d, lineId=%d", event, spellId, lineId)
-- Search for a cast-time spell matching this spellcast that was added by UNIT_SPELLCAST_START.
for _, spellcast in ipairs(self_activeSpellcast) do
@@ -393,6 +386,7 @@ function OvaleFuture:UNIT_SPELLCAST_SUCCEEDED(event, unit, name, rank, lineId, s
UNIT_SPELLCAST_CHANNEL_START and UNIT_SPELLCAST_CHANNEL_STOP.
]]--
if not API_UnitChannelInfo("player") then
+ local now = API_GetTime()
AddSpellToQueue(spellId, lineId, now, now, false, true)
end
end
@@ -444,12 +438,11 @@ function OvaleFuture:COMBAT_LOG_EVENT_UNFILTERED(event, ...)
if sourceGUID == OvaleGUID:GetGUID("player") then
if OVALE_CLEU_SPELLCAST_RESULTS[event] then
local spellId, spellName = select(12, ...)
- local now = API_GetTime()
- TracePrintf(spellId, "%s: %f %s (%d)", event, now, spellName, spellId)
+ TracePrintf(spellId, "%s: %s (%d)", event, spellName, spellId)
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 event ~= "SPELL_CAST_SUCCESS") then
- TracePrintf(spellId, " Spell finished: %f %s (%d)", now, spellName, spellId)
+ TracePrintf(spellId, " Spell finished: %s (%d)", spellName, spellId)
tremove(self_activeSpellcast, index)
UpdateLastSpellInfo(spellcast)
Ovale.refreshNeeded["player"] = true
diff --git a/OvalePaperDoll.lua b/OvalePaperDoll.lua
index c341fc3..d5c4762 100644
--- a/OvalePaperDoll.lua
+++ b/OvalePaperDoll.lua
@@ -146,7 +146,7 @@ local function GetSnapshot(t)
newStat.snapshotTime = now
self_snapshot:InsertFront(newStat)
stat = self_snapshot:Front()
- Ovale:DebugPrintf(OVALE_SNAPSHOT_DEBUG, "New snapshot at %f.", now)
+ Ovale:DebugPrintf(OVALE_SNAPSHOT_DEBUG, true, "New snapshot.")
end
return stat
end
@@ -208,7 +208,7 @@ function OvalePaperDoll:COMBAT_RATING_UPDATE(event)
self.stat.meleeCrit = API_GetCritChance()
self.stat.rangedCrit = API_GetRangedCritChance()
self.stat.spellCrit = API_GetSpellCritChance(OVALE_SPELLDAMAGE_SCHOOL[self.class])
- Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, "%s @ %f", event, now)
+ Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, true, "%s", event)
Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, " %s = %f%%", OVALE_SNAPSHOT_STATS.meleeCrit, self.stat.meleeCrit)
Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, " %s = %f%%", OVALE_SNAPSHOT_STATS.rangedCrit, self.stat.rangedCrit)
Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, " %s = %f%%", OVALE_SNAPSHOT_STATS.spellCrit, self.stat.spellCrit)
@@ -221,23 +221,22 @@ function OvalePaperDoll:MASTERY_UPDATE(event)
self.stat.masteryEffect = 0
else
self.stat.masteryEffect = API_GetMasteryEffect()
- Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, "%s @ %f: %s = %f%%",
- event, now, OVALE_SNAPSHOT_STATS.masteryEffect, self.stat.masteryEffect)
+ Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, true, "%s: %s = %f%%",
+ event, OVALE_SNAPSHOT_STATS.masteryEffect, self.stat.masteryEffect)
end
end
function OvalePaperDoll:PLAYER_LEVEL_UP(event, level, ...)
self.level = tonumber(level) or API_UnitLevel("player")
- local now = API_GetTime()
- Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, "%s @ %f: level = %d", event, now, self.level)
+ Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, true, "%s: level = %d", event, self.level)
end
function OvalePaperDoll:PLAYER_DAMAGE_DONE_MODS(event, unitId)
local now = API_GetTime()
self.stat = GetSnapshot(now)
self.stat.spellBonusHealing = API_GetSpellBonusHealing()
- Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, "%s @ %f: %s = %d",
- event, now, OVALE_SNAPSHOT_STATS.spellBonusHealing, self.stat.spellBonusHealing)
+ Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, true, "%s: %s = %d",
+ event, OVALE_SNAPSHOT_STATS.spellBonusHealing, self.stat.spellBonusHealing)
end
function OvalePaperDoll:PLAYER_REGEN_ENABLED(event)
@@ -248,8 +247,8 @@ function OvalePaperDoll:SPELL_POWER_CHANGED(event)
local now = API_GetTime()
self.stat = GetSnapshot(now)
self.stat.spellBonusDamage = API_GetSpellBonusDamage(OVALE_SPELLDAMAGE_SCHOOL[self.class])
- Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, "%s @ %f: %s = %d",
- event, now, OVALE_SNAPSHOT_STATS.spellBonusDamage, self.stat.spellBonusDamage)
+ Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, true, "%s: %s = %d",
+ event, OVALE_SNAPSHOT_STATS.spellBonusDamage, self.stat.spellBonusDamage)
end
function OvalePaperDoll:UNIT_ATTACK_POWER(event, unitId)
@@ -258,8 +257,8 @@ function OvalePaperDoll:UNIT_ATTACK_POWER(event, unitId)
self.stat = GetSnapshot(now)
local base, posBuff, negBuff = API_UnitAttackPower(unitId)
self.stat.attackPower = base + posBuff + negBuff
- Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, "%s @ %f: %s = %d",
- event, now, OVALE_SNAPSHOT_STATS.attackPower, self.stat.attackPower)
+ Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, true, "%s: %s = %d",
+ event, OVALE_SNAPSHOT_STATS.attackPower, self.stat.attackPower)
self:UpdateDamage(event)
end
end
@@ -267,16 +266,14 @@ end
function OvalePaperDoll:UNIT_DISPLAYPOWER(event, unitId)
if unitId == "player" then
self.powerType = API_UnitPowerType(unitId)
- local now = API_GetTime()
- Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, "%s @ %f: power type = %d", event, now, self.powerType)
+ Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, true, "%s: power type = %d", event, self.powerType)
end
end
function OvalePaperDoll:UNIT_LEVEL(event, unitId)
if unitId == "player" then
self.level = API_UnitLevel(unitId)
- local now = API_GetTime()
- Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, "%s @ %f: level = %d", event, now, self.level)
+ Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, true, "%s: level = %d", event, self.level)
end
end
@@ -285,8 +282,8 @@ function OvalePaperDoll:UNIT_RANGEDDAMAGE(event, unitId)
local now = API_GetTime()
self.stat = GetSnapshot(now)
self.stat.rangedHaste = API_GetRangedHaste()
- Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, "%s @ %f: %s = %f%%",
- event, now, OVALE_SNAPSHOT_STATS.rangedHaste, self.stat.rangedHaste)
+ Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, true, "%s: %s = %f%%",
+ event, OVALE_SNAPSHOT_STATS.rangedHaste, self.stat.rangedHaste)
end
end
@@ -296,8 +293,8 @@ function OvalePaperDoll:UNIT_RANGED_ATTACK_POWER(event, unitId)
local now = API_GetTime()
self.stat = GetSnapshot(now)
self.stat.rangedAttackPower = base + posBuff + negBuff
- Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, "%s @ %f: %s = %d",
- event, now, OVALE_SNAPSHOT_STATS.rangedAttackPower, self.stat.rangedAttackPower)
+ Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, true, "%s: %s = %d",
+ event, OVALE_SNAPSHOT_STATS.rangedAttackPower, self.stat.rangedAttackPower)
end
end
@@ -307,7 +304,7 @@ function OvalePaperDoll:UNIT_SPELL_HASTE(event, unitId)
self.stat = GetSnapshot(now)
self.stat.meleeHaste = API_GetMeleeHaste()
self.stat.spellHaste = API_UnitSpellHaste(unitId)
- Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, "%s @ %f", event, now)
+ Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, true, "%s", event)
Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, " %s = %f%%", OVALE_SNAPSHOT_STATS.meleeHaste, self.stat.meleeHaste)
Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, " %s = %f%%", OVALE_SNAPSHOT_STATS.spellHaste, self.stat.spellHaste)
self:UpdateDamage(event)
@@ -324,7 +321,7 @@ function OvalePaperDoll:UNIT_STATS(event, unitId)
self.stat.stamina = API_UnitStat(unitId, 3)
self.stat.intellect = API_UnitStat(unitId, 4)
self.stat.spirit = API_UnitStat(unitId, 5)
- Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, "%s @ %f", event, now)
+ Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, true, "%s", event)
Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, " %s = %d", OVALE_SNAPSHOT_STATS.agility, self.stat.agility)
Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, " %s = %d", OVALE_SNAPSHOT_STATS.intellect, self.stat.intellect)
Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, " %s = %d", OVALE_SNAPSHOT_STATS.spirit, self.stat.spirit)
@@ -385,7 +382,7 @@ function OvalePaperDoll:UpdateDamage(event)
self.stat.offHandWeaponDamage = 0
end
- Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, "%s @ %f", event, now)
+ Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, true, "%s", event)
Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, " %s = %f", OVALE_SNAPSHOT_STATS.baseDamageMultiplier, self.stat.baseDamageMultiplier)
Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, " %s = %f", OVALE_SNAPSHOT_STATS.mainHandWeaponDamage, self.stat.mainHandWeaponDamage)
Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, " %s = %f", OVALE_SNAPSHOT_STATS.offHandWeaponDamage, self.stat.offHandWeaponDamage)
@@ -408,6 +405,7 @@ end
function OvalePaperDoll:UpdatePowerRegen(event)
self.inactiveRegen, self.activeRegen = API_GetPowerRegen()
+ Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, true, "%s", event)
Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, " %s = %f", "active regen", self.activeRegen)
Ovale:DebugPrintf(OVALE_PAPERDOLL_DEBUG, " %s = %f", "inactive regen", self.inactiveRegen)
end