Use gmcp helper in OnPluginBroadcast#101
Open
rodarvus wants to merge 1 commit into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
OnPluginBroadcastinSpellupRecast/Hadar_Spellups.xmlhad four sites that each manually performed theCallPlugin → loadstring("gmcpdata = ..") → gmcpval(...)pattern just to read a single GMCP field. Thegmcp()helper fromgmcphelper— alreadyrequired 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: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 theSpellsDisabledbranch had been relying on whatevergmcpdatathe most recent inlineloadstringhappened to populate. Those are converted to directgmcp()calls too, so they stop depending on the side-effect.No behavior change —
gmcp()internally does the sameCallPluginround-trip toaard_GMCP_handler. The change removes ~16 lines of duplicated boilerplate from the hot path that runs on every GMCP broadcast.Test plan
char.status/char.vitals/char.maxstatsbroadcasts in MUSHclient (movement, damage, regen). Verified by author.{affoff}after the change. Verified by author.hsp debugoutput for vitals/maxstats values is unchanged. Verified by author.🤖 Generated with Claude Code