Skip to content

Use gmcp helper in OnPluginBroadcast#101

Open
rodarvus wants to merge 1 commit into
zzyzzyzzx:masterfrom
rodarvus:refactor/onpluginbroadcast-use-gmcp-helper
Open

Use gmcp helper in OnPluginBroadcast#101
rodarvus wants to merge 1 commit into
zzyzzyzzx:masterfrom
rodarvus:refactor/onpluginbroadcast-use-gmcp-helper

Conversation

@rodarvus

Copy link
Copy Markdown

Summary

OnPluginBroadcast in SpellupRecast/Hadar_Spellups.xml had four sites that each manually performed the CallPlugin → loadstring("gmcpdata = ..") → gmcpval(...) pattern just to read a single GMCP field. The gmcp() helper from gmcphelper — already required at the top of the script and already used elsewhere in this plugin — wraps exactly that pattern and returns the value directly.

This converts each pair to the equivalent direct gmcp() call:

Before After
CallPlugin/loadstring/gmcpval("status.state") gmcp("char.status.state")
CallPlugin/loadstring/gmcpval("vitals.mana") gmcp("char.vitals.mana")
CallPlugin/loadstring/gmcpval("maxstats.maxmana") gmcp("char.maxstats.maxmana")

The two bare gmcpval(...) calls in the SpellsDisabled branch had been relying on whatever gmcpdata the most recent inline loadstring happened to populate. Those are converted to direct gmcp() calls too, so they stop depending on the side-effect.

No behavior change — gmcp() internally does the same CallPlugin round-trip to aard_GMCP_handler. The change removes ~16 lines of duplicated boilerplate from the hot path that runs on every GMCP broadcast.

Test plan

  • Reload plugin, exercise char.status / char.vitals / char.maxstats broadcasts in MUSHclient (movement, damage, regen). Verified by author.
  • Confirm spellups still recast on {affoff} after the change. Verified by author.
  • Confirm hsp debug output for vitals/maxstats values is unchanged. Verified by author.

🤖 Generated with Claude Code

OnPluginBroadcast had four sites that each manually did the
CallPlugin -> loadstring("gmcpdata = ..") -> gmcpval(...) pattern
to read a single GMCP field. gmcphelper's gmcp() function -- already
required at the top of the script and already used elsewhere in this
plugin -- wraps exactly that pattern and returns the value directly.

Replace each pair with the equivalent direct gmcp() call:

  CallPlugin/loadstring/gmcpval("status.state")    -> gmcp("char.status.state")
  CallPlugin/loadstring/gmcpval("vitals.mana")     -> gmcp("char.vitals.mana")
  CallPlugin/loadstring/gmcpval("maxstats.maxmana") -> gmcp("char.maxstats.maxmana")

The two bare gmcpval(...) calls in the SpellsDisabled branch were
reading from whatever gmcpdata was last populated by an earlier
loadstring side-effect; convert those to direct gmcp() calls too.

No behavior change: gmcp() internally does the same CallPlugin round-
trip to aard_GMCP_handler. The change removes ~16 lines of duplicated
boilerplate from the hot path.

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