mirror of
https://github.com/brues-code/SuperCleveRoidMacros.git
synced 2026-09-16 03:38:00 +00:00
Drop the unreachable fallbacks in the health/power wrappers
UnitHealthMissing, UnitPower, UnitPowerMax and UnitPowerMissing each carried an `X or function(...)` fallback computing the value from UnitHealth/UnitMana. None could run: the addon refuses to finish loading below ClassicAPI v1.15.0, and all four globals ship at or below v1.10.0. The file header already promised as much -- "the wrappers below call the API directly -- no fallbacks" -- and these four were the only ones that didn't. The UnitPower fallback was worse than dead. It dropped powerType and returned UnitMana(unit), so a rage or energy read would have quietly answered with mana; UnitPowerMax did the same with UnitManaMax. Only unreachability kept that from being a bug. They were also the file's only plain `API.X =` assignments, bound to the global at load time. Now all 38 wrappers are `function API.X(...)`, resolving per call like their neighbours -- no practical difference, since the DLL registers these globals before any addon Lua runs. Every caller passes (unit) or (unit, powerType); both pass straight through.
This commit is contained in:
+10
-11
@@ -312,10 +312,9 @@ end
|
||||
-- Unit Health
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-- Health deficit (max - current) for `unit` in one call. Falls back to
|
||||
-- UnitHealthMax - UnitHealth without ClassicAPI.
|
||||
API.UnitHealthMissing = UnitHealthMissing or function(unit)
|
||||
return (UnitHealthMax(unit) or 0) - (UnitHealth(unit) or 0)
|
||||
-- Health deficit (max - current) for `unit` in one call.
|
||||
function API.UnitHealthMissing(unit)
|
||||
return UnitHealthMissing(unit)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
@@ -324,18 +323,18 @@ end
|
||||
|
||||
-- Current power for a specific Enum.PowerType (0=Mana, 1=Rage, 2=Focus,
|
||||
-- 3=Energy, 4=Happiness), or the unit's primary power when powerType is omitted.
|
||||
-- Display-divided (rage reads 0..100). Falls back to UnitMana without ClassicAPI.
|
||||
API.UnitPower = UnitPower or function(unit, powerType)
|
||||
return UnitMana(unit)
|
||||
-- Display-divided (rage reads 0..100).
|
||||
function API.UnitPower(unit, powerType)
|
||||
return UnitPower(unit, powerType)
|
||||
end
|
||||
|
||||
API.UnitPowerMax = UnitPowerMax or function(unit, powerType)
|
||||
return UnitManaMax(unit)
|
||||
function API.UnitPowerMax(unit, powerType)
|
||||
return UnitPowerMax(unit, powerType)
|
||||
end
|
||||
|
||||
-- Power deficit (max - current) for the type / primary power, in one call.
|
||||
API.UnitPowerMissing = UnitPowerMissing or function(unit, powerType)
|
||||
return (UnitManaMax(unit) or 0) - (UnitMana(unit) or 0)
|
||||
function API.UnitPowerMissing(unit, powerType)
|
||||
return UnitPowerMissing(unit, powerType)
|
||||
end
|
||||
|
||||
-- Unit's primary power type as an integer (0=Mana .. 4=Happiness).
|
||||
|
||||
Reference in New Issue
Block a user