engine: client: fix framerate depending player move
This commit is contained in:
parent
a9c0a4be23
commit
0796c14e79
2 changed files with 24 additions and 7 deletions
|
@ -589,8 +589,9 @@ static void CL_CreateCmd( void )
|
||||||
{
|
{
|
||||||
usercmd_t nullcmd, *cmd;
|
usercmd_t nullcmd, *cmd;
|
||||||
runcmd_t *pcmd;
|
runcmd_t *pcmd;
|
||||||
vec3_t angles;
|
|
||||||
qboolean active;
|
qboolean active;
|
||||||
|
double accurate_ms;
|
||||||
|
vec3_t angles;
|
||||||
int input_override;
|
int input_override;
|
||||||
int i, ms;
|
int i, ms;
|
||||||
|
|
||||||
|
@ -599,9 +600,23 @@ static void CL_CreateCmd( void )
|
||||||
|
|
||||||
// store viewangles in case it's will be freeze
|
// store viewangles in case it's will be freeze
|
||||||
VectorCopy( cl.viewangles, angles );
|
VectorCopy( cl.viewangles, angles );
|
||||||
ms = bound( 1, host.frametime * 1000, 255 );
|
|
||||||
input_override = 0;
|
input_override = 0;
|
||||||
|
|
||||||
|
// fix rounding error and framerate depending player move
|
||||||
|
accurate_ms = host.frametime * 1000;
|
||||||
|
ms = (int)accurate_ms;
|
||||||
|
cl.frametime_remainder += accurate_ms - ms; // accumulate rounding error each frame
|
||||||
|
|
||||||
|
// add a ms if error accumulates enough
|
||||||
|
if( cl.frametime_remainder > 1.0 )
|
||||||
|
{
|
||||||
|
cl.frametime_remainder = 0.0;
|
||||||
|
ms++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ms can't be negative, rely on error accumulation only if FPS > 1000
|
||||||
|
ms = Q_min( ms, 255 );
|
||||||
|
|
||||||
CL_SetSolidEntities();
|
CL_SetSolidEntities();
|
||||||
CL_PushPMStates();
|
CL_PushPMStates();
|
||||||
CL_SetSolidPlayers( cl.playernum );
|
CL_SetSolidPlayers( cl.playernum );
|
||||||
|
|
|
@ -276,6 +276,8 @@ typedef struct
|
||||||
model_t *worldmodel; // pointer to world
|
model_t *worldmodel; // pointer to world
|
||||||
|
|
||||||
int lostpackets; // count lost packets and show dialog in menu
|
int lostpackets; // count lost packets and show dialog in menu
|
||||||
|
|
||||||
|
double frametime_remainder;
|
||||||
} client_t;
|
} client_t;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Reference in a new issue