Quantcast

Back out part of r1196 and defer saving the player's GUID.

Johnny C. Lam [11-26-13 - 14:03]
Back out part of r1196 and defer saving the player's GUID.

The player's GUID is actually not available at load-time and must wait
until more of the game is initialized before the information can be
queried.  Get the information during PLAYER_LOGIN time instead by adding
it to the OnEnable() methods.

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1198 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
OvaleAura.lua
OvaleDamageTaken.lua
OvaleEclipse.lua
OvaleFuture.lua
OvaleScore.lua
OvaleSpellDamage.lua
OvaleSwing.lua
diff --git a/OvaleAura.lua b/OvaleAura.lua
index 03cdce4..52a5196 100644
--- a/OvaleAura.lua
+++ b/OvaleAura.lua
@@ -343,7 +343,7 @@ function OvaleAura:OnInitialize()
 end

 function OvaleAura:OnEnable()
-	self_guid = OvaleGUID:GetGUID("player")
+	self_guid = API_UnitGUID("player")
 	self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
 	self:RegisterEvent("PLAYER_ENTERING_WORLD")
 	self:RegisterEvent("UNIT_AURA")
diff --git a/OvaleDamageTaken.lua b/OvaleDamageTaken.lua
index 1eb0a26..e9eedbd 100644
--- a/OvaleDamageTaken.lua
+++ b/OvaleDamageTaken.lua
@@ -25,7 +25,7 @@ local API_GetTime = GetTime
 local API_UnitGUID = UnitGUID

 -- Player's GUID.
-local self_guid = API_UnitGUID("player")
+local self_guid = nil
 -- Damage event pool.
 local self_pool = OvalePool("OvaleDamageTaken_pool")
 -- Damage event queue: new events are inserted at the front of the queue.
@@ -54,6 +54,7 @@ function OvaleDamageTaken:OnInitialize()
 end

 function OvaleDamageTaken:OnEnable()
+	self_guid = API_UnitGUID("player")
 	self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
 	self:RegisterEvent("PLAYER_REGEN_ENABLED")
 end
diff --git a/OvaleEclipse.lua b/OvaleEclipse.lua
index 651d778..bab7748 100644
--- a/OvaleEclipse.lua
+++ b/OvaleEclipse.lua
@@ -29,7 +29,7 @@ local API_UnitPower = UnitPower
 local SPELL_POWER_ECLIPSE = SPELL_POWER_ECLIPSE

 -- Player's GUID.
-local self_guid = API_UnitGUID("player")
+local self_guid = nil
 -- Player's class.
 local self_class = select(2, API_UnitClass("player"))

@@ -55,6 +55,7 @@ function OvaleEclipse:OnInitialize()
 end

 function OvaleEclipse:OnEnable()
+	self_guid = API_UnitGUID("player")
 	if self_class == "DRUID" then
 		self:RegisterEvent("ECLIPSE_DIRECTION_CHANGE", "UpdateEclipseDirection")
 		self:RegisterEvent("UNIT_POWER")
diff --git a/OvaleFuture.lua b/OvaleFuture.lua
index 9466278..f66edab 100644
--- a/OvaleFuture.lua
+++ b/OvaleFuture.lua
@@ -41,7 +41,7 @@ local API_UnitGUID = UnitGUID
 local API_UnitName = UnitName

 -- Player's GUID.
-local self_guid = API_UnitGUID("player")
+local self_guid = nil

 -- The spells that the player is casting or has cast but are still in-flight toward their targets.
 local self_activeSpellcast = {}
@@ -270,6 +270,7 @@ function OvaleFuture:OnInitialize()
 end

 function OvaleFuture:OnEnable()
+	self_guid = API_UnitGUID("player")
 	self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
 	self:RegisterEvent("PLAYER_ENTERING_WORLD")
 	self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START")
@@ -602,4 +603,4 @@ do
 		local state = self
 		return state.counter[id] and state.counter[id] or 0
 	end
-end
\ No newline at end of file
+end
diff --git a/OvaleScore.lua b/OvaleScore.lua
index f92f372..8f31f2f 100644
--- a/OvaleScore.lua
+++ b/OvaleScore.lua
@@ -33,7 +33,6 @@ local OvaleScore = Ovale:NewModule("OvaleScore", "AceEvent-3.0")
 Ovale.OvaleScore = OvaleScore

 --<private-static-properties>
--- Forward declarations for module dependencies.
 local pairs = pairs
 local strsplit = string.split
 local API_RegisterAddonMessagePrefix = RegisterAddonMessagePrefix
@@ -41,7 +40,7 @@ local API_SendAddonMessage = SendAddonMessage
 local API_UnitGUID = UnitGUID

 -- Player's GUID.
-local self_guid = API_UnitGUID("player")
+local self_guid = nil
 -- self_damageMeter[moduleName] = module
 local self_damageMeter = {}
 -- self_damageMeterMethod[moduleName] = methodName or function
@@ -59,6 +58,7 @@ local self_scoredSpell = {}

 --<public-static-methods>
 function OvaleScore:OnEnable()
+	self_guid = API_UnitGUID("player")
 	API_RegisterAddonMessagePrefix("Ovale")
 	self:RegisterEvent("CHAT_MSG_ADDON")
 	self:RegisterEvent("PLAYER_REGEN_ENABLED")
diff --git a/OvaleSpellDamage.lua b/OvaleSpellDamage.lua
index 05478f4..3322416 100644
--- a/OvaleSpellDamage.lua
+++ b/OvaleSpellDamage.lua
@@ -15,13 +15,12 @@ local OvaleSpellDamage = Ovale:NewModule("OvaleSpellDamage", "AceEvent-3.0")
 Ovale.OvaleSpellDamage = OvaleSpellDamage

 --<private-static-properties>
--- Forward declarations for module dependencies.
 local select = select
 local strfind = string.find
 local API_UnitGUID = UnitGUID

 -- Player's GUID.
-local self_guid = API_UnitGUID("player")
+local self_guid = nil
 --</private-static-properties>

 --<public-static-properties>
@@ -30,6 +29,7 @@ OvaleSpellDamage.value = {}

 --<public-static-methods>
 function OvaleSpellDamage:OnEnable()
+	self_guid = API_UnitGUID("player")
 	self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
 end

diff --git a/OvaleSwing.lua b/OvaleSwing.lua
index 1551b5c..36aca8c 100644
--- a/OvaleSwing.lua
+++ b/OvaleSwing.lua
@@ -41,7 +41,7 @@ local API_UnitRangedDamage = UnitRangedDamage
 local BOOKTYPE_SPELL = BOOKTYPE_SPELL

 -- Player's GUID.
-local self_guid = API_UnitGUID("player")
+local self_guid = nil

 local OVALE_AUTOSHOT_NAME = API_GetSpellInfo(75)
 local OVALE_RESET_SPELLS = {}
@@ -65,6 +65,7 @@ OvaleSwing.swingmode = nil

 --<public-static-methods>
 function OvaleSwing:OnEnable()
+	self_guid = API_UnitGUID("player")
 	self.ohNext = false
 	-- fired when autoattack is enabled/disabled.
 	self:RegisterEvent("PLAYER_ENTER_COMBAT")