mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Debounce cmd latency in local camera prediction
This commit is contained in:
parent
5bffc13db9
commit
4062447ee7
3 changed files with 21 additions and 1 deletions
|
|
@ -1082,6 +1082,7 @@ angle_t localangle[MAXSPLITSCREENPLAYERS];
|
|||
INT32 localsteering[MAXSPLITSCREENPLAYERS];
|
||||
INT32 localdelta[MAXSPLITSCREENPLAYERS];
|
||||
INT32 localstoredeltas[MAXSPLITSCREENPLAYERS][TICCMD_LATENCYMASK + 1];
|
||||
UINT8 locallatency[MAXSPLITSCREENPLAYERS][TICRATE];
|
||||
UINT8 localtic;
|
||||
|
||||
void G_ResetAnglePrediction(player_t *player)
|
||||
|
|
@ -1112,6 +1113,8 @@ static void G_DoAnglePrediction(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer, p
|
|||
|
||||
localtic = cmd->latency;
|
||||
|
||||
//CONS_Printf("anglepredict realtics %d latency %d\n", realtics, cmd->latency);
|
||||
|
||||
if (player->pflags & PF_DRIFTEND)
|
||||
{
|
||||
// Otherwise, your angle slingshots off to the side violently...
|
||||
|
|
@ -1137,6 +1140,7 @@ static void G_DoAnglePrediction(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer, p
|
|||
// but this causes incredible jittering when the prediction turns out to be wrong. So we ease into it.
|
||||
// Slight increased camera lag in all scenarios > Mostly lagless camera but with jittering
|
||||
destAngle = player->angleturn + localdelta[ssplayer - 1];
|
||||
|
||||
diff = destAngle - localangle[ssplayer - 1];
|
||||
|
||||
if (diff > ANGLE_180)
|
||||
|
|
@ -1149,6 +1153,9 @@ static void G_DoAnglePrediction(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer, p
|
|||
}
|
||||
|
||||
localangle[ssplayer - 1] += diff;
|
||||
|
||||
// In case of angle debugging, break glass
|
||||
// localangle[ssplayer - 1] = destAngle;
|
||||
}
|
||||
|
||||
void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
||||
|
|
|
|||
|
|
@ -118,6 +118,7 @@ extern INT32 localaiming[MAXSPLITSCREENPLAYERS]; // should be an angle_t but sig
|
|||
extern INT32 localsteering[MAXSPLITSCREENPLAYERS];
|
||||
extern INT32 localdelta[MAXSPLITSCREENPLAYERS];
|
||||
extern INT32 localstoredeltas[MAXSPLITSCREENPLAYERS][TICCMD_LATENCYMASK + 1];
|
||||
extern UINT8 locallatency[MAXSPLITSCREENPLAYERS][TICRATE];
|
||||
extern UINT8 localtic;
|
||||
|
||||
INT32 G_PlayerInputAnalog(UINT8 p, INT32 gc, UINT8 menuPlayers);
|
||||
|
|
|
|||
14
src/p_user.c
14
src/p_user.c
|
|
@ -2120,6 +2120,7 @@ static void P_3dMovement(player_t *player)
|
|||
static void P_UpdatePlayerAngle(player_t *player)
|
||||
{
|
||||
angle_t angleChange = ANGLE_MAX;
|
||||
UINT8 maxlatency;
|
||||
UINT8 p = UINT8_MAX;
|
||||
UINT8 i;
|
||||
|
||||
|
|
@ -2143,7 +2144,18 @@ static void P_UpdatePlayerAngle(player_t *player)
|
|||
}
|
||||
else
|
||||
{
|
||||
UINT8 lateTic = ((leveltime - player->cmd.latency) & TICCMD_LATENCYMASK);
|
||||
// During standard play, our latency can vary by up to 1 tic in either direction, even on a stable connection.
|
||||
// This probably comes from differences in ticcmd dispatch vs consumption rate. Probably.
|
||||
// Uncorrected, this 2-tic "wobble" causes camera corrections to sometimes be skipped or batched.
|
||||
// So just use the highest recent value for the furthest possible search.
|
||||
// We unset the correction after applying, anyway.
|
||||
locallatency[p][leveltime%TICRATE] = maxlatency = player->cmd.latency;
|
||||
for (i = 0; i < TICRATE; i++)
|
||||
{
|
||||
maxlatency = max(locallatency[p][i], maxlatency);
|
||||
}
|
||||
|
||||
UINT8 lateTic = ((leveltime - maxlatency) & TICCMD_LATENCYMASK);
|
||||
UINT8 clearTic = ((localtic + 1) & TICCMD_LATENCYMASK);
|
||||
|
||||
player->angleturn += angleChange;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue