From eecb17bc0f58fc2c1c5f6845d4e2c31aad5fc54a Mon Sep 17 00:00:00 2001 From: Matthew Fioravante Date: Sun, 18 Aug 2019 10:25:57 -0400 Subject: [PATCH] Cleanup ShowMessages command - Don't loop over choices or number input - Increment index after choices and number input (broken in earlier commit) --- src/game_interpreter.cpp | 60 +++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/src/game_interpreter.cpp b/src/game_interpreter.cpp index d149e527416..44618e65680 100644 --- a/src/game_interpreter.cpp +++ b/src/game_interpreter.cpp @@ -803,37 +803,39 @@ bool Game_Interpreter::CommandShowMessage(RPG::EventCommand const& com) { // cod Game_Message::texts.push_back(com.string); line_count++; - for (; index + 1 < list.size(); index++) { - // If next event command is the following parts of the message - if (list[index+1].code == Cmd::ShowMessage_2) { - // Add second (another) line - line_count++; - Game_Message::texts.push_back(list[index+1].string); - } else { - // If next event command is show choices - if (list[index+1].code == Cmd::ShowChoice) { - std::vector s_choices = GetChoices(); - // If choices fit on screen - if (s_choices.size() <= (4 - line_count)) { - index++; - Game_Message::choice_start = line_count; - Game_Message::choice_cancel_type = list[index].parameters[0]; - SetupChoices(s_choices, com.indent); - } - } else if (list[index+1].code == Cmd::InputNumber) { - // If next event command is input number - // If input number fits on screen - if (line_count < 4) { - index++; - Game_Message::num_input_start = line_count; - Game_Message::num_input_digits_max = list[index].parameters[0]; - Game_Message::num_input_variable_id = list[index].parameters[1]; - } - } + ++index; - break; + // Check for continued lines via ShowMessage_2 + while (index < list.size() && list[index].code == Cmd::ShowMessage_2) { + // Add second (another) line + line_count++; + Game_Message::texts.push_back(list[index].string); + ++index; + } + + // Handle Choices or number + if (index < list.size()) { + // If next event command is show choices + if (list[index].code == Cmd::ShowChoice) { + std::vector s_choices = GetChoices(); + // If choices fit on screen + if (s_choices.size() <= (4 - line_count)) { + Game_Message::choice_start = line_count; + Game_Message::choice_cancel_type = list[index].parameters[0]; + SetupChoices(s_choices, com.indent); + ++index; + } + } else if (list[index].code == Cmd::InputNumber) { + // If next event command is input number + // If input number fits on screen + if (line_count < 4) { + Game_Message::num_input_start = line_count; + Game_Message::num_input_digits_max = list[index].parameters[0]; + Game_Message::num_input_variable_id = list[index].parameters[1]; + ++index; + } } - } // End for + } return true; }