Skip to content

Wire up HSPRecoveriesCapture to populate affectedrecovery#104

Open
rodarvus wants to merge 1 commit into
zzyzzyzzx:masterfrom
rodarvus:fix/wire-up-hsp-recoveries-capture
Open

Wire up HSPRecoveriesCapture to populate affectedrecovery#104
rodarvus wants to merge 1 commit into
zzyzzyzzx:masterfrom
rodarvus:fix/wire-up-hsp-recoveries-capture

Conversation

@rodarvus

Copy link
Copy Markdown

Summary

HSPRecoveriesCapture in SpellupRecast/Hadar_Spellups.xml fires on every row of the {recoveries hsp} sub-section that slist hsp emits after the spell list — but the trigger had no capture groups and no script attribute, so the rows were silently gagged from output and never parsed. The complete slist hsp output looks like:

{spellheaders hsp}
... spell rows handled by SlistUpdate ...
{/spellheaders}
{recoveries hsp}
40,Hex,15            <- caught by HSPRecoveriesCapture, then discarded
41,Tempering,0
...
{/recoveries}

The {recoveries hsp} rows tell us the current state of each recovery group from the server's point of view. Spellups["RT"]["affectedrecovery"] is supposed to mirror that state, but the only writers were recon() / recoff() reacting to live events — meaning a plugin reload, fresh install, or any mid-session reconnect inherited stale or missing recovery state until the next live transition.

This PR adds capture groups to the trigger regex, wires it to a new RecoveriesUpdate script that writes each row into affectedrecovery, and makes the slist refresh the authoritative source for that table.

Diff overview

Trigger:

- match="^[0-9]+,[^,]+,[0-9]+$"
+ match="^([0-9]+),([^,]+),([0-9]+)$"
+ script="RecoveriesUpdate"

New function next to SlistUpdate:

function RecoveriesUpdate(name, line, wildcards)
    local rc = tonumber(wildcards[1])
    local seconds = tonumber(wildcards[3])

    if rc == nil or seconds == nil then return end

    if seconds > 0 then
        Spellups["RT"]["affectedrecovery"][rc] = seconds
    else
        Spellups["RT"]["affectedrecovery"][rc] = nil
    end
end

Why this matters now

A companion PR (#103) fixes a crash in recon/recoff that could leave stale entries in affectedrecovery and persist them to disk. Wiring up RecoveriesUpdate means that even users who had stale entries from before the crash fix will see their state self-heal on the next slist refresh, instead of needing to manually delete the plugin state file.

It also fixes the long-standing case where a fresh install or reconnect mid-recovery had no way to learn about active recoveries until each one individually ended and {recoff} fired.

Test plan

  • Static: confirmed the trigger lifecycle — HSPRecoveriesStart enables Capture and End, End disables all three. Adding a script to Capture only changes per-row behavior; lifecycle unchanged.
  • Static: wildcards[1] (rc) and wildcards[3] (seconds) are guarded with tonumber and nil-checks.
  • In-game: trigger an active recovery (cast any spell with cooldown), wait for slist hsp (auto-fires on char.status), confirm affectedrecovery reflects current server state. Confirm affoff for affected spell groups correctly skips recast during cooldown.

🤖 Generated with Claude Code

The HSPRecoveriesCapture trigger fired on every row of the
{recoveries hsp} sub-section of "slist hsp" output -- but had no
script attribute and no capture groups, so the rows were silently
gagged. The slist recovery state was never propagated to
Spellups["RT"]["affectedrecovery"].

Add capture groups (rc, name, seconds_remaining) and a script
RecoveriesUpdate that writes the row into affectedrecovery: a non-zero
seconds value sets the entry, a zero value clears it. This makes the
slist refresh the authoritative source for affectedrecovery, which
heals any stale entries that might be left over from earlier bugs
(see the recon/recoff nil-guard PR) and lets a fresh plugin install or
mid-session reconnect inherit the player's current recovery state.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant