- do not call handleEvents outside the main loop.

In other places I_GetEvent should be used to call the system's message pump and keep the app responsive, but all game side processing should be skipped.
This commit is contained in:
Christoph Oelckers 2020-08-16 09:46:37 +02:00
parent fbdc6c7a6c
commit 7bb6b6a1ee
9 changed files with 26 additions and 40 deletions

View file

@ -29,6 +29,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "baselayer.h"
#include "common.h"
#include "common_game.h"
#include "g_input.h"
#include "db.h"
#include "blood.h"
@ -315,7 +316,7 @@ void PreloadTiles(void)
fxPrecache();
gibPrecache();
gameHandleEvents();
I_GetEvent();
}
void PreloadCache(void)
@ -336,8 +337,7 @@ void PreloadCache(void)
if (r_precache) PrecacheHardwareTextures(i);
if ((++cnt & 7) == 0)
gameHandleEvents();
I_GetEvent();
}
}
memset(gotpic,0,sizeof(gotpic));
@ -621,13 +621,13 @@ void ProcessFrame(void)
sfxUpdate3DSounds();
if (gMe->hand == 1)
{
#define CHOKERATE 8
#define TICRATE 30
const int CHOKERATE = 8;
const int COUNTRATE = 30;
gChokeCounter += CHOKERATE;
while (gChokeCounter >= TICRATE)
while (gChokeCounter >= COUNTRATE)
{
gChoke.at1c(gMe);
gChokeCounter -= TICRATE;
gChokeCounter -= COUNTRATE;
}
}
gLevelTime++;
@ -636,14 +636,17 @@ void ProcessFrame(void)
if ((gGameOptions.uGameFlags&1) != 0 && !gStartNewGame)
{
ready2send = 0;
#if 0
if (gNetPlayers > 1 && gNetMode == NETWORK_SERVER && gPacketMode == PACKETMODE_1 && myconnectindex == connecthead)
{
while (gNetFifoMasterTail < gNetFifoTail)
{
gameHandleEvents();
netGetPackets();
h andleevents();
netMasterUpdate();
}
}
#endif
seqKillAll();
if (gGameOptions.uGameFlags&2)
{
@ -932,7 +935,8 @@ int GameInterface::app_main()
if (gamestate == GS_STARTUP) gameInit();
commonTicker(playvideo);
gameHandleEvents();
netGetPackets();
handleevents();
updatePauseStatus();
D_ProcessEvents();
ctrlGetInput();

View file

@ -485,12 +485,6 @@ extern void G_ExtInit(void);
extern void G_SetupGlobalPsky(void);
static inline int gameHandleEvents(void)
{
netGetPackets();
return handleevents();
}
#pragma pack(push,1)
#if 0

View file

@ -6,4 +6,4 @@ void I_PutInClipboard (const char *str);
FString I_GetFromClipboard (bool use_primary_selection);
void I_SetMouseCapture();
void I_ReleaseMouseCapture();
void I_GetEvent();

View file

@ -526,7 +526,6 @@ public:
if (completion) completion(false);
return false;
}
handleevents();
if (actionState == State_Clear)
{
actionState = State_Run;

View file

@ -28,6 +28,7 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
#include "ns.h" // Must come before everything else!
#include "g_input.h"
#include "duke3d.h"
#include "superfasthash.h"
@ -292,7 +293,7 @@ void GameInterface::StartGame(FNewGameStartup& gs)
while (S_CheckSoundPlaying(skillsound))
{
S_Update();
handleevents();
I_GetEvent();
}
}
ud.m_respawn_monsters = (gs.Skill == 3);

View file

@ -841,7 +841,6 @@ void donewgame(MapRecord* map, int sk)
template<class func>
void newgame(MapRecord* map, int sk, func completion)
{
handleevents();
ready2send = 0;
auto completion1 = [=](bool res)

View file

@ -36,6 +36,7 @@ source as it is released.
#include "ns.h" // Must come before everything else!
#include "compat.h"
#include "g_input.h"
#include "duke3d.h"
#include "raze_music.h"
@ -103,7 +104,7 @@ void S_CacheAllSounds(void)
{
soundEngine->CacheSound(&snd);
if (((++i)&31) == 0)
handleevents();
I_GetEvent();
}
}

View file

@ -21,6 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "ns.h" // Must come before everything else!
#include "build.h"
#include "g_input.h"
#include "names2.h"
#include "panel.h"
@ -221,7 +222,7 @@ void GameInterface::StartGame(FNewGameStartup& gs)
while (soundEngine->IsSourcePlayingSomething(SOURCE_None, nullptr, CHAN_VOICE))
{
DoUpdateSounds();
handleevents();
I_GetEvent();
}
}

View file

@ -412,21 +412,8 @@ bool InitGame()
InitPalette();
// sets numplayers, connecthead, connectpoint2, myconnectindex
#if 0
if (!firstnet)
initmultiplayers(0, NULL, 0, 0, 0);
else if (initmultiplayersparms(argc - firstnet, &argv[firstnet]))
{
Printf("Waiting for players...\n");
while (initmultiplayerscycle())
{
handleevents();
}
}
#else
numplayers = 1; myconnectindex = 0;
connecthead = 0; connectpoint2[0] = -1;
#endif
initsynccrc();
// code to duplicate packets