199199
200200-- Quest objects need both the master switch and their own option.
201201local function ObjectsOn () return db .active and db .objects end
202+ local UsablePlate -- defined with the icons
202203local RefreshSoftObject , EnableObjectNameplates , RestoreObjectCVars -- soft-target objects
203204local RefreshControls , UpdatePreview , UpdateMinimapButton , UpdateGates , LayoutTabs -- options UI
204205local settingsScroll -- the scrolling settings page
@@ -647,6 +648,19 @@ local function UpdateCombatAlpha()
647648 for _ , f in pairs (icons ) do f :SetAlpha (alpha ) end
648649end
649650
651+ -- A unit's nameplate if the addon may use it. In dungeons and raids the game can hand out
652+ -- "forbidden" plates (other addons may not touch them): anchoring to one, or measuring it,
653+ -- raises errors, so those count as no plate.
654+ function UsablePlate (unit )
655+ local plate = C_NamePlate and C_NamePlate .GetNamePlateForUnit and C_NamePlate .GetNamePlateForUnit (unit )
656+ if not plate then return nil end
657+ if plate .IsForbidden then
658+ local ok , forbidden = pcall (plate .IsForbidden , plate )
659+ if not ok or forbidden then return nil end
660+ end
661+ return plate
662+ end
663+
650664-- Inside a dungeon or raid (party / raid instance), with "Hide in dungeons and raids" on.
651665local function InstanceHidden ()
652666 if not (db .hideInInstances and IsInInstance ) then return false end
@@ -655,7 +669,7 @@ local function InstanceHidden()
655669end
656670
657671local function Refresh (unit )
658- local plate = C_NamePlate and C_NamePlate . GetNamePlateForUnit (unit )
672+ local plate = UsablePlate (unit )
659673 if db .active and db .enabled and plate and not InstanceHidden () then
660674 local needed , kind , progress = IsQuestMob (unit )
661675 if needed then ShowIcon (unit , plate , kind , progress ) return end
@@ -672,7 +686,7 @@ local function RefreshAll()
672686 end
673687 RefreshSoftObject ()
674688 for unit in pairs (icons ) do
675- if not C_NamePlate . GetNamePlateForUnit (unit ) then HideIcon (unit ) end
689+ if not UsablePlate (unit ) then HideIcon (unit ) end
676690 end
677691end
678692
@@ -856,7 +870,7 @@ function RefreshSoftObject()
856870 local isQuest , kind , progress = false , nil , nil
857871 if UnitExists (SOFT ) then isQuest , kind , progress = IsQuestObject (SOFT ) end
858872 UpdateGate (isQuest )
859- local plate = C_NamePlate and C_NamePlate . GetNamePlateForUnit (SOFT )
873+ local plate = UsablePlate (SOFT )
860874 if isQuest and plate then
861875 if icons [SOFT ] and icons [SOFT ]:GetParent () ~= plate then HideIcon (SOFT ) end
862876 ShowIcon (SOFT , plate , kind , progress )
@@ -2897,8 +2911,8 @@ end
28972911
28982912function MeasurePlate (unit , force )
28992913 if (plateMeasured and not force ) or not (root and C_NamePlate and C_NamePlate .GetNamePlateForUnit ) then return end
2900- local plate = C_NamePlate . GetNamePlateForUnit (unit )
2901- if not plate then return end
2914+ local plate = UsablePlate (unit )
2915+ if not plate or ( IsInInstance and IsInInstance ()) then return end -- measured in the open world only
29022916 local w , h = Read (plate , " GetSize" )
29032917 local eff = Read (plate , " GetEffectiveScale" )
29042918 if not (w and h and eff ) or w <= 0 or h <= 0 then return end
0 commit comments