Skip to content

Commit

Permalink
Tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
InfusOnWoW authored and Stanzilla committed Dec 10, 2023
1 parent a1ff4d1 commit b739038
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions LibRangeCheck-3.0/LibRangeCheck-3.0.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ local isWrath = WOW_PROJECT_ID == WOW_PROJECT_WRATH_CLASSIC

local InCombatLockdownRestriction
if isRetail then
InCombatLockdownRestriction = function(unit, canAttack) return InCombatLockdown() and not (canAttack or UnitCanAttack("player", unit)) end
InCombatLockdownRestriction = function(unit) return InCombatLockdown() and not UnitCanAttack("player", unit) end
else
InCombatLockdownRestriction = function() return false end
end
Expand Down Expand Up @@ -546,8 +546,8 @@ local checkers_Spell = setmetatable({}, {
local checkers_SpellWithMin = {} -- see getCheckerForSpellWithMinRange()
local checkers_Item = setmetatable({}, {
__index = function(t, item)
local func = function(unit)
if InCombatLockdownRestriction(unit) then
local func = function(unit, skipInCombatCheck)
if not skipInCombatCheck and InCombatLockdownRestriction(unit) then
return nil
else
return IsItemInRange(item, unit) or nil
Expand All @@ -559,8 +559,8 @@ local checkers_Item = setmetatable({}, {
})
local checkers_Interact = setmetatable({}, {
__index = function(t, index)
local func = function(unit)
if InCombatLockdownRestriction(unit) then
local func = function(unit, skipInCombatCheck)
if not skipInCombatCheck and InCombatLockdownRestriction(unit) then
return nil
else
return CheckInteractDistance(unit, index) and true or false
Expand Down Expand Up @@ -743,7 +743,7 @@ local function getRangeWithCheckerList(unit, checkerList)
while lo <= hi do
local mid = math_floor((lo + hi) / 2)
local rc = checkerList[mid]
if rc.checker(unit) then
if rc.checker(unit, true) then
lo = mid + 1
else
hi = mid - 1
Expand Down Expand Up @@ -771,11 +771,7 @@ local function getRange(unit, noItems)
end

if UnitCanAttack("player", unit) then
if InCombatLockdownRestriction(unit, true) then
return getRangeWithCheckerList(unit, noItems and lib.harmNoItemsRCInCombat or lib.harmRCInCombat)
else
return getRangeWithCheckerList(unit, noItems and lib.harmNoItemsRC or lib.harmRC)
end
return getRangeWithCheckerList(unit, noItems and lib.harmNoItemsRC or lib.harmRC)
elseif UnitIsUnit("pet", unit) then
if InCombatLockdownRestriction(unit) then
local minRange, maxRange = getRangeWithCheckerList(unit, noItems and lib.friendNoItemsRCInCombat or lib.friendRCInCombat)
Expand Down

1 comment on commit b739038

@Hekili
Copy link
Contributor

@Hekili Hekili commented on b739038 Dec 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if there is an unintended downstream impact, but since the change, my addon (which packages the lib) gets assigned responsibility for making use of CheckInteractDistance via the library:

1x [ADDON_ACTION_BLOCKED] AddOn 'Hekili' tried to call the protected function 'CheckInteractDistance()'.
[string "@!BugGrabber/BugGrabber.lua"]:481: in function <!BugGrabber/BugGrabber.lua:481>
[string "=[C]"]: ?
[string "@Hekili/Libs/LibRangeCheck-3.0-8/LibRangeCheck-3.0.lua"]:566: in function `checker'
[string "@Hekili/Libs/LibRangeCheck-3.0-8/LibRangeCheck-3.0.lua"]:746: in function <.../Hekili/Libs/LibRangeCheck-3.0/LibRangeCheck-3.0.lua:741>
[string "=(tail call)"]: ?
[string "@Hekili/Libs/LibRangeCheck-3.0-8/LibRangeCheck-3.0.lua"]:821: in function <.../Hekili/Libs/LibRangeCheck-3.0/LibRangeCheck-3.0.lua:802>
[string "=(tail call)"]: ?
[string "=(tail call)"]: ?
[string ""]:4: in function <[string ""]:2>
[string "=[C]"]: in function `xpcall'
[string "@WeakAuras/GenericTrigger.lua"]:704: in function <WeakAuras/GenericTrigger.lua:627>
[string "@WeakAuras/GenericTrigger.lua"]:867: in function `ScanEventsInternal'
[string "@WeakAuras/GenericTrigger.lua"]:821: in function `ScanEvents'
[string "@WeakAuras/GenericTrigger.lua"]:1778: in function <WeakAuras/GenericTrigger.lua:1776>

Locals:
_ = Frame {
 RegisterEvent = <function> defined @!BugGrabber/BugGrabber.lua:487
 0 = <userdata>
 UnregisterEvent = <function> defined @!BugGrabber/BugGrabber.lua:487
 SetScript = <function> defined @!BugGrabber/BugGrabber.lua:487
}
event = "ADDON_ACTION_BLOCKED"
events = <table> {
 ADDON_ACTION_BLOCKED = <function> defined @!BugGrabber/BugGrabber.lua:553
 ADDON_ACTION_FORBIDDEN = <function> defined @!BugGrabber/BugGrabber.lua:553
 PLAYER_LOGIN = <function> defined @!BugGrabber/BugGrabber.lua:547
 LUA_WARNING = <function> defined @!BugGrabber/BugGrabber.lua:562
 ADDON_LOADED = <function> defined @!BugGrabber/BugGrabber.lua:507
}

Please sign in to comment.