mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 10:40:46 +00:00
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:
parent
d4dd737cd5
commit
9e8e441d02
2 changed files with 71 additions and 78 deletions
|
@ -5759,52 +5759,48 @@ MAIN_LOOP_RESTART:
|
||||||
bool gameUpdate = false;
|
bool gameUpdate = false;
|
||||||
double gameUpdateStartTime = timerGetHiTicks();
|
double gameUpdateStartTime = timerGetHiTicks();
|
||||||
|
|
||||||
if (((g_netClient || g_netServer) || (myplayer.gm & (MODE_MENU|MODE_DEMO)) == 0) && totalclock >= ototalclock+TICSPERFRAME)
|
while (((g_netClient || g_netServer) || (myplayer.gm & (MODE_MENU | MODE_DEMO)) == 0) && (int)(totalclock - ototalclock) >= TICSPERFRAME)
|
||||||
{
|
{
|
||||||
do
|
ototalclock += TICSPERFRAME;
|
||||||
|
|
||||||
|
P_GetInput(myconnectindex);
|
||||||
|
|
||||||
|
// this is where we fill the input_t struct that is actually processed by P_ProcessInput()
|
||||||
|
auto const pPlayer = g_player[myconnectindex].ps;
|
||||||
|
auto const q16ang = fix16_to_int(pPlayer->q16ang);
|
||||||
|
auto & input = inputfifo[0][myconnectindex];
|
||||||
|
|
||||||
|
input = localInput;
|
||||||
|
input.fvel = mulscale9(localInput.fvel, sintable[(q16ang + 2560) & 2047]) +
|
||||||
|
mulscale9(localInput.svel, sintable[(q16ang + 2048) & 2047]);
|
||||||
|
input.svel = mulscale9(localInput.fvel, sintable[(q16ang + 2048) & 2047]) +
|
||||||
|
mulscale9(localInput.svel, sintable[(q16ang + 1536) & 2047]);
|
||||||
|
|
||||||
|
if (!FURY)
|
||||||
{
|
{
|
||||||
ototalclock += TICSPERFRAME;
|
input.fvel += pPlayer->fric.x;
|
||||||
|
input.svel += pPlayer->fric.y;
|
||||||
P_GetInput(myconnectindex);
|
|
||||||
|
|
||||||
// this is where we fill the input_t struct that is actually processed by P_ProcessInput()
|
|
||||||
auto const pPlayer = g_player[myconnectindex].ps;
|
|
||||||
auto const q16ang = fix16_to_int(pPlayer->q16ang);
|
|
||||||
auto & input = inputfifo[0][myconnectindex];
|
|
||||||
|
|
||||||
input = localInput;
|
|
||||||
input.fvel = mulscale9(localInput.fvel, sintable[(q16ang + 2560) & 2047]) +
|
|
||||||
mulscale9(localInput.svel, sintable[(q16ang + 2048) & 2047]);
|
|
||||||
input.svel = mulscale9(localInput.fvel, sintable[(q16ang + 2048) & 2047]) +
|
|
||||||
mulscale9(localInput.svel, sintable[(q16ang + 1536) & 2047]);
|
|
||||||
|
|
||||||
if (!FURY)
|
|
||||||
{
|
|
||||||
input.fvel += pPlayer->fric.x;
|
|
||||||
input.svel += pPlayer->fric.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
localInput = {};
|
|
||||||
|
|
||||||
if (((!GUICapture && (myplayer.gm & MODE_MENU) != MODE_MENU) || ud.recstat == 2 || (g_netServer || ud.multimode > 1))
|
|
||||||
&& (myplayer.gm & MODE_GAME))
|
|
||||||
{
|
|
||||||
Net_GetPackets();
|
|
||||||
G_DoMoveThings();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
while (((g_netClient || g_netServer) || (myplayer.gm & (MODE_MENU | MODE_DEMO)) == 0) && (int)(totalclock - ototalclock) >= TICSPERFRAME);
|
|
||||||
|
|
||||||
gameUpdate = true;
|
localInput = {};
|
||||||
g_gameUpdateTime = timerGetHiTicks() - gameUpdateStartTime;
|
|
||||||
|
|
||||||
if (g_gameUpdateAvgTime <= 0.0)
|
if (((!GUICapture && (myplayer.gm & MODE_MENU) != MODE_MENU) || ud.recstat == 2 || (g_netServer || ud.multimode > 1))
|
||||||
g_gameUpdateAvgTime = g_gameUpdateTime;
|
&& (myplayer.gm & MODE_GAME))
|
||||||
|
{
|
||||||
g_gameUpdateAvgTime
|
Net_GetPackets();
|
||||||
= ((GAMEUPDATEAVGTIMENUMSAMPLES - 1.f) * g_gameUpdateAvgTime + g_gameUpdateTime) / ((float)GAMEUPDATEAVGTIMENUMSAMPLES);
|
G_DoMoveThings();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gameUpdate = true;
|
||||||
|
g_gameUpdateTime = timerGetHiTicks() - gameUpdateStartTime;
|
||||||
|
|
||||||
|
if (g_gameUpdateAvgTime <= 0.0)
|
||||||
|
g_gameUpdateAvgTime = g_gameUpdateTime;
|
||||||
|
|
||||||
|
g_gameUpdateAvgTime
|
||||||
|
= ((GAMEUPDATEAVGTIMENUMSAMPLES - 1.f) * g_gameUpdateAvgTime + g_gameUpdateTime) / ((float)GAMEUPDATEAVGTIMENUMSAMPLES);
|
||||||
|
|
||||||
G_DoCheats();
|
G_DoCheats();
|
||||||
|
|
||||||
if (myplayer.gm & (MODE_EOL|MODE_RESTART))
|
if (myplayer.gm & (MODE_EOL|MODE_RESTART))
|
||||||
|
|
|
@ -7228,50 +7228,47 @@ MAIN_LOOP_RESTART:
|
||||||
|
|
||||||
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)
|
|
||||||
|
while (((g_netClient || g_netServer) || !(g_player[myconnectindex].ps->gm & (MODE_MENU|MODE_DEMO))) && (int)(totalclock - ototalclock) >= TICSPERFRAME)
|
||||||
{
|
{
|
||||||
do
|
ototalclock += TICSPERFRAME;
|
||||||
|
|
||||||
|
if (RRRA && g_player[myconnectindex].ps->on_motorcycle)
|
||||||
|
P_GetInputMotorcycle(myconnectindex);
|
||||||
|
else if (RRRA && g_player[myconnectindex].ps->on_boat)
|
||||||
|
P_GetInputBoat(myconnectindex);
|
||||||
|
else
|
||||||
|
P_GetInput(myconnectindex);
|
||||||
|
|
||||||
|
// this is where we fill the input_t struct that is actually processed by P_ProcessInput()
|
||||||
|
auto const pPlayer = g_player[myconnectindex].ps;
|
||||||
|
auto const q16ang = fix16_to_int(pPlayer->q16ang);
|
||||||
|
auto & input = inputfifo[g_player[myconnectindex].movefifoend&(MOVEFIFOSIZ-1)][myconnectindex];
|
||||||
|
|
||||||
|
input = localInput;
|
||||||
|
input.fvel = mulscale9(localInput.fvel, sintable[(q16ang + 2560) & 2047]) +
|
||||||
|
mulscale9(localInput.svel, sintable[(q16ang + 2048) & 2047]) +
|
||||||
|
pPlayer->fric.x;
|
||||||
|
input.svel = mulscale9(localInput.fvel, sintable[(q16ang + 2048) & 2047]) +
|
||||||
|
mulscale9(localInput.svel, sintable[(q16ang + 1536) & 2047]) +
|
||||||
|
pPlayer->fric.y;
|
||||||
|
localInput = {};
|
||||||
|
|
||||||
|
g_player[myconnectindex].movefifoend++;
|
||||||
|
|
||||||
|
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))
|
||||||
{
|
{
|
||||||
ototalclock += TICSPERFRAME;
|
G_MoveLoop();
|
||||||
|
|
||||||
if (RRRA && g_player[myconnectindex].ps->on_motorcycle)
|
|
||||||
P_GetInputMotorcycle(myconnectindex);
|
|
||||||
else if (RRRA && g_player[myconnectindex].ps->on_boat)
|
|
||||||
P_GetInputBoat(myconnectindex);
|
|
||||||
else
|
|
||||||
P_GetInput(myconnectindex);
|
|
||||||
|
|
||||||
// this is where we fill the input_t struct that is actually processed by P_ProcessInput()
|
|
||||||
auto const pPlayer = g_player[myconnectindex].ps;
|
|
||||||
auto const q16ang = fix16_to_int(pPlayer->q16ang);
|
|
||||||
auto & input = inputfifo[g_player[myconnectindex].movefifoend&(MOVEFIFOSIZ-1)][myconnectindex];
|
|
||||||
|
|
||||||
input = localInput;
|
|
||||||
input.fvel = mulscale9(localInput.fvel, sintable[(q16ang + 2560) & 2047]) +
|
|
||||||
mulscale9(localInput.svel, sintable[(q16ang + 2048) & 2047]) +
|
|
||||||
pPlayer->fric.x;
|
|
||||||
input.svel = mulscale9(localInput.fvel, sintable[(q16ang + 2048) & 2047]) +
|
|
||||||
mulscale9(localInput.svel, sintable[(q16ang + 1536) & 2047]) +
|
|
||||||
pPlayer->fric.y;
|
|
||||||
localInput = {};
|
|
||||||
|
|
||||||
g_player[myconnectindex].movefifoend++;
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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();
|
G_DoCheats();
|
||||||
|
|
||||||
if (g_player[myconnectindex].ps->gm & (MODE_EOL|MODE_RESTART))
|
if (g_player[myconnectindex].ps->gm & (MODE_EOL|MODE_RESTART))
|
||||||
|
|
Loading…
Reference in a new issue