From 2796e0974b4484e1c4803a7caa8d585fea70552c Mon Sep 17 00:00:00 2001 From: Matt Dallmeyer Date: Fri, 4 Sep 2026 06:28:21 -0700 Subject: [PATCH] Add imgui option to restart in retail mode (#4404) --- game/graphics/opengl_renderer/debug_gui.cpp | 3 +++ game/graphics/opengl_renderer/debug_gui.h | 3 ++- game/graphics/pipelines/opengl.cpp | 4 ++++ game/kernel/common/kboot.h | 1 + game/main.cpp | 13 +++++++++++++ 5 files changed, 23 insertions(+), 1 deletion(-) diff --git a/game/graphics/opengl_renderer/debug_gui.cpp b/game/graphics/opengl_renderer/debug_gui.cpp index c6b58997e1..5d1b38ae82 100644 --- a/game/graphics/opengl_renderer/debug_gui.cpp +++ b/game/graphics/opengl_renderer/debug_gui.cpp @@ -111,6 +111,9 @@ void OpenGlDebugGui::draw(const DmaStats& dma_stats) { if (ImGui::MenuItem("Reboot In Debug Mode!")) { want_reboot_in_debug = true; } + if (ImGui::MenuItem("Reboot In Retail Mode!")) { + want_reboot_in_retail = true; + } ImGui::EndMenu(); } diff --git a/game/graphics/opengl_renderer/debug_gui.h b/game/graphics/opengl_renderer/debug_gui.h index 477afaca0f..05c8b99817 100644 --- a/game/graphics/opengl_renderer/debug_gui.h +++ b/game/graphics/opengl_renderer/debug_gui.h @@ -67,6 +67,7 @@ class OpenGlDebugGui { bool record_events = false; int max_event_buffer_size = 65536; bool want_reboot_in_debug = false; + bool want_reboot_in_retail = false; bool screenshot_hotkey_enabled = true; @@ -88,4 +89,4 @@ class OpenGlDebugGui { namespace ImGui { void applyFontStyle(); -} \ No newline at end of file +} diff --git a/game/graphics/pipelines/opengl.cpp b/game/graphics/pipelines/opengl.cpp index d8d15c873a..166b2e1367 100644 --- a/game/graphics/pipelines/opengl.cpp +++ b/game/graphics/pipelines/opengl.cpp @@ -726,6 +726,10 @@ void GLDisplay::render() { g_gfx_data->debug_gui.want_reboot_in_debug = false; MasterExit = RuntimeExitStatus::RESTART_IN_DEBUG; } + if (g_gfx_data->debug_gui.want_reboot_in_retail) { + g_gfx_data->debug_gui.want_reboot_in_retail = false; + MasterExit = RuntimeExitStatus::RESTART_IN_RETAIL; + } { auto p = scoped_prof("check-close-window"); diff --git a/game/kernel/common/kboot.h b/game/kernel/common/kboot.h index 1fbbac2b15..ca1a926763 100644 --- a/game/kernel/common/kboot.h +++ b/game/kernel/common/kboot.h @@ -14,6 +14,7 @@ enum class RuntimeExitStatus { RESTART_RUNTIME = 1, EXIT = 2, RESTART_IN_DEBUG = 3, + RESTART_IN_RETAIL = 4, }; enum class VideoMode { diff --git a/game/main.cpp b/game/main.cpp index 035ea2c179..b3e83c7e17 100644 --- a/game/main.cpp +++ b/game/main.cpp @@ -242,6 +242,7 @@ int main(int argc, char** argv) { } bool force_debug_next_time = false; + bool force_retail_next_time = false; // always start with an empty arg, as internally kmachine starts at `1` not `0` std::vector arg_ptrs = {""}; for (auto& str : game_args) { @@ -261,6 +262,15 @@ int main(int argc, char** argv) { arg_ptrs.push_back(str.data()); } } + if (force_retail_next_time) { + force_retail_next_time = false; + arg_ptrs = {""}; // see above for rationale + for (auto& str : game_args) { + if (str != "-debug") { + arg_ptrs.push_back(str.data()); + } + } + } // run the runtime in a loop so we can reset the game and have it restart cleanly lg::info("OpenGOAL Runtime {}.{}", versions::GOAL_VERSION_MAJOR, versions::GOAL_VERSION_MINOR); @@ -276,6 +286,9 @@ int main(int argc, char** argv) { case RuntimeExitStatus::RESTART_IN_DEBUG: force_debug_next_time = true; break; + case RuntimeExitStatus::RESTART_IN_RETAIL: + force_retail_next_time = true; + break; } } catch (std::exception& ex) { lg::error("Unexpected exception occurred - {}", ex.what());