Backport changes related to timing from mainline

# Conflicts:
#	source/rr/src/game.cpp
This commit is contained in:
nukeykt 2019-12-13 17:58:36 +09:00 committed by Christoph Oelckers
parent bff0646263
commit f2dd7326d0
2 changed files with 18 additions and 6 deletions

View file

@ -1,4 +1,4 @@
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
/* /*
Copyright (C) 2016 EDuke32 developers and contributors Copyright (C) 2016 EDuke32 developers and contributors
@ -160,6 +160,14 @@ enum gametokens
T_TEXTUREFILTER, T_TEXTUREFILTER,
}; };
static void gameTimerHandler(void)
{
S_Cleanup();
MUSIC_Update();
G_HandleSpecialKeys();
}
void G_HandleSpecialKeys(void) void G_HandleSpecialKeys(void)
{ {
// we need CONTROL_GetInput in order to pick up joystick button presses // we need CONTROL_GetInput in order to pick up joystick button presses
@ -7076,6 +7084,7 @@ static void G_Startup(void)
set_memerr_handler(&G_HandleMemErr); set_memerr_handler(&G_HandleMemErr);
timerInit(TICRATE); timerInit(TICRATE);
timerSetCallback(gameTimerHandler);
G_CompileScripts(); G_CompileScripts();
@ -7611,6 +7620,7 @@ MAIN_LOOP_RESTART:
OSD_DispatchQueued(); OSD_DispatchQueued();
static bool frameJustDrawn;
char gameUpdate = false; char gameUpdate = false;
double const gameUpdateStartTime = timerGetHiTicks(); double const gameUpdateStartTime = timerGetHiTicks();
if (((g_netClient || g_netServer) || !(g_player[myconnectindex].ps->gm & (MODE_MENU|MODE_DEMO))) && totalclock >= ototalclock+TICSPERFRAME) if (((g_netClient || g_netServer) || !(g_player[myconnectindex].ps->gm & (MODE_MENU|MODE_DEMO))) && totalclock >= ototalclock+TICSPERFRAME)
@ -7627,7 +7637,10 @@ MAIN_LOOP_RESTART:
//Bmemcpy(&inputfifo[0][myconnectindex], &localInput, sizeof(input_t)); //Bmemcpy(&inputfifo[0][myconnectindex], &localInput, sizeof(input_t));
S_Update(); if (!frameJustDrawn)
break;
frameJustDrawn = false;
do do
{ {
@ -7642,6 +7655,7 @@ MAIN_LOOP_RESTART:
(g_player[myconnectindex].ps->gm&MODE_GAME)) (g_player[myconnectindex].ps->gm&MODE_GAME))
{ {
G_MoveLoop(); G_MoveLoop();
S_Update();
} }
if (totalclock - moveClock >= TICSPERFRAME) if (totalclock - moveClock >= TICSPERFRAME)
@ -7690,6 +7704,8 @@ MAIN_LOOP_RESTART:
{ {
g_gameUpdateAndDrawTime = g_beforeSwapTime/* timerGetHiTicks()*/ - gameUpdateStartTime; g_gameUpdateAndDrawTime = g_beforeSwapTime/* timerGetHiTicks()*/ - gameUpdateStartTime;
} }
frameJustDrawn = true;
} }
if (g_player[myconnectindex].ps->gm&MODE_DEMO) if (g_player[myconnectindex].ps->gm&MODE_DEMO)

View file

@ -2531,10 +2531,6 @@ void Net_ReceiveDisconnect(ENetEvent *event)
void Net_GetPackets(void) void Net_GetPackets(void)
{ {
MUSIC_Update();
G_HandleSpecialKeys();
if (g_netDisconnect) if (g_netDisconnect)
{ {
Net_Disconnect(); Net_Disconnect();