Skip to content

Commit 2d71cdc

Browse files
committed
Debug scene: Fix a crash when foreground interpreter stack is empty
1 parent 571e766 commit 2d71cdc

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/game_interpreter.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2044,13 +2044,13 @@ std::optional<bool> Game_Interpreter::HandleDynRpgScript(const lcf::rpg::EventCo
20442044
if (Player::IsPatchDynRpg() || Player::HasEasyRpgExtensions()) {
20452045
if (com.string.empty() || com.string[0] != '@') {
20462046
// Not a DynRPG command
2047-
return std::nullopt;
2047+
return {};
20482048
}
20492049

20502050
if (!Player::IsPatchDynRpg() && Player::HasEasyRpgExtensions()) {
20512051
// Only accept commands starting with @easyrpg_
20522052
if (!StartsWith(com.string, "@easyrpg_")) {
2053-
return std::nullopt;
2053+
return {};
20542054
}
20552055
}
20562056

@@ -2073,19 +2073,20 @@ std::optional<bool> Game_Interpreter::HandleDynRpgScript(const lcf::rpg::EventCo
20732073

20742074
return Main_Data::game_dynrpg->Invoke(command, this);
20752075
}
2076+
return {};
20762077
}
20772078

20782079
std::optional<bool> Game_Interpreter::HandleDestinyScript(const lcf::rpg::EventCommand& com) {
20792080
// DestinyScript
20802081
if (Player::IsPatchDestiny()) {
20812082
if (com.string.empty() || com.string[0] != '$') {
20822083
// Not a DestinyScript
2083-
return std::nullopt;
2084+
return {};
20842085
}
20852086

20862087
return Main_Data::game_destiny->Main(GetFrame());
20872088
}
2088-
return std::nullopt;
2089+
return {};
20892090
}
20902091

20912092
bool Game_Interpreter::CommandComment(const lcf::rpg::EventCommand &com) {

src/window_interpreter.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,13 @@ void Window_Interpreter::DrawDescriptionLines() {
199199
rect = GetItemRect(i++);
200200
contents->ClearRect(rect);
201201

202-
auto str_ex_type = std::string(Game_Interpreter_Shared::kExecutionType.tag(static_cast<int>(stack_display_items[0].type_ex)));
203-
contents->TextDraw(rect.x, rect.y, Font::ColorDefault, "(");
204-
contents->TextDraw(rect.x + 6, rect.y, Font::ColorHeal, str_ex_type);
205-
contents->TextDraw(rect.x + 6 * (str_ex_type.length() + 1), rect.y, Font::ColorDefault, ")");
202+
203+
if (stack_display_items.size() > 0) {
204+
auto str_ex_type = std::string(Game_Interpreter_Shared::kExecutionType.tag(static_cast<int>(stack_display_items[0].type_ex)));
205+
contents->TextDraw(rect.x, rect.y, Font::ColorDefault, "(");
206+
contents->TextDraw(rect.x + 6, rect.y, Font::ColorHeal, str_ex_type);
207+
contents->TextDraw(rect.x + 6 * (str_ex_type.length() + 1), rect.y, Font::ColorDefault, ")");
208+
}
206209
contents->TextDraw(rect.x + rect.width / 2, rect.y, Font::ColorDefault, "Stack Size: ");
207210
contents->TextDraw(GetWidth() - 16, rect.y, Font::ColorCritical, std::to_string(state.stack.size()), Text::AlignRight);
208211
}

0 commit comments

Comments
 (0)