From 06fea6c8896c40df9cb9a198770f9c990aebf861 Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Wed, 5 Aug 2026 21:36:54 -0500 Subject: [PATCH] Cache the player guild name for nameplate coloring Compare each plate's guild name against a cached myGuild value instead of calling UnitIsInMyGuild for every plate. Refresh the cache on PLAYER_GUILD_UPDATE and PLAYER_ENTERING_WORLD. This replaces a per-plate C call with a Lua string compare. --- modules/nameplates.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/nameplates.lua b/modules/nameplates.lua index 92e75acd..f9844587 100644 --- a/modules/nameplates.lua +++ b/modules/nameplates.lua @@ -55,6 +55,7 @@ pfUI:RegisterModule("nameplates", function () local savedHostileState = nil local savedFriendlyState = nil local inFriendlyZone = false + local myGuild = nil local platecount = 0 local registry = {} -- Subset of registry that currently has a unit assigned (between @@ -482,6 +483,7 @@ nameplates:RegisterEvent("UNIT_SPELLCAST_START") nameplates:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START") nameplates:RegisterEvent("UNIT_SPELLCAST_STOP") nameplates:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP") +nameplates:RegisterEvent("PLAYER_GUILD_UPDATE") nameplates:SetScript("OnEvent", function() -- Stop event handling during logout to prevent crash 132 @@ -493,13 +495,17 @@ nameplates:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP") nameplates.mouselook:SetScript("OnUpdate", nil) end return - + + elseif event == "PLAYER_GUILD_UPDATE" and arg1 == 'player' then + myGuild = GetGuildInfo("player") + elseif event == "PLAYER_ENTERING_WORLD" or event == "ZONE_CHANGED_NEW_AREA" then if event == "PLAYER_ENTERING_WORLD" then CacheConfig() this:SetGameVariables() RebuildRaidGuidCache() frameState.targetGuid = UnitGUID("target") + myGuild = GetGuildInfo("player") end -- Handle friendly zone nameplate disable feature @@ -1121,7 +1127,7 @@ nameplates:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP") if guild and C.nameplates.showguildname == "1" then plate.guild:SetText(guild) - if UnitIsInMyGuild(plate.unit) then + if guild == myGuild then plate.guild:SetTextColor(0, 0.9, 0, 1) else plate.guild:SetTextColor(0.8, 0.8, 0.8, 1)