diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index 8c644ea20..a3a3bb6c6 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -3336,10 +3336,46 @@ void ConKey(void) #endif } -void FunctionKeys(PLAYERp pp) +char WangBangMacro[10][64]; + +SWBOOL DoQuickSave(short save_num) +{ + PauseAction(); + + if (SaveGame(save_num) != -1) + { + QuickLoadNum = save_num; + + LastSaveNum = -1; + + return FALSE; + } + + return TRUE; +} + +SWBOOL DoQuickLoad() +{ + KB_ClearKeysDown(); + + PauseAction(); + + ReloadPrompt = FALSE; + if (LoadGame(QuickLoadNum) == -1) + { + return FALSE; + } + + ready2send = 1; + LastSaveNum = -1; + + return TRUE; +} + +void +FunctionKeys(PLAYERp pp) { extern SWBOOL GamePaused; - extern short QuickLoadNum; static int rts_delay = 0; int fn_key = 0; @@ -3433,16 +3469,25 @@ void FunctionKeys(PLAYERp pp) } } - // F6 option menu + // F6 quick save if (inputState.GetKeyStatus(KEYSC_F6)) { - extern SWBOOL QuickSaveMode; inputState.ClearKeyStatus(KEYSC_F6); if (!TEST(pp->Flags, PF_DEAD)) { inputState.SetKeyStatus(sc_Escape); - ControlPanelType = ct_savemenu; - QuickSaveMode = TRUE; + if (QuickLoadNum < 0) + { + KEY_PRESSED(KEYSC_ESC) = 1; + ControlPanelType = ct_savemenu; + } + else + { + KB_ClearKeysDown(); + KB_FlushKeyboardQueue(); + DoQuickSave(QuickLoadNum); + ResumeAction(); + } } } @@ -3455,17 +3500,16 @@ void FunctionKeys(PLAYERp pp) { if (QuickLoadNum < 0) { - PutStringInfoLine(pp, "Last saved game not found."); + KEY_PRESSED(KEYSC_ESC) = 1; + ControlPanelType = ct_loadmenu; } else { - inputState.ClearKeysDown(); - inputState.SetKeyStatus(sc_Escape); - ControlPanelType = ct_quickloadmenu; + DoQuickLoad(); + ResumeAction(); } } } - } @@ -3535,7 +3579,6 @@ void FunctionKeys(PLAYERp pp) void PauseKey(PLAYERp pp) { extern SWBOOL GamePaused,CheatInputMode; - extern short QuickLoadNum; extern SWBOOL enabled; if (inputState.GetKeyStatus(sc_Pause) && !CommEnabled && !InputMode && !UsingMenus && !CheatInputMode && !ConPanel) diff --git a/source/sw/src/game.h b/source/sw/src/game.h index ecdb085c5..5aa48874b 100644 --- a/source/sw/src/game.h +++ b/source/sw/src/game.h @@ -2372,6 +2372,12 @@ int COVERinsertsprite(short sectnum, short statnum); //returns (short)spritenu void AudioUpdate(void); // stupid +extern short LastSaveNum; +extern short QuickLoadNum; +void LoadSaveMsg(const char *msg); +SWBOOL DoQuickSave(short save_num); +SWBOOL DoQuickLoad(void); + struct GameInterface : ::GameInterface { int app_main() override; diff --git a/source/sw/src/menus.cpp b/source/sw/src/menus.cpp index 933dd75d5..88aa9973d 100644 --- a/source/sw/src/menus.cpp +++ b/source/sw/src/menus.cpp @@ -68,7 +68,6 @@ short TimeLimitTable[9] = {0,3,5,10,15,20,30,45,60}; short QuickLoadNum = -1; char QuickLoadDescrDialog[128]; -SWBOOL QuickSaveMode = FALSE; SWBOOL SavePrompt = FALSE; extern SWBOOL InMenuLevel, LoadGameOutsideMoveLoop, LoadGameFromDemo; extern uint8_t RedBookSong[40]; @@ -570,7 +569,6 @@ MenuItem_p cust_callback_item; static void MNU_ClearDialog(void); static SWBOOL MNU_Dialog(void); -void LoadSaveMsg(const char *msg); static void MNU_ItemPreProcess(MenuGroup *group); static void MNU_SelectItem(MenuGroup *group, short index, SWBOOL draw); static void MNU_PushItem(MenuItem *item, SWBOOL draw); @@ -1796,24 +1794,17 @@ MNU_QuickLoadCustom(UserCall call, MenuItem_p item) // Y pressed cust_callback = NULL; - inputState.ClearKeysDown(); LoadSaveMsg("Loading..."); - PauseAction(); - - ReloadPrompt = FALSE; - if (LoadGame(QuickLoadNum) == -1) + if (DoQuickLoad() == FALSE) { ResumeAction(); return FALSE; } - ready2send = 1; - LastSaveNum = -1; - - // do a load game here - inputState.ClearKeysDown(); ExitMenus(); + + return TRUE; } inputState.ClearKeysDown(); @@ -2429,16 +2420,11 @@ SWBOOL MNU_GetSaveCustom(void) if (MenuInputMode) { - PauseAction(); - LoadSaveMsg("Saving..."); - if (SaveGame(save_num) != -1) + if (DoQuickSave(save_num) == FALSE) { - QuickLoadNum = save_num; - LoadGameGroup.cursor = save_num; - LastSaveNum = -1; } ResumeAction(); @@ -2523,15 +2509,6 @@ SWBOOL MNU_LoadSaveMove(UserCall call, MenuItem_p item) SaveGameInfo2[0] = 0; } - if (QuickSaveMode) - { - QuickSaveMode = FALSE; - MenuInputMode = TRUE; - strcpy(BackupSaveGameDescr, SaveGameDescr[game_num]); - inputState.ClearKeysDown(); - inputState.keyFlushChars(); - } - LastSaveNum = game_num; // input mode check