Drop player GUID retry logic

ClassicAPI's UnitGUID is valid from ADDON_LOADED on, so set playerGUID
once in Init and remove the PLAYER_ENTERING_WORLD retry, the per-event
EnsurePlayerGUID check and the pcall guards.
This commit is contained in:
Brues
2026-10-28 16:56:09 -05:00
parent a36912af47
commit 9bf7e51f76
@@ -312,9 +312,8 @@ function MikCEH.OnLoad()
-- Set up ClassicAPI combat log events and filter redundant CHAT_MSG events.
MikCEH.SetupCombatLogEvents();
-- Register for the ADDON_LOADED and PLAYER_ENTERING_WORLD events.
-- Register for the ADDON_LOADED event.
MCEHEventFrame:RegisterEvent("ADDON_LOADED");
MCEHEventFrame:RegisterEvent("PLAYER_ENTERING_WORLD");
end
@@ -337,14 +336,6 @@ function MikCEH.OnEvent()
MikCEH.Init();
end
-- Retry playerGUID initialization when the player fully enters the world.
elseif (event == "PLAYER_ENTERING_WORLD") then
this:UnregisterEvent("PLAYER_ENTERING_WORLD");
if not playerGUID then
local ok, guid = pcall(UnitGUID, "player")
if ok and guid then playerGUID = guid end
end
-- Leave Combat
elseif (event == "PLAYER_REGEN_ENABLED") then
local eventData = MikCEH.GetNotificationEventData(MikCEH.NOTIFICATIONTYPE_COMBAT_LEAVE, nil, nil);
@@ -653,9 +644,8 @@ function MikCEH.Init()
playerName = UnitName("player");
_, playerClass = UnitClass("player");
-- Cache the player GUID (UnitGUID is provided by ClassicAPI).
local ok, guid = pcall(UnitGUID, "player")
if ok and guid then playerGUID = guid end
-- Cache the player GUID (ClassicAPI's UnitGUID is valid from ADDON_LOADED on).
playerGUID = UnitGUID("player");
end
@@ -712,7 +702,6 @@ local combatLogPowerTypeToString = {
-- Checks if the given GUID string belongs to the player.
-- **********************************************************************************
local function IsPlayerGUID(guid)
if not guid or not playerGUID then return false end
return guid == playerGUID
end
@@ -721,10 +710,7 @@ end
-- Checks if the given GUID belongs to the player's pet.
-- **********************************************************************************
local function IsPetGUID(guid)
if not guid or not UnitExists("pet") then return false end
local ok, petGuid = pcall(UnitGUID, "pet")
if ok and petGuid then return guid == petGuid end
return false
return guid ~= nil and guid == UnitGUID("pet")
end
@@ -754,24 +740,10 @@ local function SetMitigationPartial(absorbed, blocked, resisted, eventData)
end
-- **********************************************************************************
-- Ensures playerGUID is set. Called lazily by combat log event handlers since
-- UnitGUID("player") may still return nil during ADDON_LOADED before the
-- player unit is fully available.
-- **********************************************************************************
local function EnsurePlayerGUID()
if playerGUID then return true end
local ok, guid = pcall(UnitGUID, "player")
if ok and guid then playerGUID = guid; return true end
return false
end
-- **********************************************************************************
-- Combat log event dispatcher — called by the combat log event frame's OnEvent.
-- **********************************************************************************
function MikCEH.OnCombatLogEvent()
EnsurePlayerGUID()
local handler = combatLogHandlers[arg2]
if handler then handler() end
end