Commit d8a523e5 authored by Richard Gobeille's avatar Richard Gobeille
Browse files

Tie player input to the frame rate instead of the game tickrate

This voodoo bullshit entirely eliminates any and all player viewport input latency.

From-SVN: r8551
parent 53c92e05
......@@ -977,11 +977,8 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio)
pPlayer->opos.z + mulscale16(pPlayer->pos.z - pPlayer->opos.z, smoothRatio) };
CAMERA(pos) = camVect;
CAMERA(q16ang) = pPlayer->oq16ang
+ mulscale16(((pPlayer->q16ang + F16(1024) - pPlayer->oq16ang) & 0x7FFFFFF) - F16(1024), smoothRatio)
+ fix16_from_int(pPlayer->look_ang);
CAMERA(q16horiz) = pPlayer->oq16horiz + pPlayer->oq16horizoff
+ mulscale16((pPlayer->q16horiz + pPlayer->q16horizoff - pPlayer->oq16horiz - pPlayer->oq16horizoff), smoothRatio);
CAMERA(q16ang) = pPlayer->q16ang + fix16_from_int(pPlayer->look_ang);
CAMERA(q16horiz) = pPlayer->q16horiz + pPlayer->q16horizoff;
if (ud.viewbob)
{
......@@ -6898,46 +6895,6 @@ MAIN_LOOP_RESTART:
do //main loop
{
if (gameHandleEvents() && quitevent)
{
KB_KeyDown[sc_Escape] = 1;
quitevent = 0;
}
// only allow binds to function if the player is actually in a game (not in a menu, typing, et cetera) or demo
CONTROL_BindsEnabled = !!(myplayer.gm & (MODE_GAME|MODE_DEMO));
#ifndef _WIN32
// stdin -> OSD input for dedicated server
if (g_networkMode == NET_DEDICATED_SERVER)
{
int32_t nb;
char ch;
static uint32_t bufpos = 0;
static char buf[128];
#ifndef GEKKO
int32_t flag = 1;
ioctl(0, FIONBIO, &flag);
#endif
if ((nb = read(0, &ch, 1)) > 0 && bufpos < sizeof(buf))
{
if (ch != '\n')
buf[bufpos++] = ch;
if (ch == '\n' || bufpos >= sizeof(buf)-1)
{
buf[bufpos] = 0;
OSD_Dispatch(buf);
bufpos = 0;
}
}
}
else
#endif
G_HandleLocalKeys();
OSD_DispatchQueued();
static bool frameJustDrawn;
bool gameUpdate = false;
double gameUpdateStartTime = timerGetHiTicks();
......@@ -6954,7 +6911,18 @@ MAIN_LOOP_RESTART:
frameJustDrawn = false;
P_GetInput(myconnectindex);
inputfifo[0][myconnectindex] = localInput;
// this is where we fill the input_t struct that is actually processed by P_ProcessInput()
auto const pPlayer = g_player[myconnectindex].ps;
int16_t 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]) + (FURY ? 0 : pPlayer->fric.x);
input.svel = mulscale9(localInput.fvel, sintable[(q16ang + 2048) & 2047])
+ mulscale9(localInput.svel, sintable[(q16ang + 1536) & 2047]) + (FURY ? 0 : pPlayer->fric.y);
localInput = {};
}
do
......@@ -7018,6 +6986,51 @@ MAIN_LOOP_RESTART:
}
else if (G_FPSLimit() || g_saveRequested)
{
if (!g_saveRequested)
{
if (gameHandleEvents() && quitevent)
{
KB_KeyDown[sc_Escape] = 1;
quitevent = 0;
}
// only allow binds to function if the player is actually in a game (not in a menu, typing, et cetera) or demo
CONTROL_BindsEnabled = !!(myplayer.gm & (MODE_GAME|MODE_DEMO));
#ifndef _WIN32
// stdin -> OSD input for dedicated server
if (g_networkMode == NET_DEDICATED_SERVER)
{
int32_t nb;
char ch;
static uint32_t bufpos = 0;
static char buf[128];
#ifndef GEKKO
int32_t flag = 1;
ioctl(0, FIONBIO, &flag);
#endif
if ((nb = read(0, &ch, 1)) > 0 && bufpos < sizeof(buf))
{
if (ch != '\n')
buf[bufpos++] = ch;
if (ch == '\n' || bufpos >= sizeof(buf)-1)
{
buf[bufpos] = 0;
OSD_Dispatch(buf);
bufpos = 0;
}
}
}
else
#endif
G_HandleLocalKeys();
OSD_DispatchQueued();
P_GetInput(myconnectindex);
}
int const smoothRatio = calc_smoothratio(totalclock, ototalclock);
G_DrawRooms(screenpeek, smoothRatio);
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment