diff --git a/api/api.lua b/api/api.lua
index 95af0cdb..7d4200c9 100644
--- a/api/api.lua
+++ b/api/api.lua
@@ -150,8 +150,7 @@ function pfUI.api.checkversion(chkmajor, chkminor, chkfix)
end
-- [ UnitInRange ]
--- Returns whether a party/raid member is nearby.
--- It takes care of the rangecheck module if existing.
+-- Returns whether a party/raid member is nearby, by the configured range check.
-- unit [string] A unit to query (string, unitID)
-- return: [bool] "1" if in range otherwise "nil"
function pfUI.api.UnitInRange(unit)
@@ -166,20 +165,21 @@ function pfUI.api.UnitInRange(unit)
-- returned nil above, matching the pre-collapse behavior.
if C.unitframes.rangecheck == "0" then return 1 end
- -- UnitXP precise mode: skip librange entirely, use direct distance check
+ -- UnitXP precise mode: direct distance check against the configured range
if C.unitframes.rangecheck_mode == "unitxp" and _G.UnitXP then
local threshold = tonumber(C.unitframes.rangecheck_distance) or 40
local success, distance = pcall(_G.UnitXP, "distanceBetween", "player", unit)
if success and distance then
return distance <= threshold and 1 or nil
end
- -- fallthrough to librange if UnitXP fails
+ -- fallthrough to the 40y check if UnitXP fails
end
- if pfUI.api.librange then
- return pfUI.api.librange:UnitInSpellRange(unit)
- end
- return nil
+ -- ClassicAPI's 40y check, _G-qualified since the bare name is this function
+ -- inside the pfUI environment. A unit it can't place (outside the client's
+ -- sync range) counts as in range.
+ local inRange, checked = _G.UnitInRange(unit)
+ return (inRange or not checked) and 1 or nil
end
-- [ UnitHasBuff ]
diff --git a/api/unitframes.lua b/api/unitframes.lua
index 9a5755ed..66ee509d 100644
--- a/api/unitframes.lua
+++ b/api/unitframes.lua
@@ -1719,7 +1719,7 @@ function pfUI.uf:RefreshUnitState(unit)
unit.power.bar:SetMinMaxValues(0, 100)
SetBarValue(unit.hp.bar, 0)
SetBarValue(unit.power.bar, 0)
- elseif unit.config.faderange == "1" and not pfUI.api.UnitInRange(unit.label .. unit.id, 4) and not unlock then
+ elseif unit.config.faderange == "1" and not pfUI.api.UnitInRange(unit.label .. unit.id) and not unlock then
alpha = unit.alpha_outrange
end
diff --git a/init/libs.xml b/init/libs.xml
index 6b0abb56..7585bafb 100644
--- a/init/libs.xml
+++ b/init/libs.xml
@@ -2,7 +2,6 @@
-
diff --git a/libs/librange.lua b/libs/librange.lua
deleted file mode 100644
index 3692470a..00000000
--- a/libs/librange.lua
+++ /dev/null
@@ -1,30 +0,0 @@
--- load pfUI environment
-setfenv(1, pfUI:GetEnvironment())
-
---[[ librange ]]--
--- A thin wrapper over ClassicAPI's UnitInRange: a fixed 40y healing-range
--- check computed C-side from unit positions, valid for any unit. There is
--- no cache or scan loop -- the check is cheap enough to run per query,
--- which also sidesteps the staleness a cached scan hit on zone changes and
--- roster re-indexing.
---
--- librange:UnitInSpellRange(unit)
--- Returns `1` if the unit is within range, `nil` otherwise.
-
-if pfUI.api.librange then return end
-
-local librange = {}
-
-function librange:UnitInSpellRange(unit)
- -- _G-qualified: bare `UnitInRange` resolves to pfUI.api.UnitInRange inside
- -- the pfUI environment (which calls us), so this must reach ClassicAPI's
- -- global directly or it recurses.
- local inRange, checked = _G.UnitInRange(unit)
- -- position miss (e.g. a unit outside the client's sync range): we can't
- -- tell, so default to in-range -- matches the old cache's nil behavior.
- if not checked then return 1 end
- return inRange and 1 or nil
-end
-
--- add librange to pfUI API
-pfUI.api.librange = librange