diff --git a/src/Application.cpp b/src/Application.cpp index 7549099..73725a6 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -2359,6 +2359,9 @@ void Application::handle(const SDL_SysWMEvent* syswm) case IDM_RESET_GAME: _fsm.resetGame(); + + if (isPaused()) + _fsm.step(); break; case IDM_SAVE_STATE_1: @@ -2685,6 +2688,9 @@ void Application::handle(const KeyBinds::Action action, unsigned extra) case KeyBinds::Action::kReset: _fsm.resetGame(); + + if (isPaused()) + _fsm.step(); break; case KeyBinds::Action::kScreenshot: diff --git a/src/Fsm.cpp b/src/Fsm.cpp index 11db8ae..2ff6e08 100644 --- a/src/Fsm.cpp +++ b/src/Fsm.cpp @@ -682,21 +682,17 @@ bool Fsm::resetGame() { return false; } - bool __ok = resumeGame() && - resetGame(); - if (__ok) { - after(__state); - after(); + ctx.resetGame(); + + __state = State::GamePaused; + after(__state); + after(); - } - else { #ifdef DEBUG_FSM - ctx.printf("FSM %s:%u Failed to switch to %s", __FUNCTION__, __LINE__, stateName(State::GameRunning)); + ctx.printf("FSM %s:%u Switched to %s", __FUNCTION__, __LINE__, stateName(State::GameRunning)); #endif - } - - return __ok; + return true; } break; @@ -717,21 +713,17 @@ bool Fsm::resetGame() { return false; } - bool __ok = resumeGame() && - resetGame(); - if (__ok) { - after(__state); - after(); + ctx.resetGame(); + + __state = State::GamePausedNoOvl; + after(__state); + after(); - } - else { #ifdef DEBUG_FSM - ctx.printf("FSM %s:%u Failed to switch to %s", __FUNCTION__, __LINE__, stateName(State::GameRunning)); + ctx.printf("FSM %s:%u Switched to %s", __FUNCTION__, __LINE__, stateName(State::GameRunning)); #endif - } - - return __ok; + return true; } break; diff --git a/src/Fsm.fsm b/src/Fsm.fsm index 0b606e1..2e265ba 100644 --- a/src/Fsm.fsm +++ b/src/Fsm.fsm @@ -129,7 +129,9 @@ fsm Fsm { GamePaused { resumeGame() => GameRunning; - resetGame() => resumeGame() => resetGame(); + resetGame() => GamePaused { + ctx.resetGame(); + } step() => FrameStep { if (ctx.hardcore()) { @@ -155,7 +157,9 @@ fsm Fsm { resumeGame() => GameRunning; - resetGame() => resumeGame() => resetGame(); + resetGame() => GamePausedNoOvl { + ctx.resetGame(); + } step() => FrameStep { if (ctx.hardcore()) {