CheckRange returns true for invalid results when using "<=".
nullKomplex opened this issue · 5 comments
Describe the bug
CheckRange returns true (meaning target is in range) when the unit is either too far to check or in another zone/phase. As the target is not in range, it should likely return false.
To Reproduce
- Be in a group with at least one other player.
- Target a group member.
- Be over 100 yards, in another zone from, or in another phase from, your target.
Custom Code:
4. Check WeakAuras.CheckRange result through WA below.
5. "true" will be output to chat when you are meet one of the criteria from step 2. (Expected result: "false" output to chat)
Condition:
4. Alternate between clearing your target selection and selecting your target with the second WA below.
5. "test" can be seen in chat frame every time you select the target, despite it not being in range. (Expected result: Never output)
Which version of WeakAuras are you using?
2.10.10
Was it working in a previous version? If yes, which was the last good one?
Prior to this commit bd11660
Additional context
The line https://github.com/WeakAuras/WeakAuras2/blob/master/WeakAuras/Prototypes.lua#L41 should default to 1000 when nil, instead of 0. For >= the expected behavior is subjective, so it could go one way or the other (personally I agree with its current implementation). Potentially a value higher than 1000 could be used for further protection.
Custom Code WA:
https://wago.io/9_Wk1Wg5m
Condition WA:
https://wago.io/AlfMuAK_K
PRs:
#441
Generally, range information isn’t completely reliable (by design, as a matter of fact). Is there a prototype trigger which is returning unexpected results, or are you trying to call this function as an API (which we do not support)?
Why do you think that the maximum range should default to 1000? That would mean that if our rangefinding library does not find a maximum distance, then we would assume that it’s up to 1000 yards away. That seems far less reasonable to me than assuming that it could be any distance greater than the minimum range away.
By that logic it should be a proper nil check and not a range assumption like it already is, but since it appeared to be a conscious decision to not implement it as such I didn't recommend it.
You still haven't answered my question. CheckRange is an internal function, used only for range check conditions. Is there a situation in which you can make a Distance
condition behave unexpectedly, without actually calling WeakAuras.CheckRange
in custom code yourself?
With no custom code, using it as a Condition does in fact behave unexpectedly (as detailed above). Using it as a trigger works as intended.