From b76168f673eb1a6a84ceee52c78234aaceb090e3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 26 Aug 2020 16:47:30 +0200 Subject: [PATCH] - moved the main event processing functions into the global main loop. Now, with all the Build timer stuff removed these calls were all identical between games. --- source/blood/src/blood.cpp | 6 +--- source/core/gamecontrol.cpp | 53 ++++++++++++++++-------------- source/core/gamecontrol.h | 2 -- source/exhumed/src/exhumed.cpp | 6 ---- source/exhumed/src/exhumed.h | 5 --- source/exhumed/src/gameloop.cpp | 10 +++--- source/exhumed/src/player.cpp | 4 +-- source/games/duke/src/gameloop.cpp | 3 -- source/sw/src/game.cpp | 4 --- 9 files changed, 37 insertions(+), 56 deletions(-) diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp index 6c73577e4..160076986 100644 --- a/source/blood/src/blood.cpp +++ b/source/blood/src/blood.cpp @@ -890,19 +890,15 @@ static void commonTicker() void GameInterface::RunGameFrame() { - if (gamestate == GS_STARTUP) gameInit(); - commonTicker(); netGetPackets(); - handleevents(); - updatePauseStatus(); - D_ProcessEvents(); ctrlGetInput(); switch (gamestate) { default: case GS_STARTUP: + gameInit(); if (userConfig.CommandMap.IsNotEmpty()) { } diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index d2629ed37..2f53733b4 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -905,6 +905,31 @@ void TickSubsystems() if (cnt == 5) nexttick = nowtick + tickInterval; } +static void updatePauseStatus() +{ + if (M_Active() || System_WantGuiCapture()) + { + paused = 1; + } + else if (!M_Active() || !System_WantGuiCapture()) + { + if (!pausedWithKey) + { + paused = 0; + } + + if (sendPause) + { + sendPause = false; + paused = pausedWithKey ? 0 : 2; + pausedWithKey = !!paused; + } + } + + paused ? S_PauseSound(!pausedWithKey, !paused) : S_ResumeSound(paused); +} + + void app_loop() { gamestate = GS_STARTUP; @@ -918,6 +943,10 @@ void app_loop() twodpsp.SetSize(screen->GetWidth(), screen->GetHeight()); I_SetFrameTime(); + handleevents(); + updatePauseStatus(); + D_ProcessEvents(); + gi->RunGameFrame(); // Draw overlay elements to the 2D drawer @@ -1182,30 +1211,6 @@ bool CheckCheatmode(bool printmsg) return gi->CheatAllowed(printmsg); } -void updatePauseStatus() -{ - if (M_Active() || System_WantGuiCapture()) - { - paused = 1; - } - else if (!M_Active() || !System_WantGuiCapture()) - { - if (!pausedWithKey) - { - paused = 0; - } - - if (sendPause) - { - sendPause = false; - paused = pausedWithKey ? 0 : 2; - pausedWithKey = !!paused; - } - } - - paused ? S_PauseSound(!pausedWithKey, !paused) : S_ResumeSound(paused); -} - bool OkForLocalization(FTextureID texnum, const char* substitute) { return false; diff --git a/source/core/gamecontrol.h b/source/core/gamecontrol.h index fa5628fb9..9f1a173b0 100644 --- a/source/core/gamecontrol.h +++ b/source/core/gamecontrol.h @@ -205,8 +205,6 @@ enum PAUSESFX_CONSOLE = 2 }; -void updatePauseStatus(); -void updatePauseStatus(bool state, bool multiplayer); extern int paused; extern int chatmodeon; diff --git a/source/exhumed/src/exhumed.cpp b/source/exhumed/src/exhumed.cpp index 8402c6318..a85fe2624 100644 --- a/source/exhumed/src/exhumed.cpp +++ b/source/exhumed/src/exhumed.cpp @@ -201,12 +201,6 @@ void ShutDown(void) //UnInitFX(); } -void HandleAsync() -{ - handleevents(); - -} - static bool HollyCheat(cheatseq_t* c) { // Do the closest thing to this cheat that's available. diff --git a/source/exhumed/src/exhumed.h b/source/exhumed/src/exhumed.h index 37599599c..960616354 100644 --- a/source/exhumed/src/exhumed.h +++ b/source/exhumed/src/exhumed.h @@ -76,10 +76,6 @@ enum GameFunction_t #define kTimerTicks 120 -#ifdef __WATCOMC__ -void handleevents(); -#endif - enum basepal_t { BASEPAL = 0, ANIMPAL, @@ -127,7 +123,6 @@ void StatusMessage(int messageTime, const char *fmt, ...); int DoSpiritHead(); -void HandleAsync(); void CheckKeys(); void CheckKeys2(); void GameTicker(); diff --git a/source/exhumed/src/gameloop.cpp b/source/exhumed/src/gameloop.cpp index 81166fd51..39645f801 100644 --- a/source/exhumed/src/gameloop.cpp +++ b/source/exhumed/src/gameloop.cpp @@ -45,6 +45,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "c_console.h" #include "cheathandler.h" #include "statistics.h" +#include "g_input.h" #include "core/menu/menu.h" BEGIN_PS_NS @@ -83,7 +84,11 @@ static int FinishLevel(TArray &jobs) // There's really no choice but to enter an active wait loop here to make the sound play out. PlayLocalSound(StaticSound[59], 0, true, CHANF_UI); int nTicks = gameclock + 12; - while (nTicks > gameclock) { HandleAsync(); } + while (nTicks > gameclock) + { + I_GetEvent(); + soundEngine->UpdateSounds(I_GetTime()); + } } } else nPlayerLives[0] = 0; @@ -263,9 +268,6 @@ void GameInterface::RunGameFrame() again: try { - HandleAsync(); - updatePauseStatus(); - D_ProcessEvents(); CheckProgression(); switch (gamestate) { diff --git a/source/exhumed/src/player.cpp b/source/exhumed/src/player.cpp index 35e384bfa..169be9d4c 100644 --- a/source/exhumed/src/player.cpp +++ b/source/exhumed/src/player.cpp @@ -159,9 +159,7 @@ void PlayerInterruptKeys() if (paused) return; - D_ProcessEvents(); - - localInput = {}; + localInput = {}; PlayerInput input {}; if (PlayerList[nLocalPlayer].nHealth == 0) diff --git a/source/games/duke/src/gameloop.cpp b/source/games/duke/src/gameloop.cpp index 3da8eca7d..2ce8b3612 100644 --- a/source/games/duke/src/gameloop.cpp +++ b/source/games/duke/src/gameloop.cpp @@ -399,9 +399,6 @@ void startmainmenu() void GameInterface::RunGameFrame() { - handleevents(); - updatePauseStatus(); - D_ProcessEvents(); switch (gamestate) { default: diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index b0a233227..b1d5a9c84 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -812,10 +812,6 @@ void GameInterface::RunGameFrame() { // if the menu initiazed a new game or loaded a savegame, switch to play mode. if (SavegameLoaded || NextLevel) gamestate = GS_LEVEL; - - handleevents(); - updatePauseStatus(); - D_ProcessEvents(); DoUpdateSounds(); switch (gamestate) {