From 0ff1c4c6038b2ce07f4044e4f6b95175c3287cc6 Mon Sep 17 00:00:00 2001 From: Allen Faure Date: Sun, 8 Dec 2024 02:04:15 -0600 Subject: [PATCH 1/2] upgrade Unit Characteristics - Ignore Dead, and add Summon/Resurrect Pending properties Fixes #5569 --- WeakAuras/Modernize.lua | 20 ++++++++++++++++++++ WeakAuras/Prototypes.lua | 39 +++++++++++++++++++++++++++++---------- WeakAuras/WeakAuras.lua | 2 +- 3 files changed, 50 insertions(+), 11 deletions(-) diff --git a/WeakAuras/Modernize.lua b/WeakAuras/Modernize.lua index b2cf938b2b..c4db5ce280 100644 --- a/WeakAuras/Modernize.lua +++ b/WeakAuras/Modernize.lua @@ -2293,6 +2293,26 @@ function Private.Modernize(data, oldSnapshot) end end + if data.internalVersion < 79 then + if data.triggers then + for _, triggerData in ipairs(data.triggers) do + local trigger = triggerData.trigger + if trigger and trigger.type == "unit" and trigger.event == "Unit Characteristics" then + if trigger.use_ignoreDead then + if trigger.unit == "group" or trigger.unit == "raid" or trigger.unit == "party" then + trigger.use_dead = false + else + -- since this option was previously only available for group units, + -- nil it out if the unit isn't group to avoid surprises from vestigial data + trigger.use_dead = nil + end + end + trigger.use_ignoreDead = nil + end + end + end + end + data.internalVersion = max(data.internalVersion or 0, WeakAuras.InternalVersion()) end diff --git a/WeakAuras/Prototypes.lua b/WeakAuras/Prototypes.lua index 1431a2ad5f..ccfa6eec05 100644 --- a/WeakAuras/Prototypes.lua +++ b/WeakAuras/Prototypes.lua @@ -2284,6 +2284,8 @@ Private.event_prototypes = { AddUnitEventForEvents(result, unit, "UNIT_NAME_UPDATE") AddUnitEventForEvents(result, unit, "UNIT_FLAGS") AddUnitEventForEvents(result, unit, "PLAYER_FLAGS_CHANGED") + AddUnitEventForEvents(result, unit, "INCOMING_RESURRECT_CHANGED") + AddUnitEventForEvents(result, unit, "INCOMING_SUMMON_CHANGED") if trigger.use_inRange then AddUnitEventForEvents(result, unit, "UNIT_IN_RANGE_UPDATE") end @@ -2451,6 +2453,33 @@ Private.event_prototypes = { test = "true", init = "raidMarkIndex > 0 and '{rt'..raidMarkIndex..'}' or ''" }, + { + name = "dead", + display = L["Dead"], + type = "tristate", + width = WeakAuras.doubleWidth, + init = "UnitIsDeadOrGhost(unit)", + store = true, + conditionType = "bool", + }, + { + name = "resurrectPending", + display = L["Resurrect Pending"], + type = "tristate", + width = WeakAuras.doubleWidth, + init = "UnitHasIncomingResurrection(unit)", + store = true, + conditionType = "bool", + }, + { + name = "summonPending", + display = L["Summon Pending"], + type = "tristate", + width = WeakAuras.doubleWidth, + init = "C_IncomingSummon.HasIncomingSummon(unit)", + store = true, + conditionType = "bool", + }, { name = "ignoreSelf", display = L["Ignore Self"], @@ -2461,16 +2490,6 @@ Private.event_prototypes = { end, init = "not UnitIsUnit(\"player\", unit)" }, - { - name = "ignoreDead", - display = L["Ignore Dead"], - type = "toggle", - width = WeakAuras.doubleWidth, - enable = function(trigger) - return trigger.unit == "group" or trigger.unit == "raid" or trigger.unit == "party" - end, - init = "not UnitIsDeadOrGhost(unit)" - }, { name = "ignoreDisconnected", display = L["Ignore Disconnected"], diff --git a/WeakAuras/WeakAuras.lua b/WeakAuras/WeakAuras.lua index 58e37a8262..3ffc16f537 100644 --- a/WeakAuras/WeakAuras.lua +++ b/WeakAuras/WeakAuras.lua @@ -3,7 +3,7 @@ local AddonName = ... ---@class Private local Private = select(2, ...) -local internalVersion = 78 +local internalVersion = 79 -- Lua APIs local insert = table.insert From f90441ced93b24a5667eee3a4e1b35e86ae14d54 Mon Sep 17 00:00:00 2001 From: Allen Faure Date: Wed, 11 Dec 2024 03:39:28 -0600 Subject: [PATCH 2/2] harden conditions against garbage in custom state It's not impossible for a user to declare that a TSU variable is of type string, but then actually populate it with something else entirely. Unfortunately, "TSU variables are trustworthy" is an invariant conditions relies on, so e.g. a condition to check if a string variable contains a substring would fail if a joker populated the state variable with a non-string value. Since Conditions are evaluated on a critical path to opening options, we need to trap any errors from this kind of shenanigans to allow the user to back out of their foolishness. Simply wrapping RunConditions in xpcall will possibly lead to half finished property applications, but that is much preferable to Options bricking up. --- WeakAuras/Conditions.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WeakAuras/Conditions.lua b/WeakAuras/Conditions.lua index 123288fd66..90a0e3639d 100644 --- a/WeakAuras/Conditions.lua +++ b/WeakAuras/Conditions.lua @@ -843,7 +843,7 @@ end function Private.RunConditions(region, uid, hideRegion) if (checkConditions[uid]) then Private.ActivateAuraEnvironmentForRegion(region) - checkConditions[uid](region, hideRegion); + xpcall(checkConditions[uid], Private.GetErrorHandlerUid(uid, L["Execute Conditions"]), region, hideRegion); Private.ActivateAuraEnvironment() end end