Skip to content

Commit

Permalink
Use Ovale.playerGUID instead of calling UnitGUID() on PLAYER_LOGIN.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnylam88 committed Mar 23, 2015
1 parent 2b06c55 commit 872e762
Show file tree
Hide file tree
Showing 15 changed files with 94 additions and 109 deletions.
37 changes: 18 additions & 19 deletions Aura.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ local type = type
local wipe = wipe
local API_GetTime = GetTime
local API_UnitAura = UnitAura
local API_UnitGUID = UnitGUID
local API_UnitHealth = UnitHealth
local API_UnitHealthMax = UnitHealthMax
local INFINITY = math.huge
Expand All @@ -59,7 +58,7 @@ OvaleDebug:RegisterDebugging(OvaleAura)
OvaleProfiler:RegisterProfiling(OvaleAura)

-- Player's GUID.
local self_guid = nil
local self_playerGUID = nil
-- Player's pet's GUID.
local self_petGUID = nil
-- Table pool.
Expand Down Expand Up @@ -257,7 +256,7 @@ local function GetAuraOnGUID(auraDB, guid, auraId, filter, mine)
if DEBUFF_TYPE[auraId] then
if mine then
-- Check for aura applied by player, then player's pet if it exists.
auraFound = GetDebuffType(auraDB, guid, auraId, filter, self_guid)
auraFound = GetDebuffType(auraDB, guid, auraId, filter, self_playerGUID)
if not auraFound and self_petGUID then
auraFound = GetDebuffType(auraDB, guid, auraId, filter, self_petGUID)
end
Expand All @@ -267,7 +266,7 @@ local function GetAuraOnGUID(auraDB, guid, auraId, filter, mine)
else
if mine then
-- Check for aura applied by player, then player's pet if it exists.
auraFound = GetAura(auraDB, guid, auraId, self_guid)
auraFound = GetAura(auraDB, guid, auraId, self_playerGUID)
if not auraFound and self_petGUID then
auraFound = GetAura(auraDB, guid, auraId, self_petGUID)
end
Expand Down Expand Up @@ -314,7 +313,7 @@ function OvaleAura:OnInitialize()
end

function OvaleAura:OnEnable()
self_guid = API_UnitGUID("player")
self_playerGUID = Ovale.playerGUID
self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
self:RegisterEvent("PLAYER_ENTERING_WORLD")
self:RegisterEvent("PLAYER_REGEN_ENABLED")
Expand Down Expand Up @@ -374,7 +373,7 @@ end
function OvaleAura:COMBAT_LOG_EVENT_UNFILTERED(event, timestamp, cleuEvent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, ...)
local arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20, arg21, arg22, arg23, arg24, arg25 = ...

local mine = (sourceGUID == self_guid or self_petGUID and sourceGUID == self_petGUID)
local mine = (sourceGUID == self_playerGUID or self_petGUID and sourceGUID == self_petGUID)
if CLEU_AURA_EVENTS[cleuEvent] then
local unitId = OvaleGUID:GetUnitId(destGUID)
if unitId then
Expand Down Expand Up @@ -440,7 +439,7 @@ function OvaleAura:COMBAT_LOG_EVENT_UNFILTERED(event, timestamp, cleuEvent, hide
else
self:Debug(true, "%s: %s", cleuEvent, destGUID)
end
local aura = GetAura(self.aura, destGUID, spellId, self_guid)
local aura = GetAura(self.aura, destGUID, spellId, self_playerGUID)
local now = API_GetTime()
if self:IsActiveAura(aura, now) then
local name = aura.name or "Unknown spell"
Expand Down Expand Up @@ -605,7 +604,7 @@ function OvaleAura:GainedAuraOnGUID(guid, atTime, auraId, casterGUID, filter, vi
local unitId = OvaleGUID:GetUnitId(guid)

-- Snapshot stats for auras applied by the player or player's pet.
local mine = (casterGUID == self_guid or self_petGUID and casterGUID == self_petGUID)
local mine = (casterGUID == self_playerGUID or self_petGUID and casterGUID == self_petGUID)
if mine then
-- Determine whether to snapshot player stats for the aura or to keep the existing stats.
local spellcast = OvaleFuture:LastInFlightSpell()
Expand Down Expand Up @@ -660,7 +659,7 @@ function OvaleAura:GainedAuraOnGUID(guid, atTime, auraId, casterGUID, filter, vi
end
end
-- Set the cooldown expiration time for player buffs applied by items with a cooldown.
if si.buff_cd and guid == self_guid then
if si.buff_cd and guid == self_playerGUID then
self:Debug(" %s (%s) is applied by an item with a cooldown of %ds.", name, auraId, si.buff_cd)
if not auraIsActive then
-- cooldownEnding is the earliest time at which we expect to gain this buff again.
Expand Down Expand Up @@ -692,7 +691,7 @@ function OvaleAura:LostAuraOnGUID(guid, atTime, auraId, casterGUID)
end

-- Snapshot stats for auras applied by the player or player's pet.
local mine = (casterGUID == self_guid or self_petGUID and casterGUID == self_petGUID)
local mine = (casterGUID == self_playerGUID or self_petGUID and casterGUID == self_petGUID)
if mine then
-- Clear old tick information for player-applied periodic auras.
aura.baseTick = nil
Expand All @@ -703,7 +702,7 @@ function OvaleAura:LostAuraOnGUID(guid, atTime, auraId, casterGUID)
-- The aura must have ended early, i.e., start + duration > ending.
if aura.start + aura.duration > aura.ending then
local spellcast
if guid == self_guid then
if guid == self_playerGUID then
-- Player aura, so it was possibly consumed by an in-flight spell.
spellcast = OvaleFuture:LastInFlightSpell()
else
Expand Down Expand Up @@ -1029,7 +1028,7 @@ function OvaleAura:ApplySpellStartCast(state, spellId, targetGUID, startCast, en
if si and si.aura then
-- Apply the auras on the player.
if si.aura.player then
state:ApplySpellAuras(spellId, self_guid, startCast, si.aura.player, spellcast)
state:ApplySpellAuras(spellId, self_playerGUID, startCast, si.aura.player, spellcast)
end
-- Apply the auras on the target.
if si.aura.target then
Expand All @@ -1053,7 +1052,7 @@ function OvaleAura:ApplySpellAfterCast(state, spellId, targetGUID, startCast, en
if si and si.aura then
-- Apply the auras on the player.
if si.aura.player then
state:ApplySpellAuras(spellId, self_guid, endCast, si.aura.player, spellcast)
state:ApplySpellAuras(spellId, self_playerGUID, endCast, si.aura.player, spellcast)
end
-- Apply the auras on the pet.
if si.aura.pet and self_petGUID then
Expand Down Expand Up @@ -1201,7 +1200,7 @@ local function GetStateAuraOnGUID(state, guid, auraId, filter, mine)
if DEBUFF_TYPE[auraId] then
if mine then
-- Check for aura applied by player, then player's pet if it exists.
auraFound = GetStateDebuffType(state, guid, auraId, filter, self_guid)
auraFound = GetStateDebuffType(state, guid, auraId, filter, self_playerGUID)
if not auraFound and self_petGUID then
auraFound = GetStateDebuffType(state, guid, auraId, filter, self_petGUID)
end
Expand All @@ -1211,7 +1210,7 @@ local function GetStateAuraOnGUID(state, guid, auraId, filter, mine)
else
if mine then
-- Check for aura applied by player, then player's pet if it exists.
local aura = GetStateAura(state, guid, auraId, self_guid)
local aura = GetStateAura(state, guid, auraId, self_playerGUID)
if aura and aura.stacks > 0 then
auraFound = aura
elseif self_petGUID then
Expand Down Expand Up @@ -1419,7 +1418,7 @@ statePrototype.ApplySpellAuras = function(state, spellId, guid, atTime, auraList
end
end
end
local aura = state:AddAuraToGUID(guid, auraId, self_guid, filter, debuffType, 0, INFINITY)
local aura = state:AddAuraToGUID(guid, auraId, self_playerGUID, filter, debuffType, 0, INFINITY)
-- Information that needs to be set below: stacks, start, ending, duration, gain.
aura.stacks = stacks
-- Set start and duration for aura.
Expand Down Expand Up @@ -1530,7 +1529,7 @@ statePrototype.GetAuraWithProperty = function(state, unitId, propertyName, filte
if OvaleAura.aura[guid] then
for auraId, whoseTable in pairs(OvaleAura.aura[guid]) do
for casterGUID in pairs(whoseTable) do
local aura = GetStateAura(state, guid, auraId, self_guid)
local aura = GetStateAura(state, guid, auraId, self_playerGUID)
if state:IsActiveAura(aura, atTime) and not aura.state then
if aura[propertyName] and aura.filter == filter then
count = count + 1
Expand Down Expand Up @@ -1610,7 +1609,7 @@ do
if guid ~= excludeGUID and auraTable[auraId] then
if mine then
-- Count aura applied by player.
local aura = GetStateAura(state, guid, auraId, self_guid)
local aura = GetStateAura(state, guid, auraId, self_playerGUID)
if state:IsActiveAura(aura, atTime) and aura.filter == filter and aura.stacks >= minStacks and not aura.state then
CountMatchingActiveAura(state, aura)
end
Expand All @@ -1636,7 +1635,7 @@ do
if guid ~= excludeGUID and auraTable[auraId] then
if mine then
-- Count aura applied by player.
local aura = auraTable[auraId][self_guid]
local aura = auraTable[auraId][self_playerGUID]
if aura then
if state:IsActiveAura(aura, atTime) and aura.filter == filter and aura.stacks >= minStacks then
CountMatchingActiveAura(state, aura)
Expand Down
19 changes: 9 additions & 10 deletions BanditsGuile.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@ Ovale.OvaleBanditsGuile = OvaleBanditsGuile
local OvaleAura = nil

local API_GetTime = GetTime
local API_UnitGUID = UnitGUID
local INFINITY = math.huge

-- Player's GUID.
local self_guid = nil
local self_playerGUID = nil

-- Aura IDs for visible buff from Bandit's Guile.
local SHALLOW_INSIGHT = 84745
Expand Down Expand Up @@ -71,7 +70,7 @@ end

function OvaleBanditsGuile:OnEnable()
if Ovale.playerClass == "ROGUE" then
self_guid = API_UnitGUID("player")
self_playerGUID = Ovale.playerGUID
self:RegisterMessage("Ovale_SpecializationChanged")
end
end
Expand Down Expand Up @@ -100,7 +99,7 @@ end
-- Insight buff.
function OvaleBanditsGuile:COMBAT_LOG_EVENT_UNFILTERED(event, timestamp, cleuEvent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, ...)
local arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20, arg21, arg22, arg23, arg24, arg25 = ...
if sourceGUID == self_guid and cleuEvent == "SPELL_DAMAGE" and self.stacks < 3 then
if sourceGUID == self_playerGUID and cleuEvent == "SPELL_DAMAGE" and self.stacks < 3 then
local spellId, multistrike = arg12, arg25
if BANDITS_GUILE_ATTACK[spellId] and not multistrike then
local now = API_GetTime()
Expand All @@ -115,7 +114,7 @@ end
-- This event handler uses Ovale_AuraAdded to track the Insight buff being applied for the first
-- time and sets the implied stacks of Bandit's Guile.
function OvaleBanditsGuile:Ovale_AuraAdded(event, timestamp, target, auraId, caster)
if target == self_guid then
if target == self_playerGUID then
if auraId == SHALLOW_INSIGHT or auraId == MODERATE_INSIGHT or auraId == DEEP_INSIGHT then
local aura = OvaleAura:GetAura("player", auraId, "HELPFUL", true)
self.start, self.ending = aura.start, aura.ending
Expand All @@ -137,7 +136,7 @@ end
-- This event handler uses Ovale_AuraChanged to track refreshes of the Insight buff, which indicates
-- that it the hidden Bandit's Guile buff has gained extra stacks.
function OvaleBanditsGuile:Ovale_AuraChanged(event, timestamp, target, auraId, caster)
if target == self_guid then
if target == self_playerGUID then
if auraId == SHALLOW_INSIGHT or auraId == MODERATE_INSIGHT or auraId == DEEP_INSIGHT then
local aura = OvaleAura:GetAura("player", auraId, "HELPFUL", true)
self.start, self.ending = aura.start, aura.ending
Expand All @@ -151,23 +150,23 @@ function OvaleBanditsGuile:Ovale_AuraChanged(event, timestamp, target, auraId, c
end

function OvaleBanditsGuile:Ovale_AuraRemoved(event, timestamp, target, auraId, caster)
if target == self_guid then
if target == self_playerGUID then
if (auraId == SHALLOW_INSIGHT and self.stacks < 8)
or (auraId == MODERATE_INSIGHT and self.stacks < 12)
or auraId == DEEP_INSIGHT then
self.ending = timestamp
self.stacks = 0
OvaleAura:LostAuraOnGUID(self_guid, timestamp, self.spellId, self_guid)
OvaleAura:LostAuraOnGUID(self_playerGUID, timestamp, self.spellId, self_playerGUID)
end
end
end

function OvaleBanditsGuile:GainedAura(atTime)
OvaleAura:GainedAuraOnGUID(self_guid, atTime, self.spellId, self_guid, "HELPFUL", nil, nil, self.stacks, nil, self.duration, self.ending, nil, self.spellName, nil, nil, nil)
OvaleAura:GainedAuraOnGUID(self_playerGUID, atTime, self.spellId, self_playerGUID, "HELPFUL", nil, nil, self.stacks, nil, self.duration, self.ending, nil, self.spellName, nil, nil, nil)
end

function OvaleBanditsGuile:DebugBanditsGuile()
local aura = OvaleAura:GetAuraByGUID(self_guid, self.spellId, "HELPFUL", true)
local aura = OvaleAura:GetAuraByGUID(self_playerGUID, self.spellId, "HELPFUL", true)
if aura then
self:Print("Player has Bandit's Guile aura with start=%s, end=%s, stacks=%d.", aura.start, aura.ending, aura.stacks)
end
Expand Down
19 changes: 9 additions & 10 deletions ComboPoints.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ local OvaleState = nil
local tinsert = table.insert
local tremove = table.remove
local API_GetTime = GetTime
local API_UnitGUID = UnitGUID
local API_UnitPower = UnitPower
local MAX_COMBO_POINTS = MAX_COMBO_POINTS
local UNKNOWN = UNKNOWN
Expand All @@ -38,7 +37,7 @@ OvaleDebug:RegisterDebugging(OvaleComboPoints)
OvaleProfiler:RegisterProfiling(OvaleComboPoints)

-- Player's GUID.
local self_guid = nil
local self_playerGUID = nil

-- Rogue's Anticipation talent.
local ANTICIPATION = 115189
Expand Down Expand Up @@ -153,7 +152,7 @@ function OvaleComboPoints:OnInitialize()
end

function OvaleComboPoints:OnEnable()
self_guid = API_UnitGUID("player")
self_playerGUID = Ovale.playerGUID
if Ovale.playerClass == "ROGUE" or Ovale.playerClass == "DRUID" then
self:RegisterEvent("PLAYER_ENTERING_WORLD", "Update")
self:RegisterEvent("PLAYER_TARGET_CHANGED")
Expand Down Expand Up @@ -245,10 +244,10 @@ function OvaleComboPoints:Ovale_SpellFinished(event, atTime, spellId, targetGUID
self:Debug(" Spell %d refunds 1 combo point from Assassination 4pT17 set bonus.", spellId)
AddPendingComboEvent(atTime, spellId, targetGUID, "Assassination 4pT17", 1)
end
if self_hasAnticipation and targetGUID ~= self_guid then
if self_hasAnticipation and targetGUID ~= self_playerGUID then
-- Anticipation causes offensive finishing moves to consume all Anticipation charges and to grant a combo point for each.
if OvaleSpellBook:IsHarmfulSpell(spellId) then
local aura = OvaleAura:GetAuraByGUID(self_guid, ANTICIPATION, "HELPFUL", true)
local aura = OvaleAura:GetAuraByGUID(self_playerGUID, ANTICIPATION, "HELPFUL", true)
if OvaleAura:IsActiveAura(aura, atTime) then
self:Debug(" Spell %d hit with %d Anticipation charges.", spellId, aura.stacks)
AddPendingComboEvent(atTime, spellId, targetGUID, "Anticipation", aura.stacks)
Expand Down Expand Up @@ -434,7 +433,7 @@ function OvaleComboPoints:ResetState(state)
for k = 1, #self_pendingComboEvents do
local comboEvent = self_pendingComboEvents[k]
if comboEvent.reason == "Anticipation" then
state:RemoveAuraOnGUID(self_guid, ANTICIPATION, "HELPFUL", true, comboEvent.atTime)
state:RemoveAuraOnGUID(self_playerGUID, ANTICIPATION, "HELPFUL", true, comboEvent.atTime)
break
end
end
Expand All @@ -459,10 +458,10 @@ function OvaleComboPoints:ApplySpellAfterCast(state, spellId, targetGUID, startC
end
-- Anticipation causes offensive finishing moves to consume all Anticipation charges and to grant a combo point for each.
if self_hasAnticipation and state.combo > 0 then
local aura = state:GetAuraByGUID(self_guid, ANTICIPATION, "HELPFUL", true)
local aura = state:GetAuraByGUID(self_playerGUID, ANTICIPATION, "HELPFUL", true)
if state:IsActiveAura(aura, endCast) then
power = power + aura.stacks
state:RemoveAuraOnGUID(self_guid, ANTICIPATION, "HELPFUL", true, endCast)
state:RemoveAuraOnGUID(self_playerGUID, ANTICIPATION, "HELPFUL", true, endCast)
-- Anticipation charges that are consumed to grant combo points don't overflow into new Anticipation charges.
if power > MAX_COMBO_POINTS then
power = MAX_COMBO_POINTS
Expand All @@ -482,7 +481,7 @@ function OvaleComboPoints:ApplySpellAfterCast(state, spellId, targetGUID, startC
if self_hasAnticipation and not si.temp_combo then
local stacks = power - MAX_COMBO_POINTS
-- Look for a pre-existing Anticipation buff and add to its stack count.
local aura = state:GetAuraByGUID(self_guid, ANTICIPATION, "HELPFUL", true)
local aura = state:GetAuraByGUID(self_playerGUID, ANTICIPATION, "HELPFUL", true)
if state:IsActiveAura(aura, endCast) then
stacks = stacks + aura.stacks
if stacks > MAX_COMBO_POINTS then
Expand All @@ -492,7 +491,7 @@ function OvaleComboPoints:ApplySpellAfterCast(state, spellId, targetGUID, startC
-- Add a new Anticipation buff with the updated start, ending, stacks information.
local start = endCast
local ending = start + ANTICIPATION_DURATION
aura = state:AddAuraToGUID(self_guid, ANTICIPATION, self_guid, "HELPFUL", nil, start, ending)
aura = state:AddAuraToGUID(self_playerGUID, ANTICIPATION, self_playerGUID, "HELPFUL", nil, start, ending)
aura.stacks = stacks
end
power = MAX_COMBO_POINTS
Expand Down
7 changes: 3 additions & 4 deletions DamageTaken.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ local bit_band = bit.band
local bit_bor = bit.bor
local strsub = string.sub
local API_GetTime = GetTime
local API_UnitGUID = UnitGUID
local SCHOOL_MASK_ARCANE = SCHOOL_MASK_ARCANE
local SCHOOL_MASK_FIRE = SCHOOL_MASK_FIRE
local SCHOOL_MASK_FROST = SCHOOL_MASK_FROST
Expand All @@ -39,7 +38,7 @@ OvaleDebug:RegisterDebugging(OvaleDamageTaken)
OvaleProfiler:RegisterProfiling(OvaleDamageTaken)

-- Player's GUID.
local self_guid = nil
local self_playerGUID = nil
-- Damage event pool.
local self_pool = OvalePool("OvaleDamageTaken_pool")
-- Time window (past number of seconds) for which damage events are stored.
Expand All @@ -60,7 +59,7 @@ function OvaleDamageTaken:OnInitialize()
end

function OvaleDamageTaken:OnEnable()
self_guid = API_UnitGUID("player")
self_playerGUID = Ovale.playerGUID
self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
self:RegisterEvent("PLAYER_REGEN_ENABLED")
end
Expand All @@ -74,7 +73,7 @@ end
function OvaleDamageTaken:COMBAT_LOG_EVENT_UNFILTERED(event, timestamp, cleuEvent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, ...)
local arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20, arg21, arg22, arg23, arg24, arg25 = ...

if destGUID == self_guid and strsub(cleuEvent, -7) == "_DAMAGE" then
if destGUID == self_playerGUID and strsub(cleuEvent, -7) == "_DAMAGE" then
self:StartProfiling("OvaleDamageTaken_COMBAT_LOG_EVENT_UNFILTERED")
local now = API_GetTime()
local eventPrefix = strsub(cleuEvent, 1, 6)
Expand Down
Loading

0 comments on commit 872e762

Please sign in to comment.