From 1460dec6d81aaf57195cc7fb3660c836a45f1763 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Sun, 11 Mar 2018 03:47:11 +0000 Subject: [PATCH] In case a requested quick load upon death cannot be completed, perform a pistol start instead of doing nothing git-svn-id: https://svn.eduke32.com/eduke32@6761 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/duke3d/src/game.cpp | 3 ++- source/duke3d/src/gameexec.cpp | 13 ++++++++++--- source/duke3d/src/menus.cpp | 16 +++++++++++----- source/duke3d/src/savegame.cpp | 4 +++- source/duke3d/src/savegame.h | 2 +- 5 files changed, 27 insertions(+), 11 deletions(-) diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index a41199f28..96109382f 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -4952,7 +4952,8 @@ FAKE_F3: KB_FlushKeyboardQueue(); KB_ClearKeysDown(); S_PauseSounds(1); - G_LoadPlayerMaybeMulti(*g_quickload); + if (G_LoadPlayerMaybeMulti(*g_quickload) != 0) + g_quickload->reset(); } } diff --git a/source/duke3d/src/gameexec.cpp b/source/duke3d/src/gameexec.cpp index 0d6ba420a..502146428 100644 --- a/source/duke3d/src/gameexec.cpp +++ b/source/duke3d/src/gameexec.cpp @@ -1095,8 +1095,11 @@ static int32_t VM_ResetPlayer(int const playerNum, int32_t vmFlags, int32_t cons KB_ClearKeysDown(); FX_StopAllSounds(); S_ClearSoundLocks(); - - G_LoadPlayerMaybeMulti(*g_quickload); + if (G_LoadPlayerMaybeMulti(*g_quickload) != 0) + { + g_quickload->reset(); + goto QuickLoadFailure; + } } else if (!(resetFlags & 1)) { @@ -1106,7 +1109,11 @@ static int32_t VM_ResetPlayer(int const playerNum, int32_t vmFlags, int32_t cons Menu_Change(MENU_RESETPLAYER); } } - else g_player[playerNum].ps->gm = MODE_RESTART; + else + { + QuickLoadFailure: + g_player[playerNum].ps->gm = MODE_RESTART; + } #if !defined LUNATIC vmFlags |= VM_NOEXECUTE; #endif diff --git a/source/duke3d/src/menus.cpp b/source/duke3d/src/menus.cpp index d8c1ec53a..f2e7c0d5a 100644 --- a/source/duke3d/src/menus.cpp +++ b/source/duke3d/src/menus.cpp @@ -3469,17 +3469,22 @@ static void Menu_Verify(int32_t input) break; case MENU_RESETPLAYER: - if (input) + switch (input) { + default: KB_FlushKeyboardQueue(); KB_ClearKeysDown(); FX_StopAllSounds(); S_ClearSoundLocks(); - G_LoadPlayerMaybeMulti(*g_quickload); - } - else - { + if (G_LoadPlayerMaybeMulti(*g_quickload) == 0) + break; + + // error state, consider as a no instead of yes + g_quickload->reset(); + + fallthrough__; + case 0: if (sprite[g_player[myconnectindex].ps->i].extra <= 0) { if (G_EnterLevel(MODE_GAME)) G_BackToMenu(); @@ -3487,6 +3492,7 @@ static void Menu_Verify(int32_t input) } Menu_Change(MENU_CLOSE); + break; } break; diff --git a/source/duke3d/src/savegame.cpp b/source/duke3d/src/savegame.cpp index 7c22dd7c2..313c829b8 100644 --- a/source/duke3d/src/savegame.cpp +++ b/source/duke3d/src/savegame.cpp @@ -615,7 +615,7 @@ saveproblem: return -1; } -void G_LoadPlayerMaybeMulti(savebrief_t & sv) +int32_t G_LoadPlayerMaybeMulti(savebrief_t & sv) { if (g_netServer || ud.multimode > 1) { @@ -623,12 +623,14 @@ void G_LoadPlayerMaybeMulti(savebrief_t & sv) P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps); // g_player[myconnectindex].ps->gm = MODE_GAME; + return 127; } else { int32_t c = G_LoadPlayer(sv); if (c == 0) g_player[myconnectindex].ps->gm = MODE_GAME; + return c; } } diff --git a/source/duke3d/src/savegame.h b/source/duke3d/src/savegame.h index 2583c816d..fd7475786 100644 --- a/source/duke3d/src/savegame.h +++ b/source/duke3d/src/savegame.h @@ -123,7 +123,7 @@ int32_t G_LoadPlayer(savebrief_t & sv); int32_t G_LoadSaveHeaderNew(char const *fn, savehead_t *saveh); void ReadSaveGameHeaders(void); void G_SavePlayerMaybeMulti(savebrief_t & sv, bool isAutoSave = false); -void G_LoadPlayerMaybeMulti(savebrief_t & sv); +int32_t G_LoadPlayerMaybeMulti(savebrief_t & sv); #ifdef YAX_ENABLE extern void sv_postyaxload(void);