diff --git a/src/game_interpreter.cpp b/src/game_interpreter.cpp index d903697b8f..e3fca05e25 100644 --- a/src/game_interpreter.cpp +++ b/src/game_interpreter.cpp @@ -882,6 +882,7 @@ bool Game_Interpreter::CommandShowMessage(lcf::rpg::EventCommand const& com) { / PendingMessage pm(Game_Message::CommandCodeInserter); pm.SetIsEventMessage(true); + pm.SetFromForegroundInterpreter(main_flag); // Set first line pm.PushLine(ToString(com.string)); @@ -978,6 +979,7 @@ bool Game_Interpreter::CommandShowChoices(lcf::rpg::EventCommand const& com) { / PendingMessage pm(Game_Message::CommandCodeInserter); pm.SetIsEventMessage(true); + pm.SetFromForegroundInterpreter(main_flag); // Choices setup std::vector choices = GetChoices(4); @@ -1009,6 +1011,7 @@ bool Game_Interpreter::CommandInputNumber(lcf::rpg::EventCommand const& com) { / PendingMessage pm(Game_Message::CommandCodeInserter); pm.SetIsEventMessage(true); + pm.SetFromForegroundInterpreter(main_flag); int variable_id = com.parameters[1]; int digits = com.parameters[0]; @@ -1651,6 +1654,7 @@ bool Game_Interpreter::CommandChangeExp(lcf::rpg::EventCommand const& com) { // PendingMessage pm(Game_Message::CommandCodeInserter); pm.SetEnableFace(false); + pm.SetFromForegroundInterpreter(main_flag); for (const auto& actor : GetActors(com.parameters[0], com.parameters[1])) { actor->ChangeExp(actor->GetExp() + value, show_msg ? &pm : nullptr); @@ -1681,6 +1685,7 @@ bool Game_Interpreter::CommandChangeLevel(lcf::rpg::EventCommand const& com) { / PendingMessage pm(Game_Message::CommandCodeInserter); pm.SetEnableFace(false); + pm.SetFromForegroundInterpreter(main_flag); for (const auto& actor : GetActors(com.parameters[0], com.parameters[1])) { actor->ChangeLevel(actor->GetLevel() + value, show_msg ? &pm : nullptr); @@ -3956,6 +3961,7 @@ bool Game_Interpreter::CommandChangeClass(lcf::rpg::EventCommand const& com) { / PendingMessage pm(Game_Message::CommandCodeInserter); pm.SetEnableFace(false); + pm.SetFromForegroundInterpreter(main_flag); const lcf::rpg::Class* cls = lcf::ReaderUtil::GetElement(lcf::Data::classes, class_id); if (!cls && class_id != 0) { diff --git a/src/game_interpreter_map.cpp b/src/game_interpreter_map.cpp index d26586ebbe..db700abe0e 100644 --- a/src/game_interpreter_map.cpp +++ b/src/game_interpreter_map.cpp @@ -90,6 +90,11 @@ void Game_Interpreter_Map::OnMapChange() { for (auto& frame: _state.stack) { frame.event_id = 0; } + + // When the message was created by a parallel process, close it + if (Game_Message::IsMessageActive() && !Game_Message::GetWindow()->GetPendingMessage().IsFromForegroundInterpreter()) { + Game_Message::GetWindow()->FinishMessageProcessing(); + } } bool Game_Interpreter_Map::RequestMainMenuScene(int subscreen_id, int actor_index, bool is_db_actor) { @@ -457,6 +462,7 @@ bool Game_Interpreter_Map::CommandShowInn(lcf::rpg::EventCommand const& com) { / } PendingMessage pm(Game_Message::CommandCodeInserter); + pm.SetFromForegroundInterpreter(main_flag); StringView greeting_1, greeting_2, greeting_3, accept, cancel; diff --git a/src/pending_message.h b/src/pending_message.h index 793d47e498..9e81a12eaa 100644 --- a/src/pending_message.h +++ b/src/pending_message.h @@ -68,6 +68,9 @@ class PendingMessage { void SetIsEventMessage(bool value) { is_event_message = value; } bool IsEventMessage() const { return is_event_message; } + + void SetFromForegroundInterpreter(bool value) { from_fg_interpreter = value; } + bool IsFromForegroundInterpreter() const { return from_fg_interpreter; } static std::string ApplyTextInsertingCommands(std::string input, uint32_t escape_char, const CommandInserter& cmd_fn); private: @@ -85,6 +88,7 @@ class PendingMessage { bool show_gold_window = false; bool enable_face = true; bool is_event_message = false; + bool from_fg_interpreter = false; };