diff --git a/api/unitframes.lua b/api/unitframes.lua index 1c66af91..7edbd6da 100644 --- a/api/unitframes.lua +++ b/api/unitframes.lua @@ -247,7 +247,7 @@ end) -- GetUnitStats - Nampower Integration for Health + Power -- Returns: hp, maxHp, power, maxPower, powerType -- IMPORTANT: Uses _G.UnitExists directly to avoid conflicts with Nampower's --- extended UnitExists that returns (exists, guid) +-- use GetUnitGUID(unit) for GUID lookup (Nampower 3.0.0+) -- ============================================================================ -- Cache für Stats-Tracking (nur Änderungen zählen) @@ -1168,7 +1168,7 @@ function pfUI.uf.OnEvent() -- Smart update: check if THIS frame's unit actually changed if pfUI.uf.guidTracker and this.id then local unit = this.label == "player" and "player" or (this.label .. this.id) - local _, newGuid = UnitExists(unit) + local newGuid = GetUnitGUID(unit) local oldGuid = pfUI.uf.guidTracker.frameToGuid[this] if newGuid ~= oldGuid then pfUI.uf.guidTracker.frameToGuid[this] = newGuid @@ -1455,7 +1455,7 @@ function pfUI.uf.OnUpdate() -- O(1) Nampower lookup via GUID (same pattern as nameplates.lua) local health, maxHealth if GetUnitField then - local _, guid = UnitExists(unit) + local guid = GetUnitGUID(unit) if guid then health = GetUnitField(guid, "health") maxHealth = GetUnitField(guid, "maxHealth") @@ -3288,7 +3288,7 @@ function pfUI.uf.GetColor(self, preset) -- O(1) Nampower lookup for health gradient color local hp, hpmax if GetUnitField then - local _, guid = UnitExists(unitstr) + local guid = GetUnitGUID(unitstr) if guid then hp = GetUnitField(guid, "health") hpmax = GetUnitField(guid, "maxHealth") diff --git a/libs/libcast.lua b/libs/libcast.lua index 2c148dad..cb9a49b8 100644 --- a/libs/libcast.lua +++ b/libs/libcast.lua @@ -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 diff --git a/libs/libdebuff.lua b/libs/libdebuff.lua index 9bd22e37..676a75f6 100644 --- a/libs/libdebuff.lua +++ b/libs/libdebuff.lua @@ -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))) diff --git a/libs/libpredict.lua b/libs/libpredict.lua index 755d4cf9..590a0aa9 100644 --- a/libs/libpredict.lua +++ b/libs/libpredict.lua @@ -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 diff --git a/modules/actionbar.lua b/modules/actionbar.lua index b7577957..02384ed7 100644 --- a/modules/actionbar.lua +++ b/modules/actionbar.lua @@ -1007,7 +1007,7 @@ pfUI:RegisterModule("actionbar", "vanilla", function () -- Prowl Spell IDs: 5215 (Rank 1), 6783 (Rank 2), 9913 (Rank 3) if event == "UNIT_CASTEVENT" then local guid, target, cEvent, spellId = arg1, arg2, arg3, arg4 - local _, playerGuid = UnitExists("player") + local playerGuid = GetUnitGUID("player") if guid == playerGuid and cEvent == "CAST" then if spellId == 5215 or spellId == 6783 or spellId == 9913 then -- Prowl cast detected diff --git a/modules/castbar.lua b/modules/castbar.lua index 8bac67fb..f8bdd99d 100644 --- a/modules/castbar.lua +++ b/modules/castbar.lua @@ -8,8 +8,8 @@ pfUI:RegisterModule("castbar", "vanilla", function () -- Helper function for castbar timer formatting local function FormatCastbarTime(value) if C.unitframes.castbardecimals == "1" then - -- 1 decimal, always floor - return string.format("%.1f", floor(value * 10) / 10) + -- 1 decimal, round half up (matches Blizzard spellbook display) + return string.format("%.1f", floor(value * 10 + 0.5) / 10) else -- 2 decimals (default) return string.format("%.2f", value) @@ -108,7 +108,7 @@ pfUI:RegisterModule("castbar", "vanilla", function () if this.unitstr and string.find(this.unitstr, "^0x") then focusGuid = this.unitstr elseif this.unitstr and this.unitstr ~= "player" then - local _, guid = UnitExists(this.unitstr) + local guid = GetUnitGUID(this.unitstr) if guid then focusGuid = guid end end @@ -176,7 +176,7 @@ pfUI:RegisterModule("castbar", "vanilla", function () if pfUI.libdebuff_casts or pfUI.libdebuff_item_icons then local castGuid = nil if this.unitstr and UnitExists then - local _, guid = UnitExists(this.unitstr) + local guid = GetUnitGUID(this.unitstr) castGuid = guid end if castGuid then diff --git a/modules/focus.lua b/modules/focus.lua index 55e42012..f36de44a 100644 --- a/modules/focus.lua +++ b/modules/focus.lua @@ -51,7 +51,7 @@ function SlashCmdList.PFFOCUS(msg) if msg ~= "" then -- Try to resolve GUID via short target swap if UnitExists then - local _, prevGUID = UnitExists("target") + local prevGUID = GetUnitGUID("target") local prevPlayer = UnitIsUnit("target", "player") -- Suppress "Unknown unit" errors during targeting attempts (fired async) @@ -59,7 +59,7 @@ function SlashCmdList.PFFOCUS(msg) -- Try exact match first, then prefix match via /tar TargetByName(msg, true) - local _, guid = UnitExists("target") + local guid = GetUnitGUID("target") if not guid or guid == "0x0000000000000000" then -- Fallback: prefix match (like /tar storm -> Stormwind Guard) @@ -94,7 +94,7 @@ function SlashCmdList.PFFOCUS(msg) else -- No msg: use current target if UnitExists then - local _, guid = UnitExists("target") + local guid = GetUnitGUID("target") if guid and guid ~= "0x0000000000000000" then SetFocusByGUID(guid) return @@ -143,11 +143,11 @@ function SlashCmdList.PFCASTFOCUS(msg) -- For lua functions with GUID: short target swap via GUID if hasGUID and func then - local _, currentGUID = UnitExists("target") + local currentGUID = GetUnitGUID("target") local isPlayer = UnitIsUnit("target", "player") TargetUnit(focusGUID) - local _, newGUID = UnitExists("target") + local newGUID = GetUnitGUID("target") if newGUID ~= focusGUID then -- Could not target focus, restore and fail diff --git a/modules/nameplates.lua b/modules/nameplates.lua index 0a167028..760c05d9 100644 --- a/modules/nameplates.lua +++ b/modules/nameplates.lua @@ -101,7 +101,7 @@ pfUI:RegisterModule("nameplates", "vanilla", function () local wipe = wipe or function(t) for k in pairs(t) do t[k] = nil end end -- Player GUID for filtering - local _, PlayerGUID = UnitExists("player") + local PlayerGUID = GetUnitGUID("player") -- ============================================================================ -- OPTIMIZATION: Config caching @@ -549,7 +549,7 @@ nameplates:RegisterEvent("ZONE_CHANGED_NEW_AREA") elseif event == "PLAYER_TARGET_CHANGED" then -- Flag target plate for update via GUID registry - local _, targetGuid = UnitExists("target") + local targetGuid = GetUnitGUID("target") if targetGuid then local plate = guidRegistry[targetGuid] if plate and plate.nameplate then @@ -561,7 +561,7 @@ nameplates:RegisterEvent("ZONE_CHANGED_NEW_AREA") elseif event == "PLAYER_COMBO_POINTS" or event == "UNIT_COMBO_POINTS" then -- Only flag the target plate for combo point update - local _, targetGuid = UnitExists("target") + local targetGuid = GetUnitGUID("target") if targetGuid then local plate = guidRegistry[targetGuid] if plate and plate.nameplate then @@ -1504,7 +1504,7 @@ nameplates:RegisterEvent("ZONE_CHANGED_NEW_AREA") if isTargetPlate then targetGUID = state and state.targetGuid if not targetGUID then - local _, guid = UnitExists("target") + local guid = GetUnitGUID("target") targetGUID = guid end end @@ -1571,7 +1571,7 @@ nameplates:RegisterEvent("ZONE_CHANGED_NEW_AREA") channel, nameSubtext, text, texture, startTime, endTime, isTradeSkill = UnitChannelInfo("target") end elseif unitstr then - local _, guid = UnitExists(unitstr) + local guid = GetUnitGUID(unitstr) local q = guid or unitstr cast, nameSubtext, text, texture, startTime, endTime, isTradeSkill = UnitCastingInfo(q) if not cast then diff --git a/modules/nampower.lua b/modules/nampower.lua index e841cd4c..d6374e83 100644 --- a/modules/nampower.lua +++ b/modules/nampower.lua @@ -591,7 +591,7 @@ pfUI:RegisterModule("nampower", "vanilla", function () -- Get base mana using Nampower's GetUnitField local baseMana, baseMaxMana - local _, guid = UnitExists(unit) + local guid = GetUnitGUID(unit) if guid then baseMana = GetUnitField(guid, "power1") diff --git a/modules/raid.lua b/modules/raid.lua index af45fe12..a389611c 100644 --- a/modules/raid.lua +++ b/modules/raid.lua @@ -121,7 +121,7 @@ pfUI:RegisterModule("raid", "vanilla:tbc", function () local frame = pfUI.uf.raid[i] if frame and frame.id and frame.id > 0 then local unit = "raid" .. frame.id - local _, newGuid = UnitExists(unit) + local newGuid = GetUnitGUID(unit) local oldGuid = tracker.frameToGuid[frame] if newGuid ~= oldGuid then diff --git a/modules/superwow.lua b/modules/superwow.lua index 5d06f189..d3afd68b 100644 --- a/modules/superwow.lua +++ b/modules/superwow.lua @@ -266,7 +266,7 @@ pfUI:RegisterModule("superwow", "vanilla", function () if event == "PLAYER_ENTERING_WORLD" then -- Cache player GUID if UnitExists then - local _, guid = UnitExists("player") + local guid = GetUnitGUID("player") playerGuid = guid end return diff --git a/modules/swingtimer.lua b/modules/swingtimer.lua index a4ac86b0..3788d647 100644 --- a/modules/swingtimer.lua +++ b/modules/swingtimer.lua @@ -575,7 +575,7 @@ pfUI:RegisterModule("swingtimer", "vanilla:tbc", function () elseif event == "PLAYER_ENTERING_WORLD" then local _, class = UnitClass("player") isWarrior = (class == "WARRIOR") - local _, guid = UnitExists("player") + local guid = GetUnitGUID("player") playerGUID = guid UpdateWeaponSpeeds() RebuildQueueSlotCache()