From fa19bc38329b7a64b82903f921494a28cf35013f Mon Sep 17 00:00:00 2001 From: Misa Date: Fri, 17 Dec 2021 23:36:13 -0800 Subject: [PATCH] Add asserts if `ingame_titlemode` in unexpected places The game will now assert if the main menu is created while ingame_titlemode is true, or if we attempt to load into a mode while it's true. And if assertions are disabled then it just stops doing it anyway. I don't think there's any way to get a glitched ingame_titlemode again, ever since I removed save data deletion taking you back to the main menu. But I've had enough bugs with the fact that we more-or-less use the same state for main menu options and in-game options, and that glitched ingame_titlemode bug DID just happen, so I'm taking precautions. --- desktop_version/src/Game.cpp | 6 ++++++ desktop_version/src/Input.cpp | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index c0fc98be..baa0a143 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -5937,6 +5937,12 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ ) switch (t) { case Menu::mainmenu: + if (ingame_titlemode) + { + /* We shouldn't be here! */ + SDL_assert(0 && "Entering main menu from in-game options!"); + break; + } #if !defined(MAKEANDPLAY) option("play"); #endif diff --git a/desktop_version/src/Input.cpp b/desktop_version/src/Input.cpp index 5696e7a4..ee4c0ba1 100644 --- a/desktop_version/src/Input.cpp +++ b/desktop_version/src/Input.cpp @@ -288,6 +288,13 @@ static void startmode(const int mode) static void handlefadetomode(void) { + if (game.ingame_titlemode) + { + /* We shouldn't be here! */ + SDL_assert(0 && "Loading a mode from in-game options!"); + return; + } + if (fadetomodedelay > 0) { --fadetomodedelay;