From f2dd7326d0b44e20346c14da9b9b58e0a57f8936 Mon Sep 17 00:00:00 2001 From: nukeykt Date: Fri, 13 Dec 2019 17:58:36 +0900 Subject: [PATCH] Backport changes related to timing from mainline # Conflicts: # source/rr/src/game.cpp --- source/rr/src/game.cpp | 20 ++++++++++++++++++-- source/rr/src/net.cpp | 4 ---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/source/rr/src/game.cpp b/source/rr/src/game.cpp index d7b1a3336..41b3f104d 100644 --- a/source/rr/src/game.cpp +++ b/source/rr/src/game.cpp @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------- +//------------------------------------------------------------------------- /* Copyright (C) 2016 EDuke32 developers and contributors @@ -160,6 +160,14 @@ enum gametokens T_TEXTUREFILTER, }; +static void gameTimerHandler(void) +{ + S_Cleanup(); + MUSIC_Update(); + + G_HandleSpecialKeys(); +} + void G_HandleSpecialKeys(void) { // 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); timerInit(TICRATE); + timerSetCallback(gameTimerHandler); G_CompileScripts(); @@ -7611,6 +7620,7 @@ MAIN_LOOP_RESTART: OSD_DispatchQueued(); + static bool frameJustDrawn; char gameUpdate = false; double const gameUpdateStartTime = timerGetHiTicks(); 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)); - S_Update(); + if (!frameJustDrawn) + break; + + frameJustDrawn = false; do { @@ -7642,6 +7655,7 @@ MAIN_LOOP_RESTART: (g_player[myconnectindex].ps->gm&MODE_GAME)) { G_MoveLoop(); + S_Update(); } if (totalclock - moveClock >= TICSPERFRAME) @@ -7690,6 +7704,8 @@ MAIN_LOOP_RESTART: { g_gameUpdateAndDrawTime = g_beforeSwapTime/* timerGetHiTicks()*/ - gameUpdateStartTime; } + + frameJustDrawn = true; } if (g_player[myconnectindex].ps->gm&MODE_DEMO) diff --git a/source/rr/src/net.cpp b/source/rr/src/net.cpp index 993283e75..9d5838e43 100644 --- a/source/rr/src/net.cpp +++ b/source/rr/src/net.cpp @@ -2531,10 +2531,6 @@ void Net_ReceiveDisconnect(ENetEvent *event) void Net_GetPackets(void) { - MUSIC_Update(); - - G_HandleSpecialKeys(); - if (g_netDisconnect) { Net_Disconnect();