Skip to content

Commit

Permalink
Close the message box after a teleport when it was created by a backg…
Browse files Browse the repository at this point in the history
…round interpreter (parallel process)

Matches the RPG_RT behaviour

Fix #3301
  • Loading branch information
Ghabry committed Nov 24, 2024
1 parent 24c5fa6 commit 34784cf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/game_interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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<std::string> choices = GetChoices(4);
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 6 additions & 0 deletions src/game_interpreter_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;

Expand Down
4 changes: 4 additions & 0 deletions src/pending_message.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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;
};


Expand Down

0 comments on commit 34784cf

Please sign in to comment.