- 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.
This commit is contained in:
Christoph Oelckers 2020-08-26 16:47:30 +02:00
parent a9f556c1bd
commit b76168f673
9 changed files with 37 additions and 56 deletions

View file

@ -890,19 +890,15 @@ static void commonTicker()
void GameInterface::RunGameFrame() void GameInterface::RunGameFrame()
{ {
if (gamestate == GS_STARTUP) gameInit();
commonTicker(); commonTicker();
netGetPackets(); netGetPackets();
handleevents();
updatePauseStatus();
D_ProcessEvents();
ctrlGetInput(); ctrlGetInput();
switch (gamestate) switch (gamestate)
{ {
default: default:
case GS_STARTUP: case GS_STARTUP:
gameInit();
if (userConfig.CommandMap.IsNotEmpty()) if (userConfig.CommandMap.IsNotEmpty())
{ {
} }

View file

@ -905,6 +905,31 @@ void TickSubsystems()
if (cnt == 5) nexttick = nowtick + tickInterval; 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() void app_loop()
{ {
gamestate = GS_STARTUP; gamestate = GS_STARTUP;
@ -918,6 +943,10 @@ void app_loop()
twodpsp.SetSize(screen->GetWidth(), screen->GetHeight()); twodpsp.SetSize(screen->GetWidth(), screen->GetHeight());
I_SetFrameTime(); I_SetFrameTime();
handleevents();
updatePauseStatus();
D_ProcessEvents();
gi->RunGameFrame(); gi->RunGameFrame();
// Draw overlay elements to the 2D drawer // Draw overlay elements to the 2D drawer
@ -1182,30 +1211,6 @@ bool CheckCheatmode(bool printmsg)
return gi->CheatAllowed(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) bool OkForLocalization(FTextureID texnum, const char* substitute)
{ {
return false; return false;

View file

@ -205,8 +205,6 @@ enum
PAUSESFX_CONSOLE = 2 PAUSESFX_CONSOLE = 2
}; };
void updatePauseStatus();
void updatePauseStatus(bool state, bool multiplayer);
extern int paused; extern int paused;
extern int chatmodeon; extern int chatmodeon;

View file

@ -201,12 +201,6 @@ void ShutDown(void)
//UnInitFX(); //UnInitFX();
} }
void HandleAsync()
{
handleevents();
}
static bool HollyCheat(cheatseq_t* c) static bool HollyCheat(cheatseq_t* c)
{ {
// Do the closest thing to this cheat that's available. // Do the closest thing to this cheat that's available.

View file

@ -76,10 +76,6 @@ enum GameFunction_t
#define kTimerTicks 120 #define kTimerTicks 120
#ifdef __WATCOMC__
void handleevents();
#endif
enum basepal_t { enum basepal_t {
BASEPAL = 0, BASEPAL = 0,
ANIMPAL, ANIMPAL,
@ -127,7 +123,6 @@ void StatusMessage(int messageTime, const char *fmt, ...);
int DoSpiritHead(); int DoSpiritHead();
void HandleAsync();
void CheckKeys(); void CheckKeys();
void CheckKeys2(); void CheckKeys2();
void GameTicker(); void GameTicker();

View file

@ -45,6 +45,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "c_console.h" #include "c_console.h"
#include "cheathandler.h" #include "cheathandler.h"
#include "statistics.h" #include "statistics.h"
#include "g_input.h"
#include "core/menu/menu.h" #include "core/menu/menu.h"
BEGIN_PS_NS BEGIN_PS_NS
@ -83,7 +84,11 @@ static int FinishLevel(TArray<JobDesc> &jobs)
// There's really no choice but to enter an active wait loop here to make the sound play out. // 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); PlayLocalSound(StaticSound[59], 0, true, CHANF_UI);
int nTicks = gameclock + 12; int nTicks = gameclock + 12;
while (nTicks > gameclock) { HandleAsync(); } while (nTicks > gameclock)
{
I_GetEvent();
soundEngine->UpdateSounds(I_GetTime());
}
} }
} }
else nPlayerLives[0] = 0; else nPlayerLives[0] = 0;
@ -263,9 +268,6 @@ void GameInterface::RunGameFrame()
again: again:
try try
{ {
HandleAsync();
updatePauseStatus();
D_ProcessEvents();
CheckProgression(); CheckProgression();
switch (gamestate) switch (gamestate)
{ {

View file

@ -159,9 +159,7 @@ void PlayerInterruptKeys()
if (paused) if (paused)
return; return;
D_ProcessEvents(); localInput = {};
localInput = {};
PlayerInput input {}; PlayerInput input {};
if (PlayerList[nLocalPlayer].nHealth == 0) if (PlayerList[nLocalPlayer].nHealth == 0)

View file

@ -399,9 +399,6 @@ void startmainmenu()
void GameInterface::RunGameFrame() void GameInterface::RunGameFrame()
{ {
handleevents();
updatePauseStatus();
D_ProcessEvents();
switch (gamestate) switch (gamestate)
{ {
default: default:

View file

@ -812,10 +812,6 @@ void GameInterface::RunGameFrame()
{ {
// if the menu initiazed a new game or loaded a savegame, switch to play mode. // if the menu initiazed a new game or loaded a savegame, switch to play mode.
if (SavegameLoaded || NextLevel) gamestate = GS_LEVEL; if (SavegameLoaded || NextLevel) gamestate = GS_LEVEL;
handleevents();
updatePauseStatus();
D_ProcessEvents();
DoUpdateSounds(); DoUpdateSounds();
switch (gamestate) switch (gamestate)
{ {