mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 23:02:03 +00:00
Partial timer cleanup
After this revision, the only place timerUpdate() is called is from within handleevents(). S_Cleanup(), MUSIC_Update(), and G_HandleSpecialKeys() are now called from a timer callback set with timerSetCallback(). This more or less deprecates the usage of faketimerhandler() in EDuke32 and Mapster32, but other games still rely on the functionality. git-svn-id: https://svn.eduke32.com/eduke32@8139 1a8010ca-5511-0410-912e-c29ae57300e0 # Conflicts: # source/duke3d/src/astub.cpp
This commit is contained in:
parent
593b5740e3
commit
802f69d324
7 changed files with 23 additions and 43 deletions
|
@ -478,7 +478,6 @@ int32_t Anim_Play(const char *fn)
|
|||
gltexapplyprops();
|
||||
#endif
|
||||
|
||||
timerUpdate();
|
||||
ototalclock = totalclock;
|
||||
|
||||
i = 1;
|
||||
|
|
|
@ -184,6 +184,15 @@ enum gametokens
|
|||
T_USERCONTENT,
|
||||
};
|
||||
|
||||
static void gameTimerHandler(void)
|
||||
{
|
||||
S_Cleanup();
|
||||
MUSIC_Update();
|
||||
|
||||
G_HandleSpecialKeys();
|
||||
}
|
||||
|
||||
|
||||
void G_HandleSpecialKeys(void)
|
||||
{
|
||||
auto &myplayer = *g_player[myconnectindex].ps;
|
||||
|
@ -6024,6 +6033,7 @@ static void G_Startup(void)
|
|||
set_memerr_handler(&G_HandleMemErr);
|
||||
|
||||
timerInit(TICRATE);
|
||||
timerSetCallback(gameTimerHandler);
|
||||
|
||||
initcrc32table();
|
||||
|
||||
|
@ -6807,14 +6817,12 @@ MAIN_LOOP_RESTART:
|
|||
|
||||
do //main loop
|
||||
{
|
||||
if (handleevents() && quitevent)
|
||||
if (G_HandleAsync() && quitevent)
|
||||
{
|
||||
KB_KeyDown[sc_Escape] = 1;
|
||||
quitevent = 0;
|
||||
}
|
||||
|
||||
Net_GetPackets();
|
||||
|
||||
// only allow binds to function if the player is actually in a game (not in a menu, typing, et cetera) or demo
|
||||
CONTROL_BindsEnabled = !!(myplayer.gm & (MODE_GAME|MODE_DEMO));
|
||||
|
||||
|
@ -6845,11 +6853,7 @@ MAIN_LOOP_RESTART:
|
|||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
S_Cleanup();
|
||||
MUSIC_Update();
|
||||
G_HandleLocalKeys();
|
||||
}
|
||||
|
||||
OSD_DispatchQueued();
|
||||
|
||||
|
@ -6865,8 +6869,6 @@ MAIN_LOOP_RESTART:
|
|||
|
||||
do
|
||||
{
|
||||
timerUpdate();
|
||||
|
||||
if (ready2send == 0) break;
|
||||
|
||||
ototalclock += TICSPERFRAME;
|
||||
|
@ -6877,6 +6879,8 @@ MAIN_LOOP_RESTART:
|
|||
(myplayer.gm & MODE_GAME))
|
||||
{
|
||||
G_MoveLoop();
|
||||
S_Update();
|
||||
|
||||
#ifdef __ANDROID__
|
||||
inputfifo[0][myconnectindex].fvel = 0;
|
||||
inputfifo[0][myconnectindex].svel = 0;
|
||||
|
@ -6885,8 +6889,6 @@ MAIN_LOOP_RESTART:
|
|||
#endif
|
||||
}
|
||||
|
||||
timerUpdate();
|
||||
|
||||
if (totalclock - moveClock >= TICSPERFRAME)
|
||||
{
|
||||
// computing a tic takes longer than a tic, so we're slowing
|
||||
|
|
|
@ -440,10 +440,10 @@ extern int G_StartRTS(int lumpNum, int localPlayer);
|
|||
|
||||
extern void G_MaybeAllocPlayer(int32_t pnum);
|
||||
|
||||
static inline void G_HandleAsync(void)
|
||||
static inline int32_t G_HandleAsync(void)
|
||||
{
|
||||
handleevents();
|
||||
Net_GetPackets();
|
||||
return handleevents();
|
||||
}
|
||||
|
||||
static inline int32_t calc_smoothratio_demo(ClockTicks totalclk, ClockTicks ototalclk)
|
||||
|
|
|
@ -1222,7 +1222,7 @@ void Screen_Play(void)
|
|||
|
||||
do
|
||||
{
|
||||
G_HandleAsync();
|
||||
gameHandleEvents();
|
||||
|
||||
ototalclock = totalclock + 1; // pause game like ANMs
|
||||
|
||||
|
|
|
@ -65,22 +65,9 @@ int32_t g_networkMode = NET_CLIENT;
|
|||
|
||||
typedef TYPE_PUNNED int32_t NetChunk32;
|
||||
|
||||
void faketimerhandler(void) { ; }
|
||||
|
||||
// Unfortunately faketimerhandler needs extra "help" because the Build Engine source doesn't include network.h.
|
||||
#ifdef NETCODE_DISABLE
|
||||
void faketimerhandler(void)
|
||||
{
|
||||
;
|
||||
}
|
||||
#else
|
||||
void faketimerhandler(void)
|
||||
{
|
||||
if (g_netServer == NULL && g_netClient == NULL)
|
||||
return;
|
||||
|
||||
enet_host_service(g_netServer ? g_netServer : g_netClient, NULL, 0);
|
||||
}
|
||||
|
||||
#ifndef NETCODE_DISABLE
|
||||
static void Net_Disconnect(void);
|
||||
static void Net_HandleClientPackets(void);
|
||||
static void Net_HandleServerPackets(void);
|
||||
|
@ -88,13 +75,10 @@ static void Net_HandleServerPackets(void);
|
|||
|
||||
void Net_GetPackets(void)
|
||||
{
|
||||
timerUpdate();
|
||||
MUSIC_Update();
|
||||
S_Update();
|
||||
|
||||
G_HandleSpecialKeys();
|
||||
|
||||
#ifndef NETCODE_DISABLE
|
||||
if (g_netServer == NULL && g_netClient == NULL)
|
||||
return;
|
||||
|
||||
if (g_netDisconnect)
|
||||
{
|
||||
Net_Disconnect();
|
||||
|
@ -106,14 +90,12 @@ void Net_GetPackets(void)
|
|||
return;
|
||||
}
|
||||
|
||||
enet_host_service(g_netServer ? g_netServer : g_netClient, NULL, 0);
|
||||
|
||||
if (g_netServer)
|
||||
{
|
||||
Net_HandleClientPackets();
|
||||
}
|
||||
else if (g_netClient)
|
||||
{
|
||||
Net_HandleServerPackets();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -481,7 +481,6 @@ void G_CacheMapData(void)
|
|||
{
|
||||
Bsprintf(tempbuf, "Loaded %d%% (%d/%d textures)\n", percentDisplayed, cnt, g_precacheCount);
|
||||
G_DoLoadScreen(tempbuf, percentDisplayed);
|
||||
timerUpdate();
|
||||
|
||||
if (totalclock - clock >= 1)
|
||||
{
|
||||
|
|
|
@ -703,8 +703,6 @@ static void G_SaveTimers(void)
|
|||
|
||||
static void G_RestoreTimers(void)
|
||||
{
|
||||
timerUpdate();
|
||||
|
||||
totalclock = g_timers.totalclock;
|
||||
totalclocklock = g_timers.totalclocklock;
|
||||
ototalclock = g_timers.ototalclock;
|
||||
|
|
Loading…
Reference in a new issue