Maniac Patch: self-variables, scoped modes 5/6, BreakLoop fix, negative IDs in messages#3546
Closed
luadebug wants to merge 4 commits into
Closed
Maniac Patch: self-variables, scoped modes 5/6, BreakLoop fix, negative IDs in messages#3546luadebug wants to merge 4 commits into
luadebug wants to merge 4 commits into
Conversation
RPG Maker games using the Maniac Patch can use negative variable IDs (-1 to -64) as "self-variables" — per-context scratch storage that doesn't pollute the global variable table. Add a 64-element `_self_vars` array to Game_Variables. Get() returns from this array for IDs in [-64..-1], SetOp() writes to it, and ShouldWarn() suppresses spurious out-of-range warnings for valid negative IDs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…Mode Mode 5 (ScopedSingle) and mode 6 (ScopedRange) address self-variables by a 1-based positive index that maps to negative IDs: params[1]=1 becomes variable ID -1, etc. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The vanilla RPG_RT emulation for BreakLoop unconditionally jumps to the next EndLoop command in the list, which is correct for vanilla 2003 but wrong under Maniac Patch where BreakLoop can appear inside conditionals nested within a loop. Example: BreakLoop at indent=2 (inside an if at indent=1 inside an infinite loop at indent=0) must break the outer loop, not whatever inner loop happens to have its EndLoop appear next in the bytecode. For Maniac Patch, scan backward from the BreakLoop to find the innermost enclosing Loop command, tracking EndLoop/Loop pairs to handle already-closed nested loops correctly, then skip forward to its EndLoop. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ParseParam() treats a leading '-' inside brackets as stopping digit parsing, so \v[-1] was returned as 0 instead of reading self-variable -1. Add an is_negative flag that consumes the '-' and negates the parsed value, matching the Maniac Patch behaviour for \v[-N], \t[-N], \c[-N], etc. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Member
|
I will directly tell you that we will not accept a contribution of such a complex feature from an unknown "developer". Especially not one who sends us vibecoded stuff. Your AI already made something up and wasted our time with the much simpler Set Game Option contribution. Just looking for 1 minute at it this patch already makes no sense: The scoped variables are per event and not some "negative index global scratch buffer". I give you a warning because of spamming. Next AI slop contribution is a ban. |
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
Four fixes for Maniac Patch behaviour, discovered while running SOLDIERS -DesireWing- (RPG Maker 2003 + Maniac Patch). The game uses all four features heavily in its Baton formation menu.
1. Self-variables (negative variable IDs -1..-64)
Maniac Patch defines variable IDs -1 through -64 as "self-variables" — per-context scratch storage separate from the global variable table. Adds a
_self_vars[64]array toGame_VariableswithGet()andSetOp()support for negative IDs, and suppresses spurious out-of-range warnings for valid negative IDs inShouldWarn().2. Scoped variable modes 5 and 6 in
DecodeTargetEvaluationModeMode 5 (
ScopedSingle) and mode 6 (ScopedRange) address self-variables by a 1-based positive index incom.parameters[1]that maps to a negative ID:params[1] = 1→ variable ID-1, etc. These modes were silently falling through to thedefault:branch (id_0 = 0).3. BreakLoop — find actual enclosing loop by scanning backward
The previous Maniac Patch path used
SkipToNextConditional({EndLoop}, indent - 1), which breaks whenBreakLoopis nested inside conditionals within a loop. Example:BreakLoopat indent 3 (inside two levels ofifinside an infinite loop at indent 0) was usingindent - 1 = 2to search forEndLoop, finding the wrong target.Fix: scan backward from
BreakLoopto find the innermost enclosingLoopcommand (trackingEndLoop/Looppairs to skip already-closed nested loops), then scan forward to itsEndLoop. The vanilla RPG_RT bug-emulation path is unchanged.4.
ParseParam: support\v[-N]negative variable IDs in message escape sequencesParseParam()treated a leading-inside brackets as a non-digit, settingstop_parsing = trueand returning 0. Adds anis_negativeflag that consumes the-before the digit loop and negates the parsed value at the end. Affects all escape sequences that callParseParam:\v[N],\t[N],\c[N],\s[N],\n[N].References
Test case
Game: SOLDIERS -DesireWing- (RPG Maker 2003 + Maniac Patch)
\v[-1]inShowStringPictureto display character SPD from self-variables → previously always showed 0BreakLoopat indent 2 inside aConditionalBranchat indent 1 inside an infinite loop at indent 0 → previously could not exit the menu