mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-10 07:30:01 +00:00
GUID replacements
* Replace all `local _, guid = UnitExists(unit)` with `GetUnitGUID(unit)` (Nampower 3.0.0+) * Bump minimum required Nampower version to 3.0.0
This commit is contained in:
+2
-2
@@ -68,7 +68,7 @@ UnitChannelInfo = function(unit)
|
||||
guid = unit -- unit IS the GUID
|
||||
elseif pfValidUnits[unit] and UnitExists then
|
||||
-- unit is a token like "target" - get GUID from it
|
||||
local _, unitGuid = UnitExists(unit)
|
||||
local unitGuid = GetUnitGUID(unit)
|
||||
guid = unitGuid
|
||||
end
|
||||
|
||||
@@ -167,7 +167,7 @@ UnitCastingInfo = function(unit)
|
||||
guid = unit -- unit IS the GUID
|
||||
elseif pfValidUnits[unit] and UnitExists then
|
||||
-- unit is a token like "target" - get GUID from it
|
||||
local _, unitGuid = UnitExists(unit)
|
||||
local unitGuid = GetUnitGUID(unit)
|
||||
guid = unitGuid
|
||||
end
|
||||
|
||||
|
||||
+23
-23
@@ -38,7 +38,7 @@ local hasNampower = false
|
||||
if GetNampowerVersion then
|
||||
local major, minor, patch = GetNampowerVersion()
|
||||
patch = patch or 0
|
||||
-- Minimum required version: 2.41.0 (CastSpellByName unitStr support, SetMouseoverUnit)
|
||||
-- Minimum required version: 3.0.0 (GetUnitGUID support)
|
||||
if major > 2 or (major == 2 and minor > 41) or (major == 2 and minor == 41 and patch >= 0) then
|
||||
hasNampower = true
|
||||
end
|
||||
@@ -101,7 +101,7 @@ nampowerCheckFrame:SetScript("OnEvent", function()
|
||||
end
|
||||
|
||||
else
|
||||
DEFAULT_CHAT_FRAME:AddMessage("|cffff0000[libdebuff] Debuff tracking disabled! Please update Nampower to v2.41.0 or higher.|r")
|
||||
DEFAULT_CHAT_FRAME:AddMessage("|cffff0000[libdebuff] Debuff tracking disabled! Please update Nampower to v3.0.0 or higher.|r")
|
||||
StaticPopup_Show("LIBDEBUFF_NAMPOWER_UPDATE", versionString)
|
||||
end
|
||||
else
|
||||
@@ -217,7 +217,7 @@ pfUI.libpredict_pending_cast = pfUI.libpredict_pending_cast or {}
|
||||
-- ============================================================================
|
||||
|
||||
StaticPopupDialogs["LIBDEBUFF_NAMPOWER_UPDATE"] = {
|
||||
text = "|cffff0000!!!WARNING!!!|r\n\nNampower Update Required!\n\nYour current version: %s\nRequired version: 2.41.0+\n\nPlease update Nampower to continue using pfUI!",
|
||||
text = "|cffff0000!!!WARNING!!!|r\n\nNampower Update Required!\n\nYour current version: %s\nRequired version: 3.0.0+\n\nPlease update Nampower to continue using pfUI!",
|
||||
button1 = "Show Download",
|
||||
button2 = "Dismiss",
|
||||
timeout = 0,
|
||||
@@ -225,12 +225,12 @@ StaticPopupDialogs["LIBDEBUFF_NAMPOWER_UPDATE"] = {
|
||||
hideOnEscape = 0,
|
||||
preferredIndex = 3,
|
||||
OnAccept = function()
|
||||
pfUI.chat.urlcopy.CopyText("https://gitea.com/avitasia/nampower/releases/tag/v2.41.0")
|
||||
pfUI.chat.urlcopy.CopyText("https://gitea.com/avitasia/nampower/releases/tag/v3.0.0")
|
||||
end,
|
||||
}
|
||||
|
||||
StaticPopupDialogs["LIBDEBUFF_NAMPOWER_MISSING"] = {
|
||||
text = "|cffff0000!!!WARNING!!!|r\n\nNampower Not Found!\n\nNampower 2.41.0+ is required for pfUI to function correctly.\n\nPlease install Nampower!",
|
||||
text = "|cffff0000!!!WARNING!!!|r\n\nNampower Not Found!\n\nNampower 3.0.0+ is required for pfUI to function correctly.\n\nPlease install Nampower!",
|
||||
button1 = "Show Download",
|
||||
button2 = "Dismiss",
|
||||
timeout = 0,
|
||||
@@ -315,8 +315,8 @@ end
|
||||
-- Player GUID Cache
|
||||
local playerGUID = nil
|
||||
local function GetPlayerGUID()
|
||||
if not playerGUID and UnitExists then
|
||||
local _, guid = UnitExists("player")
|
||||
if not playerGUID and GetUnitGUID then
|
||||
local guid = GetUnitGUID("player")
|
||||
playerGUID = guid
|
||||
end
|
||||
return playerGUID
|
||||
@@ -344,8 +344,8 @@ end
|
||||
|
||||
local function IsCurrentTarget(guid)
|
||||
if debugStats.trackAllUnits then return true end
|
||||
if not guid or not UnitExists then return false end
|
||||
local _, targetGuid = UnitExists("target")
|
||||
if not guid or not GetUnitGUID then return false end
|
||||
local targetGuid = GetUnitGUID("target")
|
||||
return targetGuid == guid
|
||||
end
|
||||
|
||||
@@ -834,8 +834,8 @@ function libdebuff:UnitDebuff(unit, displaySlot)
|
||||
local dtype = nil
|
||||
|
||||
-- Nampower: Use GetUnitField for ALL debuff data (no Blizzard UnitDebuff needed)
|
||||
if hasNampower and UnitExists then
|
||||
local _, guid = UnitExists(unit)
|
||||
if hasNampower and GetUnitGUID then
|
||||
local guid = GetUnitGUID(unit)
|
||||
if not guid then
|
||||
-- Safety fallback: no GUID available (should not happen with Nampower)
|
||||
local bTexture, bStacks, bDtype = UnitDebuff(unit, displaySlot)
|
||||
@@ -957,8 +957,8 @@ local _ownDebuffSortFunc = function(a, b)
|
||||
end
|
||||
|
||||
function libdebuff:UnitOwnDebuff(unit, id)
|
||||
if hasNampower and UnitExists then
|
||||
local _, guid = UnitExists(unit)
|
||||
if hasNampower and GetUnitGUID then
|
||||
local guid = GetUnitGUID(unit)
|
||||
if guid and ownDebuffs[guid] then
|
||||
-- Build sorted list of our active debuffs
|
||||
local sortedDebuffs = {}
|
||||
@@ -1143,8 +1143,8 @@ if hasNampower then
|
||||
end
|
||||
|
||||
-- Trigger UI updates
|
||||
if pfTarget and UnitExists("target") then
|
||||
local _, currentTargetGuid = UnitExists("target")
|
||||
if pfTarget and GetUnitGUID("target") then
|
||||
local currentTargetGuid = GetUnitGUID("target")
|
||||
if currentTargetGuid == guid then
|
||||
pfTarget.update_aura = true
|
||||
end
|
||||
@@ -1586,16 +1586,16 @@ if hasNampower then
|
||||
|
||||
-- Notify unitframes of debuff updates (UNIT_AURA doesn't fire on refreshes!)
|
||||
-- Check player
|
||||
if UnitExists("player") then
|
||||
local _, playerGuid = UnitExists("player")
|
||||
if GetUnitGUID("player") then
|
||||
local playerGuid = GetUnitGUID("player")
|
||||
if playerGuid == targetGuid and pfPlayer then
|
||||
pfPlayer.update_aura = true
|
||||
end
|
||||
end
|
||||
|
||||
-- Check target
|
||||
if UnitExists("target") then
|
||||
local _, targetUnitGuid = UnitExists("target")
|
||||
if GetUnitGUID("target") then
|
||||
local targetUnitGuid = GetUnitGUID("target")
|
||||
if targetUnitGuid == targetGuid and pfTarget then
|
||||
pfTarget.update_aura = true
|
||||
end
|
||||
@@ -1899,8 +1899,8 @@ if hasNampower then
|
||||
end
|
||||
|
||||
elseif event == "PLAYER_TARGET_CHANGED" then
|
||||
if not UnitExists then return end
|
||||
local _, targetGuid = UnitExists("target")
|
||||
if not GetUnitGUID then return end
|
||||
local targetGuid = GetUnitGUID("target")
|
||||
|
||||
if targetGuid and targetGuid ~= "" then
|
||||
-- Invalidate slot map cache on retarget
|
||||
@@ -1963,12 +1963,12 @@ _G.SlashCmdList["LIBDEBUGSTATS"] = function(msg)
|
||||
DEFAULT_CHAT_FRAME:AddMessage("|cff00ff00No manual slot shifting needed!|r")
|
||||
|
||||
elseif msg == "target" then
|
||||
if not UnitExists("target") then
|
||||
if not GetUnitGUID("target") then
|
||||
DEFAULT_CHAT_FRAME:AddMessage("|cffff0000[libdebuff]|r No target!")
|
||||
return
|
||||
end
|
||||
|
||||
local _, guid = UnitExists("target")
|
||||
local guid = GetUnitGUID("target")
|
||||
DEFAULT_CHAT_FRAME:AddMessage("|cff00ffff=== TARGET DEBUFF STATE ===|r")
|
||||
DEFAULT_CHAT_FRAME:AddMessage(string.format("GUID: %s", tostring(guid)))
|
||||
|
||||
|
||||
+15
-23
@@ -140,39 +140,33 @@ libpredict:SetScript("OnEvent", function()
|
||||
end
|
||||
end)
|
||||
|
||||
-- GUID->Name cache for dead players (UnitExists returns nil for corpses)
|
||||
-- GUID->Name cache for dead players (UnitExists/GetUnitGUID return nil for corpses)
|
||||
local guidNameCache = {} -- [guid] = name
|
||||
|
||||
local function resolveNameFromGuid(guid)
|
||||
if not guid then return nil end
|
||||
if guidNameCache[guid] then return guidNameCache[guid] end
|
||||
local unit = UnitExists(guid)
|
||||
local name = unit and type(unit) == "string" and UnitName(unit) or nil
|
||||
if name then guidNameCache[guid] = name end
|
||||
return name
|
||||
-- UnitExists(guid) reverse lookup not reliable; cache is primary source
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Register with libdebuff hooks
|
||||
local function cacheRaidNames()
|
||||
-- Alle Raid/Party Mitglieder cachen solange sie noch auffindbar sind
|
||||
-- Cache all raid/party members while they are still reachable
|
||||
for i = 1, GetNumRaidMembers() do
|
||||
local unit = "raid" .. i
|
||||
if UnitExists(unit) then
|
||||
local _, guid = UnitExists(unit)
|
||||
local name = UnitName(unit)
|
||||
if guid and name then guidNameCache[guid] = name end
|
||||
end
|
||||
local guid = GetUnitGUID(unit)
|
||||
local name = UnitName(unit)
|
||||
if guid and name then guidNameCache[guid] = name end
|
||||
end
|
||||
for i = 1, GetNumPartyMembers() do
|
||||
local unit = "party" .. i
|
||||
if UnitExists(unit) then
|
||||
local _, guid = UnitExists(unit)
|
||||
local name = UnitName(unit)
|
||||
if guid and name then guidNameCache[guid] = name end
|
||||
end
|
||||
local guid = GetUnitGUID(unit)
|
||||
local name = UnitName(unit)
|
||||
if guid and name then guidNameCache[guid] = name end
|
||||
end
|
||||
-- Spieler selbst
|
||||
local _, pguid = UnitExists("player")
|
||||
-- player self
|
||||
local pguid = GetUnitGUID("player")
|
||||
if pguid then guidNameCache[pguid] = UnitName("player") end
|
||||
end
|
||||
|
||||
@@ -478,8 +472,7 @@ function libpredict:ParseChatMessage(sender, msg, comm)
|
||||
for i = 1, GetNumRaidMembers() do
|
||||
local unit = "raid" .. i
|
||||
if UnitName(unit) == sender then
|
||||
local _, guid = UnitExists(unit)
|
||||
senderGuid = guid
|
||||
senderGuid = GetUnitGUID(unit)
|
||||
break
|
||||
end
|
||||
end
|
||||
@@ -487,8 +480,7 @@ function libpredict:ParseChatMessage(sender, msg, comm)
|
||||
for i = 1, GetNumPartyMembers() do
|
||||
local unit = "party" .. i
|
||||
if UnitName(unit) == sender then
|
||||
local _, guid = UnitExists(unit)
|
||||
senderGuid = guid
|
||||
senderGuid = GetUnitGUID(unit)
|
||||
break
|
||||
end
|
||||
end
|
||||
@@ -1173,7 +1165,7 @@ function libpredict:GetHotDuration(unit, spell)
|
||||
|
||||
-- NEW: Try libdebuff first (Nampower AURA_CAST events)
|
||||
if pfUI.api.libdebuff and pfUI.api.libdebuff.GetBestAuraCast then
|
||||
local _, guid = UnitExists(unit) -- FIX: Get GUID, not exists boolean!
|
||||
local guid = GetUnitGUID(unit)
|
||||
if guid then
|
||||
-- Get the best (highest rank) aura cast for this spell
|
||||
local spellName = spell
|
||||
|
||||
Reference in New Issue
Block a user