Further improve Duke3D and RR main game loop.

- Replace if statement containing nested do/while loop with a while loop.
This commit is contained in:
Mitchell Richters 2020-03-27 22:17:01 +11:00 committed by Christoph Oelckers
parent d4dd737cd5
commit 9e8e441d02
2 changed files with 71 additions and 78 deletions

View file

@ -5759,9 +5759,7 @@ MAIN_LOOP_RESTART:
bool gameUpdate = false;
double gameUpdateStartTime = timerGetHiTicks();
if (((g_netClient || g_netServer) || (myplayer.gm & (MODE_MENU|MODE_DEMO)) == 0) && totalclock >= ototalclock+TICSPERFRAME)
{
do
while (((g_netClient || g_netServer) || (myplayer.gm & (MODE_MENU | MODE_DEMO)) == 0) && (int)(totalclock - ototalclock) >= TICSPERFRAME)
{
ototalclock += TICSPERFRAME;
@ -5793,7 +5791,6 @@ MAIN_LOOP_RESTART:
G_DoMoveThings();
}
}
while (((g_netClient || g_netServer) || (myplayer.gm & (MODE_MENU | MODE_DEMO)) == 0) && (int)(totalclock - ototalclock) >= TICSPERFRAME);
gameUpdate = true;
g_gameUpdateTime = timerGetHiTicks() - gameUpdateStartTime;
@ -5803,7 +5800,6 @@ MAIN_LOOP_RESTART:
g_gameUpdateAvgTime
= ((GAMEUPDATEAVGTIMENUMSAMPLES - 1.f) * g_gameUpdateAvgTime + g_gameUpdateTime) / ((float)GAMEUPDATEAVGTIMENUMSAMPLES);
}
G_DoCheats();

View file

@ -7228,9 +7228,8 @@ MAIN_LOOP_RESTART:
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
while (((g_netClient || g_netServer) || !(g_player[myconnectindex].ps->gm & (MODE_MENU|MODE_DEMO))) && (int)(totalclock - ototalclock) >= TICSPERFRAME)
{
ototalclock += TICSPERFRAME;
@ -7263,14 +7262,12 @@ MAIN_LOOP_RESTART:
G_MoveLoop();
}
}
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);
}
G_DoCheats();