Johnny C. Lam [03-31-13 - 18:55]
diff --git a/OvaleFuture.lua b/OvaleFuture.lua
index 3082722..689bdb5 100644
--- a/OvaleFuture.lua
+++ b/OvaleFuture.lua
@@ -356,40 +356,26 @@ function OvaleFuture:COMBAT_LOG_EVENT_UNFILTERED(event, ...)
end
end
---[[-----------------------------------------------------------------------
- Iterator for spells that are being cast or are in flight.
-
- The iterator returns:
- spellId: ID of the spell
- lineId: spell counter (see documentation for UNIT_SPELLCAST_START)
- startCast: the time the spell started being cast
- endCast: the time the spell cast will end
- nextCast: the time the next spell can be cast
- nocd: true if the spell has no cooldown
- target: the target of the spell (can be nil)
---]]-----------------------------------------------------------------------
-function OvaleFuture:InFlightSpells(now)
+-- Apply spells that are being cast or are in flight.
+function OvaleFuture:ApplyInFlightSpells(now, ApplySpell)
local index = 0
local spellcast, si
- return function()
- while true do
- index = index + 1
- if index > #self_activeSpellcast then return end
-
- spellcast = self_activeSpellcast[index]
- si = OvaleData.spellInfo[spellcast.spellId]
- -- skip over spells that are toggles for other spells
- if not (si and si.toggle) then
- 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
- tremove(self_activeSpellcast, index)
- self_pool:Release(spellcast)
- -- Decrement current index since item was removed and rest of items shifted up.
- index = index - 1
- end
- break
+ while true do
+ index = index + 1
+ if index > #self_activeSpellcast then return end
+
+ spellcast = self_activeSpellcast[index]
+ si = OvaleData.spellInfo[spellcast.spellId]
+ -- skip over spells that are toggles for other spells
+ if not (si and si.toggle) then
+ Ovale:Logf("now = %f, spellId = %d, endCast = %f", now, spellcast.spellId, spellcast.stop)
+ if now - spellcast.stop < 5 then
+ ApplySpell(spellcast.spellId, spellcast.lineId, spellcast.start, spellcast.stop, spellcast.stop, spellcast.nocd, spellcast.target)
+ else
+ tremove(self_activeSpellcast, index)
+ self_pool:Release(spellcast)
+ -- Decrement current index since item was removed and rest of items shifted up.
+ index = index - 1
end
end
end
diff --git a/OvaleState.lua b/OvaleState.lua
index e8ce254..3330f1e 100644
--- a/OvaleState.lua
+++ b/OvaleState.lua
@@ -61,6 +61,13 @@ OvaleState.powerRate = {}
OvaleState.lastSpellId = nil
--</public-static-properties>
+--<private-static-methods>
+local function ApplySpell(spellId, startCast, endCast, nextCast, nocd, targetGUID)
+ local self = OvaleState
+ self:ApplySpell(spellId, startCast, endCast, nextCast, nocd, targetGUID)
+end
+--</private-static-methods>
+
--<public-static-methods>
function OvaleState:StartNewFrame()
self.maintenant = Ovale.now
@@ -186,9 +193,7 @@ end
-- Apply the effects of spells that are being cast or are in flight, allowing us to
-- ignore lag or missile travel time.
function OvaleState:ApplyActiveSpells()
- for spellId, _, startCast, endCast, nextCast, nocd, target in OvaleFuture:InFlightSpells(self.maintenant) do
- OvaleState:ApplySpell(spellId, startCast, endCast, nextCast, nocd, target)
- end
+ OvaleFuture:ApplyInFlightSpells(self.maintenant, ApplySpell)
end
-- Cast a spell in the simulator