Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issue 3301 #3304

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading