Johnny C. Lam [11-26-13 - 14:05]
diff --git a/OvaleAura.lua b/OvaleAura.lua
index aee9d36..f06ffcf 100644
--- a/OvaleAura.lua
+++ b/OvaleAura.lua
@@ -514,6 +514,13 @@ function OvaleAura:ResetState(state)
state.serial = state.serial + 1
end
+-- Release state resources prior to removing from the simulator.
+function OvaleAura:CleanState(state)
+ for guid in pairs(state.aura) do
+ RemoveAurasOnGUID(state.aura, guid)
+ end
+end
+
-- Apply the effects of the spell on the player's state, assuming the spellcast completes.
function OvaleAura:ApplySpellAfterCast(state, spellId, targetGUID, startCast, endCast, nextCast, isChanneled, nocd, spellcast)
local si = OvaleData.spellInfo[spellId]
diff --git a/OvaleCooldown.lua b/OvaleCooldown.lua
index f4f21ac..412fa51 100644
--- a/OvaleCooldown.lua
+++ b/OvaleCooldown.lua
@@ -112,6 +112,16 @@ function OvaleCooldown:ResetState(state)
end
end
+-- Release state resources prior to removing from the simulator.
+function OvaleCooldown:CleanState(state)
+ for spellId, cd in pairs(state.cd) do
+ for k in pairs(cd) do
+ cd[k] = nil
+ end
+ state.cd[spellId] = nil
+ end
+end
+
-- Apply the effects of the spell on the player's state, assuming the spellcast completes.
function OvaleCooldown:ApplySpellAfterCast(state, spellId, targetGUID, startCast, endCast, nextCast, isChanneled, nocd, spellcast)
local si = OvaleData.spellInfo[spellId]
diff --git a/OvaleFuture.lua b/OvaleFuture.lua
index 8720435..6012328 100644
--- a/OvaleFuture.lua
+++ b/OvaleFuture.lua
@@ -599,6 +599,13 @@ function OvaleFuture:ResetState(state)
end
end
+-- Release state resources prior to removing from the simulator.
+function OvaleFuture:CleanState(state)
+ for k in pairs(state.counter) do
+ state.counter[k] = nil
+ end
+end
+
-- Apply the effects of the spell at the start of the spellcast.
function OvaleFuture:ApplySpellStartCast(state, spellId, targetGUID, startCast, endCast, nextCast, isChanneled, nocd, spellcast)
local si = OvaleData.spellInfo[spellId]
diff --git a/OvalePaperDoll.lua b/OvalePaperDoll.lua
index 9e1692c..5aa9710 100644
--- a/OvalePaperDoll.lua
+++ b/OvalePaperDoll.lua
@@ -508,6 +508,11 @@ function OvalePaperDoll:ResetState(state)
end
state.snapshot = state.snapshot or self_pool:GetReference(self.snapshot)
end
+
+-- Release state resources prior to removing from the simulator.
+function OvalePaperDoll:CleanState(state)
+ self_pool:ReleaseReference(state.snapshot)
+end
--</public-static-methods>
--<state-methods>
diff --git a/OvalePower.lua b/OvalePower.lua
index dded77d..c9dfca5 100644
--- a/OvalePower.lua
+++ b/OvalePower.lua
@@ -242,6 +242,16 @@ function OvalePower:ResetState(state)
end
end
+-- Release state resources prior to removing from the simulator.
+function OvalePower:CleanState(state)
+ for powerType in pairs(self.POWER_INFO) do
+ state[powerType] = nil
+ end
+ for k in pairs(state.powerRate) do
+ state.powerRate[k] = nil
+ end
+end
+
-- Apply the effects of the spell on the player's state, assuming the spellcast completes.
function OvalePower:ApplySpellAfterCast(state, spellId, targetGUID, startCast, endCast, nextCast, isChanneled, nocd, spellcast)
local si = OvaleData.spellInfo[spellId]
diff --git a/OvaleRunes.lua b/OvaleRunes.lua
index 99c4c0f..aa37d6d 100644
--- a/OvaleRunes.lua
+++ b/OvaleRunes.lua
@@ -203,6 +203,16 @@ function OvaleRunes:ResetState(state)
end
end
+-- Release state resources prior to removing from the simulator.
+function OvaleRunes:CleanState(state)
+ for slot, rune in pairs(state.rune) do
+ for k in pairs(rune) do
+ rune[k] = nil
+ end
+ state.rune[slot] = nil
+ end
+end
+
-- Apply the effects of the spell on the player's state, assuming the spellcast completes.
function OvaleRunes:ApplySpellAfterCast(state, spellId, targetGUID, startCast, endCast, nextCast, isChanneled, nocd, spellcast)
local si = OvaleData.spellInfo[spellId]
diff --git a/OvaleState.lua b/OvaleState.lua
index cc4dcfa..e162cce 100644
--- a/OvaleState.lua
+++ b/OvaleState.lua
@@ -71,6 +71,11 @@ function OvaleState:UnregisterState(addon)
end
self_stateModules = stateModules
+ -- Release resources used by the state machine managed by the addon.
+ if addon.CleanState then
+ addon:CleanState(self.state)
+ end
+
-- Remove mix-in methods from addon's state prototype.
local statePrototype = self_statePrototype[addon]
for k in pairs(statePrototype) do