Quantcast

Fix ticket 259 - Snapshots not reliable for macro'ed abilities

Johnny C. Lam [07-13-13 - 20:58]
Fix ticket 259 - Snapshots not reliable for macro'ed abilities

Force OvalePaperDoll to update stats prior to a snapshot being taken if
the live stats are requested.

Also remove the explicit copy of damageMultiplier, which is now included
as a baseline player stat.

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@968 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
OvaleAura.lua
OvaleFuture.lua
OvalePaperDoll.lua
OvaleState.lua
diff --git a/OvaleAura.lua b/OvaleAura.lua
index 32aea8f..ae83ca6 100644
--- a/OvaleAura.lua
+++ b/OvaleAura.lua
@@ -138,7 +138,8 @@ local function UnitGainedAura(event, guid, spellId, filter, casterGUID, icon, co
 	)
 	local addAura = not existingAura or not auraIsUnchanged
 	if addAura then
-		Ovale:DebugPrintf(OVALE_AURA_DEBUG, "Adding %s %s (%s) to %s, aura.serial=%d", filter, name, spellId, guid, aura.serial)
+		Ovale:DebugPrintf(OVALE_AURA_DEBUG, "%s: Adding %s %s (%s) to %s, aura.serial=%d",
+			event, filter, name, spellId, guid, aura.serial)
 		aura.icon = icon
 		aura.stacks = count
 		aura.debuffType = debuffType
@@ -162,9 +163,11 @@ local function UnitGainedAura(event, guid, spellId, filter, casterGUID, icon, co
 		if mine and (not existingAura or event == "SPELL_AURA_REFRESH") then
 			local si = OvaleData.spellInfo[spellId]
 			if si and si.tick then
+				Ovale:DebugPrintf(OVALE_AURA_DEBUG, "%s: Snapshot stats for %s %s (%s) on %s at %f, gain=%f, aura.serial=%d",
+					event, filter, name, spellId, guid, Ovale.now, aura.gain, aura.serial)
 				aura.ticksSeen = 0
 				aura.tick = OvaleData:GetTickLength(spellId)
-				OvalePaperDoll:SnapshotStats(aura.gain, aura)
+				OvalePaperDoll:SnapshotStats(aura)
 				aura.damageMultiplier = self:GetDamageMultiplier(spellId)
 			end
 		end
diff --git a/OvaleFuture.lua b/OvaleFuture.lua
index 8878b49..e50f423 100644
--- a/OvaleFuture.lua
+++ b/OvaleFuture.lua
@@ -111,7 +111,7 @@ local function AddSpellToQueue(spellId, lineId, startTime, endTime, channeled, a

 	-- Snapshot the current stats for the spellcast.
 	self.lastSpellId = spellId
-	OvalePaperDoll:SnapshotStats(Ovale.now, spellcast)
+	OvalePaperDoll:SnapshotStats(spellcast)
 	spellcast.damageMultiplier = OvaleAura:GetDamageMultiplier(spellId)
 	tinsert(self_activeSpellcast, spellcast)

@@ -295,7 +295,7 @@ function OvaleFuture:UNIT_SPELLCAST_SENT(event, unit, spell, rank, target, lineI
 			if spellcast.lineId == lineId then
 				spellcast.target = targetGUID
 				-- Update spellcast stats to the latest snapshot of the player's stats.
-				OvalePaperDoll:SnapshotStats(Ovale.now, spellcast)
+				OvalePaperDoll:SnapshotStats(spellcast)
 				spellcast.damageMultiplier = OvaleAura:GetDamageMultiplier(spellId)
 			end
 		end
diff --git a/OvalePaperDoll.lua b/OvalePaperDoll.lua
index 9bfea40..24db9b6 100644
--- a/OvalePaperDoll.lua
+++ b/OvalePaperDoll.lua
@@ -294,15 +294,13 @@ end

 -- Snapshot the stats into the given table using the same keynames as self.stat.
 -- If source is nil, then use the current player stats; otherwise, use the given stat table.
--- Only take the snapshot if the source snapshot time is older than timestamp.
-function OvalePaperDoll:SnapshotStats(timestamp, t, source)
-	source = source or self.stat
-	if timestamp and timestamp >= source.snapshotTime then
-		for k in pairs(self.stat) do
-			t[k] = source[k]
-		end
-		-- Also snapshot damageMultiplier if it's present (added by OvaleFuture and OvaleAura).
-		t.damageMultiplier = source.damageMultiplier
+function OvalePaperDoll:SnapshotStats(t, source)
+	if not source then
+		self:UpdateStats()
+		source = self.stat
+	end
+	for k in pairs(self.stat) do
+		t[k] = source[k]
 	end
 end

diff --git a/OvaleState.lua b/OvaleState.lua
index c79e2d6..e19d9cd 100644
--- a/OvaleState.lua
+++ b/OvaleState.lua
@@ -446,7 +446,7 @@ function OvaleState:ApplySpell(spellId, startCast, endCast, nextCast, nocd, targ
 										newAura.ending = (oldEnding - oldTick * remainingTicks) + duration
 										newAura.tick = OvaleData:GetTickLength(auraSpellId)
 										-- Re-snapshot stats for the DoT.
-										OvalePaperDoll:SnapshotStats(newAura.start, newAura, stats)
+										OvalePaperDoll:SnapshotStats(newAura, stats)
 										newAura.damageMultiplier = self:GetDamageMultiplier(auraSpellId)
 									else
 										newAura.ending = endCast + duration
@@ -471,7 +471,7 @@ function OvaleState:ApplySpell(spellId, startCast, endCast, nextCast, nocd, targ
 								newAura.ending = endCast + duration
 								if isDoT then
 									newAura.tick = OvaleData:GetTickLength(auraSpellId)
-									OvalePaperDoll:SnapshotStats(newAura.start, newAura, stats)
+									OvalePaperDoll:SnapshotStats(newAura, stats)
 									newAura.damageMultiplier = self:GetDamageMultiplier(auraSpellId)
 								end
 							end