Xonotic
cl_player.qc File Reference
#include "cl_player.qh"
#include "cl_model.qh"
#include "common.qh"
#include "interpolate.qh"
+ Include dependency graph for cl_player.qc:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void CSQC_ClientMovement_PlayerMove_Frame (entity this)
 
vector CSQCModel_ApplyStairSmoothing (entity this, bool isonground, vector v)
 
vector CSQCPlayer_ApplyBobbing (entity this, vector v)
 
vector CSQCPlayer_ApplyChase (entity this, vector v)
 
void CSQCPlayer_ApplyDeathTilt (entity this)
 
void CSQCPlayer_ApplyIdleScaling (entity this)
 
vector CSQCPlayer_ApplySmoothing (entity this, vector v)
 
void CSQCPlayer_CalcRefdef (entity this)
 
float CSQCPlayer_CalcRoll (entity this)
 
vector CSQCPlayer_GetPredictionErrorO ()
 
vector CSQCPlayer_GetPredictionErrorV ()
 
bool CSQCPlayer_IsLocalPlayer (entity this)
 
void CSQCPlayer_Physics (entity this)
 
bool CSQCPlayer_PostUpdate (entity this)
 
void CSQCPlayer_PredictTo (entity this, float endframe, bool apply_error)
 
bool CSQCPlayer_PreUpdate (entity this)
 
void CSQCPlayer_Remove (entity this)
 
void CSQCPlayer_SavePrediction (entity this)
 
void CSQCPlayer_SetCamera ()
 Called once per CSQC_UpdateView() More...
 
void CSQCPlayer_SetMinsMaxs (entity this)
 
void CSQCPlayer_SetPredictionError (vector o, vector v, float onground_diff)
 
void CSQCPlayer_Unpredict (entity this)
 

Variables

float autocvar_chase_back
 
bool autocvar_chase_overhead
 
float autocvar_chase_pitchangle
 
float autocvar_chase_up
 
float autocvar_cl_bob = 0
 
float autocvar_cl_bob2 = 0
 
float autocvar_cl_bob2cycle = 1
 
float autocvar_cl_bob2smooth = 0.05
 
float autocvar_cl_bob_limit = 7
 
float autocvar_cl_bob_limit_heightcheck = 0
 
float autocvar_cl_bob_velocity_limit = 400
 
float autocvar_cl_bobcycle = 0.5
 
float autocvar_cl_bobfall = 0.05
 
float autocvar_cl_bobfallcycle = 3
 
float autocvar_cl_bobfallminspeed = 200
 
float autocvar_cl_bobup = 0.5
 
float autocvar_cl_movement_errorcompensation = 0
 
bool autocvar_cl_movement_intermissionrunning = false
 
float autocvar_cl_rollangle
 
float autocvar_cl_rollspeed
 
float autocvar_cl_smoothviewheight = 0.05
 
float autocvar_cl_stairsmoothspeed = 200
 
bool autocvar_cl_useenginerefdef = false
 
bool autocvar_v_deathtilt
 
float autocvar_v_deathtiltangle
 
float autocvar_v_idlescale
 
float autocvar_v_ipitch_cycle
 
float autocvar_v_ipitch_level
 
float autocvar_v_iroll_cycle
 
float autocvar_v_iroll_level
 
float autocvar_v_iyaw_cycle
 
float autocvar_v_iyaw_level
 
float bob2_smooth
 
float bobfall_speed
 
float bobfall_swing
 
float csqcplayer_moveframe
 
vector csqcplayer_origin
 
float csqcplayer_predictionerrorfactor
 
vector csqcplayer_predictionerroro
 
float csqcplayer_predictionerrortime
 
vector csqcplayer_predictionerrorv
 
float csqcplayer_sequence
 
vector csqcplayer_velocity
 
int player_pmflags
 
float pmove_onground
 
float smooth_prevtime
 
float stairsmooth_drawtime
 
float stairsmooth_offset
 
float stairsmooth_prevtime
 
float stairsmoothz
 
float viewheightavg
 

Function Documentation

◆ CSQC_ClientMovement_PlayerMove_Frame()

void CSQC_ClientMovement_PlayerMove_Frame ( entity  this)

Referenced by CSQCPlayer_Physics(), CSQCPlayer_SavePrediction(), and IsFlying().

+ Here is the caller graph for this function:

◆ CSQCModel_ApplyStairSmoothing()

vector CSQCModel_ApplyStairSmoothing ( entity  this,
bool  isonground,
vector  v 
)

Definition at line 245 of file cl_player.qc.

References autocvar_cl_stairsmoothspeed, bound(), csqcmodel_teleported, drawtime, max(), PHYS_STEPHEIGHT, stairsmooth_drawtime, stairsmooth_offset, stairsmooth_prevtime, time, and v.

Referenced by CSQCModel_Hook_PreDraw(), and CSQCPlayer_SetCamera().

246 {
247  float smoothtime = bound(0, time - this.stairsmooth_prevtime, 0.1);
248  this.stairsmooth_prevtime = max(this.stairsmooth_prevtime, this.stairsmooth_drawtime); // stairsmooth_drawtime is the previous frame's time at this point
249 
250  if(this.csqcmodel_teleported || !isonground || autocvar_cl_stairsmoothspeed <= 0 || this.ground_networkentity)
251  this.stairsmooth_offset = v.z;
252  else
253  {
254  if(this.stairsmooth_offset < v.z)
255  v.z = this.stairsmooth_offset = bound(v.z - PHYS_STEPHEIGHT(this), this.stairsmooth_offset + smoothtime * autocvar_cl_stairsmoothspeed, v.z);
256  else if(this.stairsmooth_offset > v.z)
257  v.z = this.stairsmooth_offset = bound(v.z, this.stairsmooth_offset - smoothtime * autocvar_cl_stairsmoothspeed, v.z + PHYS_STEPHEIGHT(this));
258  }
259 
260  this.stairsmooth_prevtime = time;
262 
263  return v;
264 }
float stairsmooth_offset
Definition: cl_player.qc:242
float stairsmooth_drawtime
Definition: cl_player.qc:244
float drawtime
Definition: view.qh:115
float autocvar_cl_stairsmoothspeed
Definition: cl_player.qc:213
vector v
Definition: ent_cs.qc:116
float stairsmooth_prevtime
Definition: cl_player.qc:243
#define PHYS_STEPHEIGHT(s)
Definition: movetypes.qh:38
float time
Definition: csprogsdefs.qc:16
float csqcmodel_teleported
Definition: cl_model.qh:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CSQCPlayer_ApplyBobbing()

vector CSQCPlayer_ApplyBobbing ( entity  this,
vector  v 
)

Definition at line 307 of file cl_player.qc.

References autocvar_cl_bob, autocvar_cl_bob2, autocvar_cl_bob2cycle, autocvar_cl_bob2smooth, autocvar_cl_bob_limit, autocvar_cl_bob_limit_heightcheck, autocvar_cl_bob_velocity_limit, autocvar_cl_bobcycle, autocvar_cl_bobfall, autocvar_cl_bobfallcycle, autocvar_cl_bobfallminspeed, autocvar_cl_bobup, BIT, bob2_smooth, bobfall_speed, bobfall_swing, bound(), cos(), csqcmodel_isdead, frametime, input_buttons, IS_ONGROUND, ISPLAYER_PLAYER, isplayermodel, M_PI, makevectors, max(), min(), MOVE_NOMONSTERS, NULL, rint(), sin(), sqrt(), time, trace_fraction, v, v_forward, v_right, v_up, vector(), velocity, and view_angles.

Referenced by CSQCPlayer_CalcRefdef().

308 {
309  if(this.csqcmodel_isdead || PHYS_INVEHICLE(this) || !(this.isplayermodel & ISPLAYER_PLAYER))
310  return v;
311 
312  // bounded XY speed, used by several effects below
313  float bob, cycle;
314 
315  // vertical view bobbing code
317  {
318  float bob_limit = autocvar_cl_bob_limit;
319 
321  {
322  // use traces to determine what range the view can bob in, and scale down the bob as needed
323  vector bob_height_check_dest = v;
324  bob_height_check_dest.z += autocvar_cl_bob_limit * 1.1;
325  traceline(v, bob_height_check_dest, MOVE_NOMONSTERS, NULL);
326  float trace1fraction = trace_fraction;
327 
328  bob_height_check_dest = v;
329  bob_height_check_dest.z += autocvar_cl_bob_limit * -0.5;
330  traceline(v, bob_height_check_dest, MOVE_NOMONSTERS, NULL);
331  float trace2fraction = trace_fraction;
332 
333  bob_limit *= min(trace1fraction, trace2fraction);
334  }
335 
336  // LordHavoc: figured out bobup: the time at which the sin is at 180
337  // degrees (which allows lengthening or squishing the peak or valley)
338  cycle = time / autocvar_cl_bobcycle;
339  cycle -= rint(cycle);
340  if(cycle < autocvar_cl_bobup)
341  cycle = sin(M_PI * cycle / autocvar_cl_bobup);
342  else
343  cycle = sin(M_PI + M_PI * (cycle - autocvar_cl_bobup) / (1.0 - autocvar_cl_bobup));
344  // bob is proportional to velocity in the xy plane
345  // (don't count Z, or jumping messes it up)
346  float xyspeed = bound(0, sqrt(this.velocity.x * this.velocity.x + this.velocity.y * this.velocity.y), autocvar_cl_bob_velocity_limit);
347  bob = xyspeed * autocvar_cl_bob;
348  bob = bound(0, bob, bob_limit);
349  bob = bob * 0.3 + bob * 0.7 * cycle;
350  v.z += bob;
351  }
352 
353  // horizontal view bobbing code
355  {
356  cycle = time / autocvar_cl_bob2cycle;
357  cycle -= rint(cycle);
358  if(cycle < 0.5)
359  cycle = cos(M_PI * cycle / 0.5); // cos looks better here with the other view bobbing using sin
360  else
361  cycle = cos(M_PI + M_PI * (cycle - 0.5) / 0.5);
362  bob = autocvar_cl_bob2 * cycle;
363 
364  // this value slowly decreases from 1 to 0 when we stop touching the ground.
365  // The cycle is later multiplied with it so the view smooths back to normal
366  if(IS_ONGROUND(this) && !(input_buttons & BIT(1))) // also block the effect while the jump button is pressed, to avoid twitches when bunny-hopping
367  bob2_smooth = 1;
368  else
369  {
370  if(bob2_smooth > 0)
372  else
373  bob2_smooth = 0;
374  }
375 
376  // calculate the front and side of the player between the X and Y axes
378  // now get the speed based on those angles. The bounds should match the same value as xyspeed's
381  v_forward = v_forward * bob;
382  v_right = v_right * bob;
383  // we use side with forward and front with right, so the bobbing goes
384  // to the side when we walk forward and to the front when we strafe
385  vector bob2vel;
386  bob2vel.x = side * v_forward.x + front * v_right.x + 0 * v_up.x;
387  bob2vel.y = side * v_forward.y + front * v_right.y + 0 * v_up.y;
388  bob2vel.z = side * v_forward.z + front * v_right.z + 0 * v_up.z;
389  v.x += bob2vel.x;
390  v.y += bob2vel.y;
391  }
392 
393  // fall bobbing code
394  // causes the view to swing down and back up when touching the ground
396  {
397  if(!IS_ONGROUND(this))
398  {
399  bobfall_speed = bound(-400, this.velocity.z, 0) * bound(0, autocvar_cl_bobfall, 0.1);
401  bobfall_swing = 1;
402  else
403  bobfall_swing = 0; // really?
404  }
405  else
406  {
408  float bobfall = sin(M_PI * bobfall_swing) * bobfall_speed;
409  v.z += bobfall;
410  }
411  }
412 
413  return v;
414 }
float bobfall_swing
Definition: cl_player.qc:304
const int ISPLAYER_PLAYER
Definition: common.qh:59
float autocvar_cl_bob_limit
Definition: cl_player.qc:294
bool csqcmodel_isdead
int isplayermodel
float autocvar_cl_bob_limit_heightcheck
Definition: cl_player.qc:295
float input_buttons
Definition: csprogsdefs.qc:62
#define IS_ONGROUND(s)
Definition: movetypes.qh:16
float autocvar_cl_bob
Definition: cl_player.qc:292
float bobfall_speed
Definition: cl_player.qc:305
float autocvar_cl_bobup
Definition: cl_player.qc:297
vector view_angles
Definition: csprogsdefs.qc:150
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
Definition: bits.qh:8
float autocvar_cl_bob_velocity_limit
Definition: cl_player.qc:296
const float MOVE_NOMONSTERS
Definition: csprogsdefs.qc:253
float autocvar_cl_bobfallminspeed
Definition: cl_player.qc:300
vector v_up
Definition: csprogsdefs.qc:31
float autocvar_cl_bob2smooth
Definition: cl_player.qc:303
float autocvar_cl_bob2cycle
Definition: cl_player.qc:302
#define NULL
Definition: post.qh:17
float frametime
Definition: csprogsdefs.qc:17
float autocvar_cl_bobcycle
Definition: cl_player.qc:293
float autocvar_cl_bobfallcycle
Definition: cl_player.qc:299
float autocvar_cl_bob2
Definition: cl_player.qc:301
vector(float skel, float bonenum) _skel_get_boneabs_hidden
const float M_PI
Definition: csprogsdefs.qc:269
vector v
Definition: ent_cs.qc:116
vector v_right
Definition: csprogsdefs.qc:31
float time
Definition: csprogsdefs.qc:16
vector velocity
Definition: csprogsdefs.qc:103
float autocvar_cl_bobfall
Definition: cl_player.qc:298
#define makevectors
Definition: post.qh:21
float trace_fraction
Definition: csprogsdefs.qc:36
float bob2_smooth
Definition: cl_player.qc:306
vector v_forward
Definition: csprogsdefs.qc:31
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CSQCPlayer_ApplyChase()

vector CSQCPlayer_ApplyChase ( entity  this,
vector  v 
)

Definition at line 437 of file cl_player.qc.

References autocvar_chase_back, autocvar_chase_front, autocvar_chase_overhead, autocvar_chase_pitchangle, autocvar_chase_up, makevectors, move_movetype, MOVE_NOMONSTERS, MOVE_NORMAL, MOVETYPE_NOCLIP, normalize(), NULL, spectatee_status, trace_endpos, trace_plane_normal, v, v_forward, v_up, vectoangles(), vector(), and view_angles.

Referenced by CSQCPlayer_CalcRefdef().

438 {
439  vector forward;
440  vector chase_dest;
441 
443  {
444  view_angles.x = 0;
446  forward = v_forward;
447  vector up = v_up;
448  // trace a little further so it hits a surface more consistently (to avoid 'snapping' on the edge of the range)
449  chase_dest.x = v.x - forward.x * autocvar_chase_back + up.x * autocvar_chase_up;
450  chase_dest.y = v.y - forward.y * autocvar_chase_back + up.y * autocvar_chase_up;
451  chase_dest.z = v.z - forward.z * autocvar_chase_back + up.z * autocvar_chase_up;
452 
453  // trace from first person view location to our chosen third person view location
454  traceline(v, chase_dest, MOVE_NOMONSTERS, NULL);
455 
456  vector bestvieworg = trace_endpos;
457  vector offset = '0 0 0';
458  for(offset.x = -16; offset.x <= 16; offset.x += 8)
459  {
460  for(offset.y = -16; offset.y <= 16; offset.y += 8)
461  {
463  up = v_up;
464  chase_dest.x = v.x - forward.x * autocvar_chase_back + up.x * autocvar_chase_up + offset.x;
465  chase_dest.y = v.y - forward.y * autocvar_chase_back + up.y * autocvar_chase_up + offset.y;
466  chase_dest.z = v.z - forward.z * autocvar_chase_back + up.z * autocvar_chase_up + offset.z;
467  traceline(v, chase_dest, MOVE_NOMONSTERS, NULL);
468  if(bestvieworg.z > trace_endpos.z)
469  bestvieworg.z = trace_endpos.z;
470  }
471  }
472  bestvieworg.z -= 8;
473  v = bestvieworg;
474 
476  //setproperty(VF_CL_VIEWANGLES, view_angles); // update view angles as well so we can aim
477  }
478  else
479  {
481  forward = v_forward;
483  forward = normalize(forward * -1);
484  // trace a little further so it hits a surface more consistently (to avoid 'snapping' on the edge of the range)
485  float cdist = -autocvar_chase_back - 8;
486  chase_dest.x = v.x + forward.x * cdist;
487  chase_dest.y = v.y + forward.y * cdist;
488  chase_dest.z = v.z + forward.z * cdist + autocvar_chase_up;
489  if (this.move_movetype == MOVETYPE_NOCLIP)
490  {
491  // as if traceline hasn't hit anything
492  trace_endpos = chase_dest;
493  trace_plane_normal = '0 0 0';
494  }
495  else
496  {
497  traceline(v, chase_dest, MOVE_NOMONSTERS, NULL);
498  }
499  v.x = 1 * trace_endpos.x + 8 * forward.x + 4 * trace_plane_normal.x;
500  v.y = 1 * trace_endpos.y + 8 * forward.y + 4 * trace_plane_normal.y;
501  v.z = 1 * trace_endpos.z + 8 * forward.z + 4 * trace_plane_normal.z;
502 
504  {
505  // now flip the view so the player is looking at themselves
506  vector newang = vectoangles(forward);
507  view_angles.x = view_angles.x * -1; // inverse up-down looking direction
508  view_angles.y = newang.y;
509  }
510  }
511 
512 #if 0
513  tracebox(v, '-4 -4 -4', '4 4 4', v - v_forward * autocvar_chase_back, MOVE_NORMAL, this);
514  v = trace_endpos;
515  tracebox(v, '-4 -4 -4', '4 4 4', v + v_up * autocvar_chase_up, MOVE_NORMAL, this);
516  v = trace_endpos;
517 #endif
518  return v;
519 }
float autocvar_chase_pitchangle
Definition: cl_player.qc:436
float autocvar_chase_up
Definition: cl_player.qc:434
const float MOVE_NORMAL
Definition: csprogsdefs.qc:252
bool autocvar_chase_overhead
Definition: cl_player.qc:435
float autocvar_chase_back
Definition: cl_player.qc:433
float move_movetype
Definition: movetypes.qh:76
vector view_angles
Definition: csprogsdefs.qc:150
bool autocvar_chase_front
Definition: view.qh:18
const float MOVE_NOMONSTERS
Definition: csprogsdefs.qc:253
vector v_up
Definition: csprogsdefs.qc:31
#define NULL
Definition: post.qh:17
vector trace_endpos
Definition: csprogsdefs.qc:37
vector(float skel, float bonenum) _skel_get_boneabs_hidden
float MOVETYPE_NOCLIP
Definition: progsdefs.qc:254
vector v
Definition: ent_cs.qc:116
float spectatee_status
Definition: main.qh:166
vector trace_plane_normal
Definition: csprogsdefs.qc:38
#define makevectors
Definition: post.qh:21
vector v_forward
Definition: csprogsdefs.qc:31
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CSQCPlayer_ApplyDeathTilt()

void CSQCPlayer_ApplyDeathTilt ( entity  this)

Definition at line 268 of file cl_player.qc.

References autocvar_v_deathtilt, autocvar_v_deathtiltangle, csqcmodel_isdead, and view_angles.

Referenced by CSQCPlayer_CalcRefdef().

269 {
271  return;
273 }
bool autocvar_v_deathtilt
Definition: cl_player.qc:266
float autocvar_v_deathtiltangle
Definition: cl_player.qc:267
bool csqcmodel_isdead
vector view_angles
Definition: csprogsdefs.qc:150
+ Here is the caller graph for this function:

◆ CSQCPlayer_ApplyIdleScaling()

void CSQCPlayer_ApplyIdleScaling ( entity  this)

Definition at line 282 of file cl_player.qc.

References autocvar_v_idlescale, autocvar_v_ipitch_cycle, autocvar_v_ipitch_level, autocvar_v_iroll_cycle, autocvar_v_iroll_level, autocvar_v_iyaw_cycle, autocvar_v_iyaw_level, sin(), time, and view_angles.

Referenced by CSQCPlayer_CalcRefdef().

283 {
285  return;
289  //setproperty(VF_CL_VIEWANGLES, view_angles); // update view angles as well so we can aim
290 }
float autocvar_v_iroll_level
Definition: cl_player.qc:281
float autocvar_v_iroll_cycle
Definition: cl_player.qc:278
float autocvar_v_ipitch_level
Definition: cl_player.qc:279
vector view_angles
Definition: csprogsdefs.qc:150
float autocvar_v_idlescale
Definition: cl_player.qc:275
float autocvar_v_iyaw_level
Definition: cl_player.qc:280
float time
Definition: csprogsdefs.qc:16
float autocvar_v_ipitch_cycle
Definition: cl_player.qc:276
float autocvar_v_iyaw_cycle
Definition: cl_player.qc:277
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CSQCPlayer_ApplySmoothing()

vector CSQCPlayer_ApplySmoothing ( entity  this,
vector  v 
)

Definition at line 217 of file cl_player.qc.

References autocvar_cl_smoothviewheight, autocvar_cl_stairsmoothspeed, bound(), csqcmodel_teleported, drawtime, max(), PHYS_STEPHEIGHT, PMF_ONGROUND, pmove_flags, smooth_prevtime, stairsmoothz, time, view_ofs, and viewheightavg.

Referenced by CSQCPlayer_CalcRefdef().

218 {
219  float smoothtime = bound(0, time - smooth_prevtime, 0.1);
220  smooth_prevtime = max(smooth_prevtime, drawtime); // drawtime is the previous frame's time at this point
221 
222  if(this.csqcmodel_teleported || !(this.pmove_flags & PMF_ONGROUND) || autocvar_cl_stairsmoothspeed <= 0 || this.ground_networkentity)
223  stairsmoothz = v.z;
224  else
225  {
226  if(stairsmoothz < v.z)
227  v.z = stairsmoothz = bound(v.z - PHYS_STEPHEIGHT(this), stairsmoothz + smoothtime * autocvar_cl_stairsmoothspeed, v.z);
228  else if(stairsmoothz > v.z)
229  v.z = stairsmoothz = bound(v.z, stairsmoothz - smoothtime * autocvar_cl_stairsmoothspeed, v.z + PHYS_STEPHEIGHT(this));
230  }
231 
232  float viewheight = bound(0, (time - smooth_prevtime) / max(0.0001, autocvar_cl_smoothviewheight), 1);
233  viewheightavg = viewheightavg * (1 - viewheight) + this.view_ofs.z * viewheight;
234  v.z += viewheightavg;
235 
237 
238  return v;
239 }
vector view_ofs
Definition: progsdefs.qc:151
int pmove_flags
Definition: cl_player.qh:33
float drawtime
Definition: view.qh:115
float autocvar_cl_stairsmoothspeed
Definition: cl_player.qc:213
float PMF_ONGROUND
Definition: csprogsdefs.qc:922
float smooth_prevtime
Definition: cl_player.qc:215
vector v
Definition: ent_cs.qc:116
float viewheightavg
Definition: cl_player.qc:216
float autocvar_cl_smoothviewheight
Definition: cl_player.qc:214
#define PHYS_STEPHEIGHT(s)
Definition: movetypes.qh:38
float time
Definition: csprogsdefs.qc:16
float csqcmodel_teleported
Definition: cl_model.qh:39
float stairsmoothz
Definition: cl_player.qc:212
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CSQCPlayer_CalcRefdef()

void CSQCPlayer_CalcRefdef ( entity  this)

Definition at line 521 of file cl_player.qc.

References autocvar_chase_active, CSQCPlayer_ApplyBobbing(), CSQCPlayer_ApplyChase(), CSQCPlayer_ApplyDeathTilt(), CSQCPlayer_ApplyIdleScaling(), CSQCPlayer_ApplySmoothing(), CSQCPlayer_CalcRoll(), intermission, origin, vector(), VF_ANGLES, VF_ORIGIN, view_angles, view_ofs, view_punchangle, and view_punchvector.

Referenced by CSQCPlayer_SetCamera().

522 {
523  vector vieworg = this.origin;
524  if(intermission)
525  {
526  // just update view offset, don't need to do anything else
527  vieworg.z += this.view_ofs.z;
528  }
529  else
530  {
531  vieworg = CSQCPlayer_ApplySmoothing(this, vieworg);
533  vieworg = CSQCPlayer_ApplyChase(this, vieworg);
534  else
535  {
536  // angles
539  view_angles.z += CSQCPlayer_CalcRoll(this);
540  // TODO? we don't have damage time accessible here
541  // origin
542  vieworg = vieworg + view_punchvector;
543  vieworg = CSQCPlayer_ApplyBobbing(this, vieworg);
544  }
546  }
547  setproperty(VF_ORIGIN, vieworg);
548  setproperty(VF_ANGLES, view_angles);
549 }
vector CSQCPlayer_ApplyChase(entity this, vector v)
Definition: cl_player.qc:437
vector view_ofs
Definition: progsdefs.qc:151
float intermission
Definition: csprogsdefs.qc:148
origin
Definition: ent_cs.qc:114
void CSQCPlayer_ApplyIdleScaling(entity this)
Definition: cl_player.qc:282
void CSQCPlayer_ApplyDeathTilt(entity this)
Definition: cl_player.qc:268
vector view_angles
Definition: csprogsdefs.qc:150
float CSQCPlayer_CalcRoll(entity this)
Definition: cl_player.qc:418
vector(float skel, float bonenum) _skel_get_boneabs_hidden
vector CSQCPlayer_ApplySmoothing(entity this, vector v)
Definition: cl_player.qc:217
const float VF_ANGLES
Definition: csprogsdefs.qc:186
vector view_punchangle
Definition: csprogsdefs.qc:151
int autocvar_chase_active
Definition: view.qh:17
vector view_punchvector
Definition: csprogsdefs.qc:152
vector CSQCPlayer_ApplyBobbing(entity this, vector v)
Definition: cl_player.qc:307
const float VF_ORIGIN
Definition: csprogsdefs.qc:182
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CSQCPlayer_CalcRoll()

float CSQCPlayer_CalcRoll ( entity  this)

Definition at line 418 of file cl_player.qc.

References autocvar_cl_rollangle, autocvar_cl_rollspeed, fabs(), makevectors, v_right, velocity, and view_angles.

Referenced by CSQCPlayer_CalcRefdef().

419 {
421  float side = (this.velocity * v_right);
422  float sign = (side < 0) ? -1 : 1;
423  side = fabs(side);
424 
425  if(side < autocvar_cl_rollspeed)
427  else
428  side = autocvar_cl_rollangle;
429 
430  return side * sign;
431 }
float autocvar_cl_rollspeed
Definition: cl_player.qc:417
vector view_angles
Definition: csprogsdefs.qc:150
float autocvar_cl_rollangle
Definition: cl_player.qc:416
vector v_right
Definition: csprogsdefs.qc:31
vector velocity
Definition: csprogsdefs.qc:103
#define makevectors
Definition: post.qh:21
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CSQCPlayer_GetPredictionErrorO()

vector CSQCPlayer_GetPredictionErrorO ( )

Definition at line 44 of file cl_player.qc.

References csqcplayer_predictionerrorfactor, csqcplayer_predictionerroro, csqcplayer_predictionerrortime, and time.

Referenced by CSQCPlayer_PredictTo(), and CSQCPlayer_SetPredictionError().

45 {
46  if (time >= csqcplayer_predictionerrortime) return '0 0 0';
48 }
vector csqcplayer_predictionerroro
Definition: cl_player.qc:39
float csqcplayer_predictionerrortime
Definition: cl_player.qc:41
float csqcplayer_predictionerrorfactor
Definition: cl_player.qc:42
float time
Definition: csprogsdefs.qc:16
+ Here is the caller graph for this function:

◆ CSQCPlayer_GetPredictionErrorV()

vector CSQCPlayer_GetPredictionErrorV ( )

Definition at line 50 of file cl_player.qc.

References csqcplayer_predictionerrorfactor, csqcplayer_predictionerrortime, csqcplayer_predictionerrorv, and time.

Referenced by CSQCPlayer_PredictTo(), and CSQCPlayer_SetPredictionError().

51 {
52  if (time >= csqcplayer_predictionerrortime) return '0 0 0';
54 }
float csqcplayer_predictionerrortime
Definition: cl_player.qc:41
float csqcplayer_predictionerrorfactor
Definition: cl_player.qc:42
vector csqcplayer_predictionerrorv
Definition: cl_player.qc:40
float time
Definition: csprogsdefs.qc:16
+ Here is the caller graph for this function:

◆ CSQCPlayer_IsLocalPlayer()

bool CSQCPlayer_IsLocalPlayer ( entity  this)

Definition at line 207 of file cl_player.qc.

References csqcplayer.

Referenced by CSQCModel_Draw().

208 {
209  return (this == csqcplayer);
210 }
entity csqcplayer
Definition: cl_player.qh:26
+ Here is the caller graph for this function:

◆ CSQCPlayer_Physics()

void CSQCPlayer_Physics ( entity  this)

Definition at line 128 of file cl_player.qc.

References angles, autocvar_cl_movement, CSQC_ClientMovement_PlayerMove_Frame(), input_angles, IS_DUCKED, IS_JUMP_HELD, IS_ONGROUND, Movetype_Physics_NoMatchTicrate(), PMF_DUCKED, PMF_JUMP_HELD, PMF_ONGROUND, pmove_flags, v_angle, vector(), and view_angles.

Referenced by CSQCPlayer_PredictTo().

129 {
130  if(!autocvar_cl_movement) { return; }
131 
132  //_Movetype_CheckWater(this); // we apparently need to check water *before* physics so it can use this for water jump
133 
134  vector oldv_angle = this.v_angle;
135  vector oldangles = this.angles; // we need to save these, as they're abused by other code
136  this.v_angle = PHYS_INPUT_ANGLES(this);
137  this.angles = PHYS_WORLD_ANGLES(this);
138 
140 
141  Movetype_Physics_NoMatchTicrate(this, PHYS_INPUT_TIMELENGTH, true);
142 
143  view_angles = this.v_angle;
144  input_angles = this.angles;
145  this.v_angle = oldv_angle;
146  this.angles = oldangles;
147 
148  this.pmove_flags =
149  ((IS_DUCKED(this)) ? PMF_DUCKED : 0) |
150  ((IS_JUMP_HELD(this)) ? PMF_JUMP_HELD : 0) |
151  ((IS_ONGROUND(this)) ? PMF_ONGROUND : 0);
152 }
const int PMF_JUMP_HELD
Definition: cl_player.qh:34
int pmove_flags
Definition: cl_player.qh:33
#define IS_DUCKED(s)
Definition: player.qh:206
void CSQC_ClientMovement_PlayerMove_Frame(entity this)
vector input_angles
Definition: csprogsdefs.qc:60
vector v_angle
Definition: progsdefs.qc:161
#define IS_ONGROUND(s)
Definition: movetypes.qh:16
void Movetype_Physics_NoMatchTicrate(entity this, float movedt, bool isclient)
Definition: movetypes.qc:813
float PMF_DUCKED
Definition: csprogsdefs.qc:921
vector view_angles
Definition: csprogsdefs.qc:150
float PMF_ONGROUND
Definition: csprogsdefs.qc:922
vector(float skel, float bonenum) _skel_get_boneabs_hidden
vector angles
Definition: csprogsdefs.qc:104
#define IS_JUMP_HELD(s)
Definition: player.qh:199
bool autocvar_cl_movement
Definition: cl_player.qh:24
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CSQCPlayer_PostUpdate()

bool CSQCPlayer_PostUpdate ( entity  this)

Definition at line 674 of file cl_player.qc.

References csqcplayer, CSQCPlayer_Remove(), csqcplayer_status, CSQCPLAYERSTATUS_FROMSERVER, cvar(), cvar_settemp(), entnum, and player_localnum.

Referenced by NET_HANDLE().

675 {
676  if (this.entnum != player_localnum + 1) return false;
677  csqcplayer = this;
679  if (cvar("cl_movement_replay"))
680  cvar_settemp("cl_movement_replay", "0");
681  this.entremove = CSQCPlayer_Remove;
682  return true;
683 }
float cvar_settemp(string tmp_cvar, string tmp_value)
Definition: util.qc:696
void CSQCPlayer_Remove(entity this)
Definition: cl_player.qc:661
float csqcplayer_status
Definition: cl_player.qh:27
entity csqcplayer
Definition: cl_player.qh:26
const int CSQCPLAYERSTATUS_FROMSERVER
Definition: cl_player.qh:29
float entnum
Definition: csprogsdefs.qc:94
float player_localnum
Definition: csprogsdefs.qc:20
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CSQCPlayer_PredictTo()

void CSQCPlayer_PredictTo ( entity  this,
float  endframe,
bool  apply_error 
)

Definition at line 154 of file cl_player.qc.

References clientcommandframe, CSQCPlayer_GetPredictionErrorO(), CSQCPlayer_GetPredictionErrorV(), csqcplayer_moveframe, CSQCPlayer_Physics(), CSQCPlayer_SetMinsMaxs(), csqcplayer_status, CSQCPlayer_Unpredict(), CSQCPLAYERSTATUS_PREDICTED, input_angles, LOG_INFO, origin, velocity, and view_angles.

Referenced by CSQCPlayer_SetCamera().

155 {
156  CSQCPlayer_Unpredict(this);
157  if (apply_error)
158  {
161  }
163 
165 
166 #if 0
167  // we don't need this
168  // darkplaces makes servercommandframe == 0 in these cases anyway
169  if (STAT(HEALTH) <= 0)
170  {
172  getinputstate(csqcplayer_moveframe-1);
173  LOG_INFO("the Weird code path got hit");
174  return;
175  }
176 #endif
177 
178  if (csqcplayer_moveframe >= endframe)
179  {
180  getinputstate(csqcplayer_moveframe - 1);
181  }
182  else
183  {
184  do
185  {
186  if (!getinputstate(csqcplayer_moveframe)) break;
187  /*if (input_timelength > 0.0005)
188  {
189  if (input_timelength > 0.05)
190  {
191  input_timelength /= 2;
192  CSQCPlayer_Physics(this);
193  }
194  CSQCPlayer_Physics(this);
195  }*/
196  CSQCPlayer_Physics(this);
199  }
200  while (csqcplayer_moveframe < endframe);
201  }
202 
203  // add in anything that was applied after (for low packet rate protocols)
205 }
vector CSQCPlayer_GetPredictionErrorO()
Definition: cl_player.qc:44
vector input_angles
Definition: csprogsdefs.qc:60
void CSQCPlayer_SetMinsMaxs(entity this)
Definition: cl_player.qc:99
const int CSQCPLAYERSTATUS_PREDICTED
Definition: cl_player.qh:30
origin
Definition: ent_cs.qc:114
float csqcplayer_status
Definition: cl_player.qh:27
void CSQCPlayer_Unpredict(entity this)
Definition: cl_player.qc:89
vector CSQCPlayer_GetPredictionErrorV()
Definition: cl_player.qc:50
float clientcommandframe
Definition: csprogsdefs.qc:23
vector view_angles
Definition: csprogsdefs.qc:150
float csqcplayer_moveframe
Definition: cl_player.qc:38
#define LOG_INFO(...)
Definition: log.qh:70
void CSQCPlayer_Physics(entity this)
Definition: cl_player.qc:128
vector velocity
Definition: csprogsdefs.qc:103
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CSQCPlayer_PreUpdate()

bool CSQCPlayer_PreUpdate ( entity  this)

Definition at line 667 of file cl_player.qc.

References csqcplayer, csqcplayer_status, CSQCPlayer_Unpredict(), and CSQCPLAYERSTATUS_FROMSERVER.

Referenced by NET_HANDLE().

668 {
669  if (this != csqcplayer) return false;
671  return true;
672 }
float csqcplayer_status
Definition: cl_player.qh:27
void CSQCPlayer_Unpredict(entity this)
Definition: cl_player.qc:89
entity csqcplayer
Definition: cl_player.qh:26
const int CSQCPLAYERSTATUS_FROMSERVER
Definition: cl_player.qh:29
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CSQCPlayer_Remove()

void CSQCPlayer_Remove ( entity  this)

Definition at line 661 of file cl_player.qc.

References csqcplayer, cvar_settemp(), and NULL.

Referenced by CSQCPlayer_PostUpdate().

662 {
663  csqcplayer = NULL;
664  cvar_settemp("cl_movement_replay", "1");
665 }
float cvar_settemp(string tmp_cvar, string tmp_value)
Definition: util.qc:696
#define NULL
Definition: post.qh:17
entity csqcplayer
Definition: cl_player.qh:26
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CSQCPlayer_SavePrediction()

void CSQCPlayer_SavePrediction ( entity  this)

Definition at line 117 of file cl_player.qc.

References CSQC_ClientMovement_PlayerMove_Frame(), csqcplayer_origin, csqcplayer_sequence, csqcplayer_status, csqcplayer_velocity, CSQCPLAYERSTATUS_PREDICTED, entity(), flags, origin, player_pmflags, servercommandframe, and velocity.

Referenced by CSQCPlayer_SetCamera().

118 {
119  player_pmflags = this.flags;
120  csqcplayer_origin = this.origin;
124 }
vector csqcplayer_origin
Definition: cl_player.qc:35
float servercommandframe
Definition: csprogsdefs.qc:24
const int CSQCPLAYERSTATUS_PREDICTED
Definition: cl_player.qh:30
origin
Definition: ent_cs.qc:114
float csqcplayer_status
Definition: cl_player.qh:27
float csqcplayer_sequence
Definition: cl_player.qc:36
float flags
Definition: csprogsdefs.qc:129
vector velocity
Definition: csprogsdefs.qc:103
vector csqcplayer_velocity
Definition: cl_player.qc:35
int player_pmflags
Definition: cl_player.qc:37
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CSQCPlayer_SetCamera()

void CSQCPlayer_SetCamera ( )

Called once per CSQC_UpdateView()

Definition at line 554 of file cl_player.qc.

References autocvar_cl_movement_intermissionrunning, autocvar_cl_useenginerefdef, BIT, BITSET, clientcommandframe, CSQCModel_ApplyStairSmoothing(), CSQCModel_server2csqc(), csqcplayer, CSQCPlayer_CalcRefdef(), CSQCPLAYER_HOOK_POSTCAMERASETUP, CSQCPlayer_PredictTo(), CSQCPlayer_SavePrediction(), CSQCPlayer_SetMinsMaxs(), CSQCPlayer_SetPredictionError(), csqcplayer_status, CSQCPLAYERSTATUS_FROMSERVER, CSQCPLAYERSTATUS_PREDICTED, drawtime, entity(), FL_ONGROUND, IFLAG_ANGLES, IFLAG_ORIGIN, input_angles, input_buttons, intermission, InterpolateOrigin_Do(), IS_DEAD, IS_ONGROUND, NULL, PHYS_HEALTH, PHYS_PL_CROUCH_VIEWOFS, PHYS_PL_VIEWOFS, PHYS_VIEWHEIGHT, player_localentnum, PMF_ONGROUND, pmove_onground, pmove_vel, REFDEFFLAG_DEAD, REFDEFFLAG_INTERMISSION, REFDEFFLAG_JUMPING, REFDEFFLAG_TELEPORTED, servercommandframe, setorigin(), and vector().

Referenced by CSQC_UpdateView().

555 {
556  vector v0 = ((intermission && !autocvar_cl_movement_intermissionrunning) ? '0 0 0' : pmove_vel); // TRICK: pmove_vel is set by the engine when we get here. No need to network velocity
557  float vh = PHYS_VIEWHEIGHT(NULL);
558  vector pl_viewofs = PHYS_PL_VIEWOFS(NULL);
559  vector pl_viewofs_crouch = PHYS_PL_CROUCH_VIEWOFS(NULL);
560  entity e = csqcplayer;
561  if (e)
562  {
563  if (servercommandframe == 0 || clientcommandframe == 0)
564  {
566  e.view_ofs = '0 0 1' * vh;
567 
568  // get crouch state from the server
569  if (vh == pl_viewofs.z) e.flags &= ~FL_DUCKED;
570  else if (vh == pl_viewofs_crouch.z) e.flags |= FL_DUCKED;
571 
572  // get onground state from the server
573  e.flags = BITSET(e.flags, FL_ONGROUND, pmove_onground);
574 
576 
577  // override it back just in case
578  e.view_ofs = '0 0 1' * vh;
579 
580  // set velocity
581  e.velocity = v0;
582  }
583  else
584  {
585  int flg = e.iflags; e.iflags &= ~(IFLAG_ORIGIN | IFLAG_ANGLES);
587  e.iflags = flg;
588 
590  {
591  vector o = e.origin;
594  CSQCPlayer_SetPredictionError(e.origin - o, e.velocity - v0, pmove_onground - IS_ONGROUND(e));
595  e.origin = o;
596  e.velocity = v0;
597 
598  // get crouch state from the server
599  if (vh == pl_viewofs.z) e.flags &= ~FL_DUCKED;
600  else if(vh == pl_viewofs_crouch.z) e.flags |= FL_DUCKED;
601 
602  // get onground state from the server
603  e.flags = BITSET(e.flags, FL_ONGROUND, pmove_onground);
604 
606  }
608 
609 #ifdef CSQCMODEL_SERVERSIDE_CROUCH
610  // get crouch state from the server (LAG)
611  if (vh == pl_viewofs.z) e.flags &= ~FL_DUCKED;
612  else if (vh == pl_viewofs_crouch.z) e.flags |= FL_DUCKED;
613 #endif
615 
616  if (!IS_DEAD(e))
617  e.angles.y = input_angles.y;
618  }
619 
620  // relink
621  e.stairsmooth_drawtime = drawtime; // since drawtime is a frame old at this point, copy it now to avoid using a drawtime 2 frames old!
622  e.origin = CSQCModel_ApplyStairSmoothing(e, (e.pmove_flags & PMF_ONGROUND), e.origin);
623  setorigin(e, e.origin);
624  }
625 
627  if (view)
628  {
629  if (view != csqcplayer)
630  {
631  InterpolateOrigin_Do(view);
632  view.view_ofs = '0 0 1' * vh;
633  }
635  {
636  int refdefflags = 0;
637  if (view.csqcmodel_teleported) refdefflags |= REFDEFFLAG_TELEPORTED;
638  if (input_buttons & BIT(1)) refdefflags |= REFDEFFLAG_JUMPING;
639  // note: these two only work in WIP2, but are harmless in WIP1
640  if (PHYS_HEALTH(NULL) <= 0 && PHYS_HEALTH(NULL) != -666 && PHYS_HEALTH(NULL) != -2342) refdefflags |= REFDEFFLAG_DEAD;
641  if (intermission) refdefflags |= REFDEFFLAG_INTERMISSION;
642  V_CalcRefdef(view, refdefflags); // TODO? uses .health stat in the engine when this isn't called here, may be broken!
643  }
644  else
645  {
646  CSQCPlayer_CalcRefdef(view);
647  }
648  }
649  else
650  {
651  // FIXME by CSQC spec we have to do this:
652  // but it breaks chase cam
653  /*
654  setproperty(VF_ORIGIN, pmove_org + '0 0 1' * vh);
655  setproperty(VF_ANGLES, view_angles);
656  */
657  }
659 }
#define CSQCPLAYER_HOOK_POSTCAMERASETUP()
entity CSQCModel_server2csqc(int i)
Definition: cl_model.qc:314
#define PHYS_PL_CROUCH_VIEWOFS(s)
Definition: player.qh:86
#define PHYS_PL_VIEWOFS(s)
Definition: player.qh:85
float servercommandframe
Definition: csprogsdefs.qc:24
float FL_ONGROUND
Definition: progsdefs.qc:240
entity() spawn
float input_buttons
Definition: csprogsdefs.qc:62
vector input_angles
Definition: csprogsdefs.qc:60
#define IS_ONGROUND(s)
Definition: movetypes.qh:16
float intermission
Definition: csprogsdefs.qc:148
void CSQCPlayer_SetMinsMaxs(entity this)
Definition: cl_player.qc:99
const int CSQCPLAYERSTATUS_PREDICTED
Definition: cl_player.qh:30
vector pmove_vel
Definition: csprogsdefs.qc:55
float csqcplayer_status
Definition: cl_player.qh:27
float drawtime
Definition: view.qh:115
float REFDEFFLAG_DEAD
Definition: csprogsdefs.qc:925
void CSQCPlayer_CalcRefdef(entity this)
Definition: cl_player.qc:521
float clientcommandframe
Definition: csprogsdefs.qc:23
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
Definition: bits.qh:8
float REFDEFFLAG_TELEPORTED
Definition: csprogsdefs.qc:923
#define NULL
Definition: post.qh:17
float PMF_ONGROUND
Definition: csprogsdefs.qc:922
#define IS_DEAD(s)
Definition: utils.qh:26
bool autocvar_cl_movement_intermissionrunning
Definition: cl_player.qc:30
float player_localentnum
Definition: csprogsdefs.qc:19
#define BITSET(var, mask, flag)
Definition: bits.qh:11
vector(float skel, float bonenum) _skel_get_boneabs_hidden
#define PHYS_VIEWHEIGHT(s)
Definition: player.qh:88
const int IFLAG_ORIGIN
Definition: interpolate.qh:36
void CSQCPlayer_SetPredictionError(vector o, vector v, float onground_diff)
Definition: cl_player.qc:56
vector CSQCModel_ApplyStairSmoothing(entity this, bool isonground, vector v)
Definition: cl_player.qc:245
setorigin(ent, v)
float REFDEFFLAG_INTERMISSION
Definition: csprogsdefs.qc:926
void CSQCPlayer_PredictTo(entity this, float endframe, bool apply_error)
Definition: cl_player.qc:154
entity csqcplayer
Definition: cl_player.qh:26
bool autocvar_cl_useenginerefdef
Definition: cl_player.qc:551
float pmove_onground
Definition: cl_player.qc:33
float REFDEFFLAG_JUMPING
Definition: csprogsdefs.qc:924
#define PHYS_HEALTH(s)
Definition: player.qh:89
const int CSQCPLAYERSTATUS_FROMSERVER
Definition: cl_player.qh:29
void InterpolateOrigin_Do(entity this)
set origin based on iorigin1 (old pos), iorigin2 (desired pos), and time
Definition: interpolate.qc:129
const int IFLAG_ANGLES
Definition: interpolate.qh:28
void CSQCPlayer_SavePrediction(entity this)
Definition: cl_player.qc:117
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CSQCPlayer_SetMinsMaxs()

void CSQCPlayer_SetMinsMaxs ( entity  this)

Definition at line 99 of file cl_player.qc.

References IS_DEAD, IS_DUCKED, ISPLAYER_PLAYER, isplayermodel, maxs, mins, PHYS_PL_CROUCH_MAX, PHYS_PL_CROUCH_MIN, PHYS_PL_CROUCH_VIEWOFS, PHYS_PL_MAX, PHYS_PL_MIN, PHYS_PL_VIEWOFS, and view_ofs.

Referenced by CSQCPlayer_PredictTo(), and CSQCPlayer_SetCamera().

100 {
101  if (IS_DUCKED(this) || !(this.isplayermodel & ISPLAYER_PLAYER))
102  {
103  this.mins = PHYS_PL_CROUCH_MIN(this);
104  this.maxs = PHYS_PL_CROUCH_MAX(this);
105  this.view_ofs = PHYS_PL_CROUCH_VIEWOFS(this);
106  }
107  else
108  {
109  this.mins = PHYS_PL_MIN(this);
110  this.maxs = PHYS_PL_MAX(this);
111  if (IS_DEAD(this))
112  this.maxs.z = 5;
113  this.view_ofs = PHYS_PL_VIEWOFS(this);
114  }
115 }
#define PHYS_PL_CROUCH_MIN(s)
Definition: player.qh:83
#define PHYS_PL_CROUCH_MAX(s)
Definition: player.qh:82
const int ISPLAYER_PLAYER
Definition: common.qh:59
vector view_ofs
Definition: progsdefs.qc:151
#define PHYS_PL_CROUCH_VIEWOFS(s)
Definition: player.qh:86
#define PHYS_PL_VIEWOFS(s)
Definition: player.qh:85
#define IS_DUCKED(s)
Definition: player.qh:206
int isplayermodel
vector maxs
Definition: csprogsdefs.qc:113
#define PHYS_PL_MAX(s)
Definition: player.qh:80
vector mins
Definition: csprogsdefs.qc:113
#define PHYS_PL_MIN(s)
Definition: player.qh:81
#define IS_DEAD(s)
Definition: utils.qh:26
+ Here is the caller graph for this function:

◆ CSQCPlayer_SetPredictionError()

void CSQCPlayer_SetPredictionError ( vector  o,
vector  v,
float  onground_diff 
)

Definition at line 56 of file cl_player.qc.

References autocvar_cl_movement_errorcompensation, CSQCPlayer_GetPredictionErrorO(), CSQCPlayer_GetPredictionErrorV(), csqcplayer_predictionerrorfactor, csqcplayer_predictionerroro, csqcplayer_predictionerrortime, csqcplayer_predictionerrorv, ticrate, time, v, and vdist.

Referenced by CSQCPlayer_SetCamera().

57 {
58  // error too big to compensate, we LIKELY hit a teleport or a
59  // jumppad, or it's a jump time disagreement that'll get fixed
60  // next frame
61 
62  // FIXME we sometimes have disagreement in order of jump velocity. Do not act on them!
63  /*
64  // commented out as this one did not help
65  if(onground_diff)
66  {
67  printf("ONGROUND MISMATCH: %d x=%v v=%v\n", onground_diff, o, v);
68  return;
69  }
70  */
71  if(vdist(o, >, 32) || vdist(v, >, 192))
72  {
73  //printf("TOO BIG: x=%v v=%v\n", o, v);
74  return;
75  }
76 
78  {
80  return;
81  }
82 
87 }
vector CSQCPlayer_GetPredictionErrorO()
Definition: cl_player.qc:44
vector CSQCPlayer_GetPredictionErrorV()
Definition: cl_player.qc:50
vector csqcplayer_predictionerroro
Definition: cl_player.qc:39
float csqcplayer_predictionerrortime
Definition: cl_player.qc:41
float csqcplayer_predictionerrorfactor
Definition: cl_player.qc:42
vector csqcplayer_predictionerrorv
Definition: cl_player.qc:40
float autocvar_cl_movement_errorcompensation
Definition: cl_player.qc:29
vector v
Definition: ent_cs.qc:116
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
Definition: vector.qh:8
float time
Definition: csprogsdefs.qc:16
float ticrate
Definition: main.qh:182
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CSQCPlayer_Unpredict()

void CSQCPlayer_Unpredict ( entity  this)

Definition at line 89 of file cl_player.qc.

References csqcplayer_moveframe, csqcplayer_origin, csqcplayer_sequence, csqcplayer_status, csqcplayer_velocity, CSQCPLAYERSTATUS_PREDICTED, CSQCPLAYERSTATUS_UNPREDICTED, flags, LOG_FATALF, origin, player_pmflags, and velocity.

Referenced by CSQCPlayer_PredictTo(), and CSQCPlayer_PreUpdate().

90 {
92  if (csqcplayer_status != CSQCPLAYERSTATUS_PREDICTED) LOG_FATALF("Cannot unpredict in current status (%d)", csqcplayer_status);
95  csqcplayer_moveframe = csqcplayer_sequence + 1; // + 1 because the recieved frame has the move already done (server side)
96  this.flags = player_pmflags;
97 }
vector csqcplayer_origin
Definition: cl_player.qc:35
const int CSQCPLAYERSTATUS_PREDICTED
Definition: cl_player.qh:30
origin
Definition: ent_cs.qc:114
float csqcplayer_status
Definition: cl_player.qh:27
float csqcplayer_moveframe
Definition: cl_player.qc:38
float csqcplayer_sequence
Definition: cl_player.qc:36
float flags
Definition: csprogsdefs.qc:129
#define LOG_FATALF(...)
Definition: log.qh:59
const int CSQCPLAYERSTATUS_UNPREDICTED
Definition: cl_player.qh:28
vector velocity
Definition: csprogsdefs.qc:103
vector csqcplayer_velocity
Definition: cl_player.qc:35
int player_pmflags
Definition: cl_player.qc:37
+ Here is the caller graph for this function:

Variable Documentation

◆ autocvar_chase_back

float autocvar_chase_back

Definition at line 433 of file cl_player.qc.

Referenced by CSQCPlayer_ApplyChase().

◆ autocvar_chase_overhead

bool autocvar_chase_overhead

Definition at line 435 of file cl_player.qc.

Referenced by CSQCPlayer_ApplyChase().

◆ autocvar_chase_pitchangle

float autocvar_chase_pitchangle

Definition at line 436 of file cl_player.qc.

Referenced by CSQCPlayer_ApplyChase().

◆ autocvar_chase_up

float autocvar_chase_up

Definition at line 434 of file cl_player.qc.

Referenced by CSQCPlayer_ApplyChase().

◆ autocvar_cl_bob

float autocvar_cl_bob = 0

Definition at line 292 of file cl_player.qc.

Referenced by CSQCPlayer_ApplyBobbing().

◆ autocvar_cl_bob2

float autocvar_cl_bob2 = 0

Definition at line 301 of file cl_player.qc.

Referenced by CSQCPlayer_ApplyBobbing().

◆ autocvar_cl_bob2cycle

float autocvar_cl_bob2cycle = 1

Definition at line 302 of file cl_player.qc.

Referenced by CSQCPlayer_ApplyBobbing().

◆ autocvar_cl_bob2smooth

float autocvar_cl_bob2smooth = 0.05

Definition at line 303 of file cl_player.qc.

Referenced by CSQCPlayer_ApplyBobbing().

◆ autocvar_cl_bob_limit

float autocvar_cl_bob_limit = 7

Definition at line 294 of file cl_player.qc.

Referenced by CSQCPlayer_ApplyBobbing().

◆ autocvar_cl_bob_limit_heightcheck

float autocvar_cl_bob_limit_heightcheck = 0

Definition at line 295 of file cl_player.qc.

Referenced by CSQCPlayer_ApplyBobbing().

◆ autocvar_cl_bob_velocity_limit

float autocvar_cl_bob_velocity_limit = 400

Definition at line 296 of file cl_player.qc.

Referenced by CSQCPlayer_ApplyBobbing().

◆ autocvar_cl_bobcycle

float autocvar_cl_bobcycle = 0.5

Definition at line 293 of file cl_player.qc.

Referenced by CSQCPlayer_ApplyBobbing().

◆ autocvar_cl_bobfall

float autocvar_cl_bobfall = 0.05

Definition at line 298 of file cl_player.qc.

Referenced by CSQCPlayer_ApplyBobbing().

◆ autocvar_cl_bobfallcycle

float autocvar_cl_bobfallcycle = 3

Definition at line 299 of file cl_player.qc.

Referenced by CSQCPlayer_ApplyBobbing().

◆ autocvar_cl_bobfallminspeed

float autocvar_cl_bobfallminspeed = 200

Definition at line 300 of file cl_player.qc.

Referenced by CSQCPlayer_ApplyBobbing().

◆ autocvar_cl_bobup

float autocvar_cl_bobup = 0.5

Definition at line 297 of file cl_player.qc.

Referenced by CSQCPlayer_ApplyBobbing().

◆ autocvar_cl_movement_errorcompensation

float autocvar_cl_movement_errorcompensation = 0

Definition at line 29 of file cl_player.qc.

Referenced by CSQCPlayer_SetPredictionError().

◆ autocvar_cl_movement_intermissionrunning

bool autocvar_cl_movement_intermissionrunning = false

Definition at line 30 of file cl_player.qc.

Referenced by CSQCPlayer_SetCamera().

◆ autocvar_cl_rollangle

float autocvar_cl_rollangle

Definition at line 416 of file cl_player.qc.

Referenced by CSQCPlayer_CalcRoll().

◆ autocvar_cl_rollspeed

float autocvar_cl_rollspeed

Definition at line 417 of file cl_player.qc.

Referenced by CSQCPlayer_CalcRoll().

◆ autocvar_cl_smoothviewheight

float autocvar_cl_smoothviewheight = 0.05

Definition at line 214 of file cl_player.qc.

Referenced by CSQCPlayer_ApplySmoothing().

◆ autocvar_cl_stairsmoothspeed

float autocvar_cl_stairsmoothspeed = 200

Definition at line 213 of file cl_player.qc.

Referenced by CSQCModel_ApplyStairSmoothing(), and CSQCPlayer_ApplySmoothing().

◆ autocvar_cl_useenginerefdef

bool autocvar_cl_useenginerefdef = false

Definition at line 551 of file cl_player.qc.

Referenced by CSQCPlayer_SetCamera().

◆ autocvar_v_deathtilt

bool autocvar_v_deathtilt

Definition at line 266 of file cl_player.qc.

Referenced by CSQCPlayer_ApplyDeathTilt().

◆ autocvar_v_deathtiltangle

float autocvar_v_deathtiltangle

Definition at line 267 of file cl_player.qc.

Referenced by CSQCPlayer_ApplyDeathTilt().

◆ autocvar_v_idlescale

float autocvar_v_idlescale

Definition at line 275 of file cl_player.qc.

Referenced by CSQCPlayer_ApplyIdleScaling().

◆ autocvar_v_ipitch_cycle

float autocvar_v_ipitch_cycle

Definition at line 276 of file cl_player.qc.

Referenced by CSQCPlayer_ApplyIdleScaling().

◆ autocvar_v_ipitch_level

float autocvar_v_ipitch_level

Definition at line 279 of file cl_player.qc.

Referenced by CSQCPlayer_ApplyIdleScaling().

◆ autocvar_v_iroll_cycle

float autocvar_v_iroll_cycle

Definition at line 278 of file cl_player.qc.

Referenced by CSQCPlayer_ApplyIdleScaling().

◆ autocvar_v_iroll_level

float autocvar_v_iroll_level

Definition at line 281 of file cl_player.qc.

Referenced by CSQCPlayer_ApplyIdleScaling().

◆ autocvar_v_iyaw_cycle

float autocvar_v_iyaw_cycle

Definition at line 277 of file cl_player.qc.

Referenced by CSQCPlayer_ApplyIdleScaling().

◆ autocvar_v_iyaw_level

float autocvar_v_iyaw_level

Definition at line 280 of file cl_player.qc.

Referenced by CSQCPlayer_ApplyIdleScaling().

◆ bob2_smooth

float bob2_smooth

Definition at line 306 of file cl_player.qc.

Referenced by CSQCPlayer_ApplyBobbing().

◆ bobfall_speed

float bobfall_speed

Definition at line 305 of file cl_player.qc.

Referenced by CSQCPlayer_ApplyBobbing().

◆ bobfall_swing

float bobfall_swing

Definition at line 304 of file cl_player.qc.

Referenced by CSQCPlayer_ApplyBobbing().

◆ csqcplayer_moveframe

float csqcplayer_moveframe

Definition at line 38 of file cl_player.qc.

Referenced by CSQCPlayer_PredictTo(), and CSQCPlayer_Unpredict().

◆ csqcplayer_origin

vector csqcplayer_origin

Definition at line 35 of file cl_player.qc.

Referenced by CSQCPlayer_SavePrediction(), and CSQCPlayer_Unpredict().

◆ csqcplayer_predictionerrorfactor

float csqcplayer_predictionerrorfactor

◆ csqcplayer_predictionerroro

vector csqcplayer_predictionerroro

Definition at line 39 of file cl_player.qc.

Referenced by CSQCPlayer_GetPredictionErrorO(), and CSQCPlayer_SetPredictionError().

◆ csqcplayer_predictionerrortime

float csqcplayer_predictionerrortime

◆ csqcplayer_predictionerrorv

vector csqcplayer_predictionerrorv

Definition at line 40 of file cl_player.qc.

Referenced by CSQCPlayer_GetPredictionErrorV(), and CSQCPlayer_SetPredictionError().

◆ csqcplayer_sequence

float csqcplayer_sequence

Definition at line 36 of file cl_player.qc.

Referenced by CSQCPlayer_SavePrediction(), and CSQCPlayer_Unpredict().

◆ csqcplayer_velocity

vector csqcplayer_velocity

Definition at line 35 of file cl_player.qc.

Referenced by CSQCPlayer_SavePrediction(), and CSQCPlayer_Unpredict().

◆ player_pmflags

int player_pmflags

Definition at line 37 of file cl_player.qc.

Referenced by CSQCPlayer_SavePrediction(), and CSQCPlayer_Unpredict().

◆ pmove_onground

float pmove_onground

Definition at line 33 of file cl_player.qc.

Referenced by CSQCPlayer_SetCamera().

◆ smooth_prevtime

float smooth_prevtime

Definition at line 215 of file cl_player.qc.

Referenced by CSQCPlayer_ApplySmoothing().

◆ stairsmooth_drawtime

float stairsmooth_drawtime

Definition at line 244 of file cl_player.qc.

Referenced by CSQCModel_ApplyStairSmoothing().

◆ stairsmooth_offset

float stairsmooth_offset

Definition at line 242 of file cl_player.qc.

Referenced by CSQCModel_ApplyStairSmoothing().

◆ stairsmooth_prevtime

float stairsmooth_prevtime

Definition at line 243 of file cl_player.qc.

Referenced by CSQCModel_ApplyStairSmoothing().

◆ stairsmoothz

float stairsmoothz

Definition at line 212 of file cl_player.qc.

Referenced by CSQCPlayer_ApplySmoothing().

◆ viewheightavg

float viewheightavg

Definition at line 216 of file cl_player.qc.

Referenced by CSQCPlayer_ApplySmoothing().