From 2e8b808683abf95902b68853a1c3c1d520b4c28c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 4 Sep 2020 22:23:38 +0200 Subject: [PATCH] - added a C_ClearMessages function for the console and fixed game restart after death. Fixes #322 --- source/blood/src/player.cpp | 3 ++- source/common/console/c_console.h | 1 + source/core/console/c_console.cpp | 5 +++++ source/core/mainloop.cpp | 6 +++--- source/sw/src/player.cpp | 3 ++- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/source/blood/src/player.cpp b/source/blood/src/player.cpp index bb3c02bf5..5f379262c 100644 --- a/source/blood/src/player.cpp +++ b/source/blood/src/player.cpp @@ -47,6 +47,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "messages.h" #include "nnexts.h" #include "gstrings.h" +#include "gamestate.h" BEGIN_BLD_NS @@ -1369,7 +1370,7 @@ void ProcessInput(PLAYER *pPlayer) playerReset(pPlayer); if (gGameOptions.nGameType == 0 && numplayers == 1) { - DeferedStartGame(currentLevel, -1); + gameaction = ga_autoloadgame; } else playerStart(pPlayer->nPlayer); diff --git a/source/common/console/c_console.h b/source/common/console/c_console.h index d7cbe5d95..5ea3f8f34 100644 --- a/source/common/console/c_console.h +++ b/source/common/console/c_console.h @@ -57,6 +57,7 @@ extern constate_e ConsoleState; void C_InitConsole (int width, int height, bool ingame); void C_DeinitConsole (); void C_InitConback(); +void C_ClearMessages(); // Adjust the console for a new screen mode void C_NewModeAdjust (void); diff --git a/source/core/console/c_console.cpp b/source/core/console/c_console.cpp index d5edf4120..432afe6b4 100644 --- a/source/core/console/c_console.cpp +++ b/source/core/console/c_console.cpp @@ -935,6 +935,11 @@ int PrintString (int iprintlevel, const char *outline) return 0; // Don't waste time on calculating this if nothing at all was printed... } +void C_ClearMessages() +{ + NotifyStrings.Clear(); +} + int VPrintf (int printlevel, const char *format, va_list parms) { FString outline; diff --git a/source/core/mainloop.cpp b/source/core/mainloop.cpp index a9c792abe..f8a1d4762 100644 --- a/source/core/mainloop.cpp +++ b/source/core/mainloop.cpp @@ -136,12 +136,11 @@ static void GameTicker() case ga_autoloadgame: // todo: for now just handle the restart case g_nextmap = currentLevel; - g_nextskill = -1; FX_StopAllSounds(); FX_SetReverb(0); gi->FreeLevelData(); - gamestate = GS_LEVEL; - gi->NextLevel(g_nextmap, -1); + C_ClearMessages(); + gi->NewGame(g_nextmap, -1); break; case ga_completed: @@ -168,6 +167,7 @@ static void GameTicker() FX_StopAllSounds(); FX_SetReverb(0); gi->FreeLevelData(); + C_ClearMessages(); gamestate = GS_LEVEL; gi->NewGame(g_nextmap, g_nextskill); break; diff --git a/source/sw/src/player.cpp b/source/sw/src/player.cpp index 869a41ddb..c1ce4f52a 100644 --- a/source/sw/src/player.cpp +++ b/source/sw/src/player.cpp @@ -54,6 +54,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "menu.h" #include "gstrings.h" #include "raze_music.h" +#include "gamestate.h" BEGIN_SW_NS @@ -6661,7 +6662,7 @@ void DoPlayerDeathCheckKeys(PLAYERp pp) } else { - DeferedStartGame(currentLevel, -1); + gameaction = ga_autoloadgame; } DoPlayerFireOutDeath(pp);