[ANSWERED] Bug Fix Request - Jump to Label looping issue

So, VX Ace has a major issue with labels and choice branching... the problem is very easy to recreate on a brand new game with no plugins:

1730065000412.png

When jumping to a label below the jump (from "Jump to Label: this_works" to "Label: this_works"), everything functions as expected. You see "normal text 1" followed by "normal text 2" and then the dialog exits.

1730065146812.png


But when jumping to the label above the jump (from "Jump to Label: this_loops" to "Label: this_loops"), the engine will render the "loop part 1" text, will jump to the label, render "loop part 2"... and then, inexplicably, go back and render "loop part 1" again, followed by jumping to the label, then "loop part 2", repeat infinitely until the user closes the game.

Does a bug patch to fix this label bug exist?

Like, I can work around it, it's a pretty predictable issue, but my game has some deeply stacked if/else blocks for managing quest entry points and it would be really nice if I could use labels to keep things tidy without worrying that re-ordering the blocks might trap my beta testers in infinite loops. It scares me a little to have such a big game built on an engine where basic features don't work as expected... :I
It's not really an issue, but an unexpected use of the (Jump to) Label command indeed. This is why I wouldn't dare to call it a bug for it was supposed to be used in a more linear way than yours. The only reason why it fails is because nothing is telling the engine that your label has become part of a given choice.

You could place the contents of both labels BELOW the choices and exit the event processing based on your needs.
Thanks for the response!

It does feel like it's not an intuitive way for jumps and choices to work. Granted, so much of what's actually going on under the hood with choices is obfuscated by the RPG Maker psuedocode, but the flow of control leading back into the top of the choice that initiated the jump, ensuring a loop, rather than flowing directly into the other choice options underneath it or exiting the choice structure normally doesn't feel like intended functionality. I'm having a hard time envisioning what the underlying logic structure is there.

What do you mean by "nothing is telling the engine that your label has become part of a given choice?"

There are definitely ways around it, as you said. I'd like to improve my understanding how these two components interact so that I can avoid non-expected control flow problems in the future.
I'm not familiar with VXAce, so I can't fix it myself, but I think I have a good guess as to what's going on. There is likely some field in the interpreter that stores the choice the player selected. When going through the list of commands, whenever the interpreter encounters a "When" block, it checks if it matches that field. If it does, it runs the contents of that choice block, and otherwise skips it.

So a reasonable fix would be to clear that field whenever a jump command is processed, or maybe even right after entering a "When" block.
Sadly, I don't think so. The problem is that there is nothing to be cleared because it didn't go through the natural choice processing mechanism already implemented in the engine. This means that the Game_Interpreter will interpret the following lines as just any other type of event commands. 🙁 So it won't stop where it was supposed to because nothing told it that it was reading a choice event command.
Agreed, this isn't a bug, you've selected which choice you want to do - the engine is just storing that and continuing back down to that event block.

If you need to do something like this...I had this whole thing typed up and I'm not going to bother, because it's basically the same thing @kyonides said in post #2.
Thank you very much for the explanations--that helps me understand what's going on here.

It still seems like a unintuitive/incomplete implementation if "Jump to" aborts choice processing in such a manner as to so easily create unintentional loops... I was envisioning the code underpinning the choice structure as a switch case with decision logic at the top and and breaks after each case. But my Ruby knowledge is pretty minimal and I'm definitely bringing in assumptions from the other languages I've worked with.

I'll keep this in mind when I'm building jumpy branchy dialog structures in the future. Thanks again for the assistance! I'll update the title now that this topic has been solved.
My suggestion is you use a variable to store your choice and below the choice use a if structure to do the job.
Show choices 1,2,3,4
when 1
variable = 1
when 2
variable = 2
when 3
variable = 3
when 4
variable = 4

if variable = 1
blanblah
if variable = 2
blanblah
.....
I don't think this is really intended. The decision to process an indented section instead of skipping it would normally only be triggered once, right after the choice is made by the previous "master" command.

As Mac15001900 mentioned, the info which block to jump into is never actually cleared, so if you reach the block a second time using jump commands without making a new choice first, the section will be processed again. The info does not even have to come from the same "Show Choices" or "Battle Processing" command.

I think the reason this is usually not an issue is that using labels to jump into a choice box is rarely done in pratice, since it usually just makes the event unnecessarily more complex.
More often you would do something similar to what utunnels is describing and have separate sections you could either jump to with labels or address with variables.

--

Still, if it bothers you, you could try something like this to replace the branch info after using "Jump to Label" (I have not actually tested this yet):
Spoiler
Code:
class Game_Interpreter
 
  # Jump to Label
  alias_method(:command_119_beforeBranchClear, :command_119)
  def command_119
    command_119_beforeBranchClear
    @branch = [:cleared_by_jump] * @indent  if @list[@index].code == 118
  end
end

Not related, but another bug I know of would be the "Break Loop" command, which by default jumps behind the next "Repeat Above" command with less indent, which in rare cases does not belong to the loop you want to break.
Both issues have been fixed in MV, in VXAce you could attempt to use this (also not tested):
Spoiler
Code:
class Game_Interpreter

  # Break Loop
  def command_113
    extra_loops = 0
    while @index < @list.length - 1
      @index += 1
      if @list[@index].code == 112
        extra_loops += 1
      elsif @list[@index].code == 413
        return  if extra_loops == 0
        extra_loops -= 1
      end
    end
  end
end
I know you said you've got ways around it but I'll just post some for if my ideas are different.
Either: Make "Loop Part 2" a common event and call that common event on both choices.
Or: Add a second Jump Lable from after "Loop Part 2" that takes the processing to below the Show Choices.
Another Fen said:
As Mac15001900 mentioned, the info which block to jump into is never actually cleared...

Please read my two previous posts here. I made it clear that's NOT happening.
It's not about not being cleared. It's just that it never got called by the jump to label command, thus, it can't be cleared because there's no choice block from the J2L perspective. The OP would have to do something like what I suggested before or use a common event like @Zahawk mentioned above.
I agree with your suggestion and that OPs use of the Label command is kind of unexpected.

As for the clearing, I'm not sure if we are talking past each other here. My point was supposed to be that, regardless of whether using a label inside a branch would be a good idea in practise, the behaviour in OPs case is likely a bug and not intended, especially when expanding on it:
Spoiler
EventLabels.jpg
Not a bug at all. It would be if the choices processing command were made of something like a case statement. It's not, it never was. Honestly, it's processed by a loop that breaks just when the player presses the OK button and sometimes the Cancel button as well.

When it reads the Jump to label command, the choice command has finished successfully, cleared the corresponding variable (by reducing the indent by 1). Then the OP makes the event jump to something that is not properly linked to the choice command. The loop I mentioned above is not running at all. So how do you expect it to realize there's a choice event command there? It just can't.

What the OP did was simply breaking the engine's event processing design. Nothing else.

In order to call something a bug, you gotta know exactly how it's supposed to work.
What @Another Fen told us about the Break Loop command does sound like a real bug indeed.

Original thread: https://forums.rpgmakerweb.com/threads/answered-bug-fix-request-jump-to-label-looping-issue.172872/