diff options
-rw-r--r-- | engines/mutationofjb/commands/randomcommand.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/engines/mutationofjb/commands/randomcommand.cpp b/engines/mutationofjb/commands/randomcommand.cpp index ff03e96cc6..b9cc303125 100644 --- a/engines/mutationofjb/commands/randomcommand.cpp +++ b/engines/mutationofjb/commands/randomcommand.cpp @@ -74,8 +74,13 @@ bool RandomBlockStartParser::parse(const Common::String &line, ScriptParseContex } void RandomBlockStartParser::transition(ScriptParseContext &parseCtx, Command *, Command *newCommand, CommandParser *) { - if (newCommand && parseCtx._pendingRandomCommand) { - parseCtx._pendingRandomCommand->_choices.push_back(newCommand); + RandomCommand *randomCommand = parseCtx._pendingRandomCommand; + if (newCommand && randomCommand) { + randomCommand->_choices.push_back(newCommand); + + if (randomCommand->_choices.size() == randomCommand->_numChoices) { + parseCtx._pendingRandomCommand = nullptr; + } } } |