mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 23:02:03 +00:00
Remove last vestiges of input latency from Duke3D and RR main game loops.
- Hack code to break loop early removed. If game code is running slow, that's not the fix. - Get input and fill the input_t struct in same loop as G_DoMoveThings(). - Remove unnecessary do/while (0) loop.
This commit is contained in:
parent
1a2663f7ac
commit
2cbbe9ec61
2 changed files with 45 additions and 94 deletions
|
@ -5906,22 +5906,14 @@ MAIN_LOOP_RESTART:
|
|||
|
||||
OSD_DispatchQueued();
|
||||
|
||||
static bool frameJustDrawn;
|
||||
bool gameUpdate = false;
|
||||
double gameUpdateStartTime = timerGetHiTicks();
|
||||
|
||||
auto beforeMoveClock = ototalclock;
|
||||
|
||||
if (((g_netClient || g_netServer) || (myplayer.gm & (MODE_MENU|MODE_DEMO)) == 0) && totalclock >= ototalclock+TICSPERFRAME)
|
||||
{
|
||||
do
|
||||
{
|
||||
if (g_networkMode != NET_DEDICATED_SERVER)
|
||||
{
|
||||
if (!frameJustDrawn)
|
||||
break;
|
||||
|
||||
frameJustDrawn = false;
|
||||
ototalclock += TICSPERFRAME;
|
||||
|
||||
P_GetInput(myconnectindex);
|
||||
|
||||
|
@ -5943,16 +5935,6 @@ MAIN_LOOP_RESTART:
|
|||
}
|
||||
|
||||
localInput = {};
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if (ready2send == 0)
|
||||
break;
|
||||
|
||||
ototalclock += TICSPERFRAME;
|
||||
|
||||
auto const moveClock = totalclock;
|
||||
|
||||
if (((!GUICapture && (myplayer.gm & MODE_MENU) != MODE_MENU) || ud.recstat == 2 || (g_netServer || ud.multimode > 1))
|
||||
&& (myplayer.gm & MODE_GAME))
|
||||
|
@ -5960,11 +5942,6 @@ MAIN_LOOP_RESTART:
|
|||
Net_GetPackets();
|
||||
G_DoMoveThings();
|
||||
}
|
||||
|
||||
// computing a tic is taking too long.
|
||||
// rather than tightly spinning here, go draw a frame since we're fucked anyway
|
||||
if ((int)(totalclock - moveClock) >= (TICSPERFRAME >> 1))
|
||||
break;
|
||||
}
|
||||
while (((g_netClient || g_netServer) || (myplayer.gm & (MODE_MENU | MODE_DEMO)) == 0) && (int)(totalclock - ototalclock) >= TICSPERFRAME);
|
||||
|
||||
|
@ -5976,7 +5953,6 @@ MAIN_LOOP_RESTART:
|
|||
|
||||
g_gameUpdateAvgTime
|
||||
= ((GAMEUPDATEAVGTIMENUMSAMPLES - 1.f) * g_gameUpdateAvgTime + g_gameUpdateTime) / ((float)GAMEUPDATEAVGTIMENUMSAMPLES);
|
||||
} while (0);
|
||||
}
|
||||
|
||||
G_DoCheats();
|
||||
|
@ -6011,8 +5987,6 @@ MAIN_LOOP_RESTART:
|
|||
|
||||
if (gameUpdate)
|
||||
g_gameUpdateAndDrawTime = g_beforeSwapTime/* timerGetHiTicks()*/ - gameUpdateStartTime;
|
||||
|
||||
frameJustDrawn = true;
|
||||
}
|
||||
|
||||
// handle CON_SAVE and CON_SAVENN
|
||||
|
|
|
@ -7411,17 +7411,13 @@ 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)
|
||||
{
|
||||
do
|
||||
{
|
||||
if (!frameJustDrawn)
|
||||
break;
|
||||
|
||||
frameJustDrawn = false;
|
||||
ototalclock += TICSPERFRAME;
|
||||
|
||||
if (RRRA && g_player[myconnectindex].ps->on_motorcycle)
|
||||
P_GetInputMotorcycle(myconnectindex);
|
||||
|
@ -7446,36 +7442,19 @@ MAIN_LOOP_RESTART:
|
|||
|
||||
g_player[myconnectindex].movefifoend++;
|
||||
|
||||
do
|
||||
{
|
||||
if (ready2send == 0) break;
|
||||
|
||||
ototalclock += TICSPERFRAME;
|
||||
|
||||
int const moveClock = (int) totalclock;
|
||||
|
||||
if (((!GUICapture && (g_player[myconnectindex].ps->gm&MODE_MENU) != MODE_MENU) || ud.recstat == 2 || (g_netServer || ud.multimode > 1)) &&
|
||||
(g_player[myconnectindex].ps->gm&MODE_GAME))
|
||||
{
|
||||
G_MoveLoop();
|
||||
}
|
||||
|
||||
if (totalclock - moveClock >= TICSPERFRAME)
|
||||
{
|
||||
// computing a tic takes longer than a tic, so we're slowing
|
||||
// the game down. rather than tightly spinning here, go draw
|
||||
// a frame since we're fucked anyway
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (((g_netClient || g_netServer) || !(g_player[myconnectindex].ps->gm & (MODE_MENU|MODE_DEMO))) && totalclock >= ototalclock+TICSPERFRAME);
|
||||
while (((g_netClient || g_netServer) || !(g_player[myconnectindex].ps->gm & (MODE_MENU|MODE_DEMO))) && (int)(totalclock - ototalclock) >= TICSPERFRAME);
|
||||
|
||||
gameUpdate = true;
|
||||
g_gameUpdateTime = timerGetHiTicks()-gameUpdateStartTime;
|
||||
if (g_gameUpdateAvgTime < 0.f)
|
||||
g_gameUpdateAvgTime = g_gameUpdateTime;
|
||||
g_gameUpdateAvgTime = ((GAMEUPDATEAVGTIMENUMSAMPLES-1.f)*g_gameUpdateAvgTime+g_gameUpdateTime)/((float) GAMEUPDATEAVGTIMENUMSAMPLES);
|
||||
} while(0);
|
||||
}
|
||||
|
||||
G_DoCheats();
|
||||
|
@ -7515,8 +7494,6 @@ MAIN_LOOP_RESTART:
|
|||
g_gameUpdateAndDrawTime = g_beforeSwapTime/* timerGetHiTicks()*/ - gameUpdateStartTime;
|
||||
}
|
||||
|
||||
frameJustDrawn = true;
|
||||
|
||||
if (DEER)
|
||||
sub_5A02C();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue