Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
cl_player.qh File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

vector CSQCModel_ApplyStairSmoothing (entity this, bool isonground, vector v)
float CSQCPlayer_IsLocalPlayer (entity this)
float CSQCPlayer_PostUpdate (entity this)
float CSQCPlayer_PreUpdate (entity this)
void CSQCPlayer_SetCamera ()
 Called once per CSQC_UpdateView()

Variables

bool autocvar_cl_movement = true
entity csqcplayer
float csqcplayer_status
const int CSQCPLAYERSTATUS_FROMSERVER = 1
const int CSQCPLAYERSTATUS_PREDICTED = 2
const int CSQCPLAYERSTATUS_UNPREDICTED = 0
const int PMF_JUMP_HELD = 1
int pmove_flags
bool use_engine_refdef

Function Documentation

◆ CSQCModel_ApplyStairSmoothing()

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

Definition at line 248 of file cl_player.qc.

249{
250 float smoothtime = bound(0, time - this.stairsmooth_prevtime, 0.1);
251 this.stairsmooth_prevtime = max(this.stairsmooth_prevtime, this.stairsmooth_drawtime); // stairsmooth_drawtime is the previous frame's time at this point
252
253 if(this.csqcmodel_teleported || !isonground || autocvar_cl_stairsmoothspeed <= 0 || this.ground_networkentity)
254 this.stairsmooth_offset = v.z;
255 else
256 {
257 if(this.stairsmooth_offset < v.z)
258 v.z = this.stairsmooth_offset = bound(v.z - PHYS_STEPHEIGHT(this), this.stairsmooth_offset + smoothtime * autocvar_cl_stairsmoothspeed, v.z);
259 else if(this.stairsmooth_offset > v.z)
260 v.z = this.stairsmooth_offset = bound(v.z, this.stairsmooth_offset - smoothtime * autocvar_cl_stairsmoothspeed, v.z + PHYS_STEPHEIGHT(this));
261 }
262
265
266 return v;
267}
float csqcmodel_teleported
Definition cl_model.qh:39
float stairsmooth_prevtime
Definition cl_player.qc:246
float autocvar_cl_stairsmoothspeed
Definition cl_player.qc:216
float stairsmooth_drawtime
Definition cl_player.qc:247
float stairsmooth_offset
Definition cl_player.qc:245
float time
float ground_networkentity
float bound(float min, float value, float max)
float max(float f,...)
#define PHYS_STEPHEIGHT(s)
Definition movetypes.qh:38
float drawtime
Definition view.qh:119

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

Referenced by CSQCModel_Hook_PreDraw(), and CSQCPlayer_SetCamera().

◆ CSQCPlayer_IsLocalPlayer()

float CSQCPlayer_IsLocalPlayer ( entity this)

Definition at line 210 of file cl_player.qc.

211{
212 return (this == csqcplayer);
213}
entity csqcplayer
Definition cl_player.qh:26

References csqcplayer, and entity().

Referenced by CSQCModel_Draw().

◆ CSQCPlayer_PostUpdate()

float CSQCPlayer_PostUpdate ( entity this)

Definition at line 680 of file cl_player.qc.

681{
682 if (this.entnum != player_localnum + 1) return false;
683 csqcplayer = this;
685 if (cvar("cl_movement_replay"))
686 cvar_settemp("cl_movement_replay", "0");
687 this.entremove = CSQCPlayer_Remove;
688 return true;
689}
void CSQCPlayer_Remove(entity this)
Definition cl_player.qc:667
const int CSQCPLAYERSTATUS_FROMSERVER
Definition cl_player.qh:29
float csqcplayer_status
Definition cl_player.qh:27
float cvar_settemp(string tmp_cvar, string tmp_value)
Definition util.qc:811
float player_localnum
float entnum
float cvar(string name)

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

Referenced by NET_HANDLE().

◆ CSQCPlayer_PreUpdate()

float CSQCPlayer_PreUpdate ( entity this)

Definition at line 673 of file cl_player.qc.

674{
675 if (this != csqcplayer) return false;
677 return true;
678}
void CSQCPlayer_Unpredict(entity this)
Definition cl_player.qc:89

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

Referenced by NET_HANDLE().

◆ CSQCPlayer_SetCamera()

void CSQCPlayer_SetCamera ( )

Called once per CSQC_UpdateView()

Definition at line 573 of file cl_player.qc.

574{
575 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
576 float vh = PHYS_VIEWHEIGHT(NULL);
577 vector pl_viewofs = PHYS_PL_VIEWOFS(NULL);
578 vector pl_viewofs_crouch = PHYS_PL_CROUCH_VIEWOFS(NULL);
579 entity e = csqcplayer;
580 if (e)
581 {
582 if (servercommandframe == 0 || clientcommandframe == 0)
583 {
585 e.view_ofs = '0 0 1' * vh;
586
587 // get crouch state from the server
588 if (vh == pl_viewofs.z) e.flags &= ~FL_DUCKED;
589 else if (vh == pl_viewofs_crouch.z) e.flags |= FL_DUCKED;
590
591 // get onground state from the server
592 e.flags = BITSET(e.flags, FL_ONGROUND, pmove_onground);
593
595
596 // override it back just in case
597 e.view_ofs = '0 0 1' * vh;
598
599 // set velocity
600 e.velocity = v0;
601 }
602 else
603 {
604 int flg = e.iflags; e.iflags &= ~(IFLAG_ORIGIN | IFLAG_ANGLES);
606 e.iflags = flg;
607
609 {
610 vector o = e.origin;
613 CSQCPlayer_SetPredictionError(e.origin - o, e.velocity - v0, pmove_onground - IS_ONGROUND(e));
614 e.origin = o;
615 e.velocity = v0;
616
617 // get crouch state from the server
618 if (vh == pl_viewofs.z) e.flags &= ~FL_DUCKED;
619 else if(vh == pl_viewofs_crouch.z) e.flags |= FL_DUCKED;
620
621 // get onground state from the server
622 e.flags = BITSET(e.flags, FL_ONGROUND, pmove_onground);
623
625 }
627
628#ifdef CSQCMODEL_SERVERSIDE_CROUCH
629 // get crouch state from the server (LAG)
630 if (vh == pl_viewofs.z) e.flags &= ~FL_DUCKED;
631 else if (vh == pl_viewofs_crouch.z) e.flags |= FL_DUCKED;
632#endif
634
635 if (!IS_DEAD(e))
636 e.angles.y = input_angles.y;
637 }
638
639 // relink
640 e.stairsmooth_drawtime = drawtime; // since drawtime is a frame old at this point, copy it now to avoid using a drawtime 2 frames old!
641 e.origin = CSQCModel_ApplyStairSmoothing(e, (e.pmove_flags & PMF_ONGROUND), e.origin);
642 setorigin(e, e.origin);
643 }
644
646 if (view)
647 {
648 if (view != csqcplayer)
649 {
651 view.view_ofs = '0 0 1' * vh;
652 }
654 }
655 else
656 {
657 // FIXME by CSQC spec we have to do this:
658 // but it breaks chase cam
659 /*
660 setproperty(VF_ORIGIN, pmove_org + '0 0 1' * vh);
661 setproperty(VF_ANGLES, view_angles);
662 */
663 }
665}
#define BITSET(var, mask, flag)
Definition bits.qh:11
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
float pmove_onground
Definition cl_player.qc:33
void CSQCPlayer_SetPredictionError(vector o, vector v, float onground_diff)
Definition cl_player.qc:56
bool autocvar_cl_movement_intermissionrunning
Definition cl_player.qc:30
vector CSQCModel_ApplyStairSmoothing(entity this, bool isonground, vector v)
Definition cl_player.qc:248
void CSQCPlayer_CalcRefdef(entity this)
Definition cl_player.qc:530
void CSQCPlayer_PredictTo(entity this, float endframe, bool apply_error)
Definition cl_player.qc:157
void CSQCPlayer_SavePrediction(entity this)
Definition cl_player.qc:120
void CSQCPlayer_SetMinsMaxs(entity this)
Definition cl_player.qc:99
const int CSQCPLAYERSTATUS_PREDICTED
Definition cl_player.qh:30
#define PHYS_PL_CROUCH_VIEWOFS(s)
Definition player.qh:89
#define IS_DEAD(s)
Definition player.qh:245
#define PHYS_PL_VIEWOFS(s)
Definition player.qh:88
#define PHYS_VIEWHEIGHT(s)
Definition player.qh:91
const int FL_ONGROUND
Definition constants.qh:78
const int FL_DUCKED
Definition constants.qh:89
float clientcommandframe
vector pmove_vel
vector input_angles
float player_localentnum
float intermission
float PMF_ONGROUND
float servercommandframe
#define CSQCPLAYER_HOOK_POSTCAMERASETUP()
entity CSQCModel_server2csqc(int i)
Definition cl_model.qc:314
void InterpolateOrigin_Do(entity this)
set origin based on iorigin1 (old pos), iorigin2 (desired pos), and time
const int IFLAG_ANGLES
const int IFLAG_ORIGIN
#define IS_ONGROUND(s)
Definition movetypes.qh:16
#define NULL
Definition post.qh:14
vector
Definition self.qh:92

References autocvar_cl_movement_intermissionrunning, 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_DUCKED, FL_ONGROUND, IFLAG_ANGLES, IFLAG_ORIGIN, input_angles, intermission, InterpolateOrigin_Do(), IS_DEAD, IS_ONGROUND, NULL, PHYS_PL_CROUCH_VIEWOFS, PHYS_PL_VIEWOFS, PHYS_VIEWHEIGHT, player_localentnum, PMF_ONGROUND, pmove_onground, pmove_vel, servercommandframe, and vector.

Referenced by CSQC_UpdateView().

Variable Documentation

◆ autocvar_cl_movement

bool autocvar_cl_movement = true

Definition at line 24 of file cl_player.qh.

Referenced by CSQCPlayer_Physics().

◆ csqcplayer

◆ csqcplayer_status

◆ CSQCPLAYERSTATUS_FROMSERVER

const int CSQCPLAYERSTATUS_FROMSERVER = 1

Definition at line 29 of file cl_player.qh.

Referenced by CSQCPlayer_PostUpdate(), CSQCPlayer_PreUpdate(), and CSQCPlayer_SetCamera().

◆ CSQCPLAYERSTATUS_PREDICTED

const int CSQCPLAYERSTATUS_PREDICTED = 2

◆ CSQCPLAYERSTATUS_UNPREDICTED

const int CSQCPLAYERSTATUS_UNPREDICTED = 0

Definition at line 28 of file cl_player.qh.

Referenced by CSQCPlayer_Unpredict().

◆ PMF_JUMP_HELD

const int PMF_JUMP_HELD = 1

Definition at line 36 of file cl_player.qh.

Referenced by CSQCPlayer_Physics().

◆ pmove_flags

int pmove_flags

Definition at line 35 of file cl_player.qh.

Referenced by CSQCPlayer_ApplySmoothing(), and CSQCPlayer_Physics().

◆ use_engine_refdef

bool use_engine_refdef

Definition at line 32 of file cl_player.qh.

Referenced by CSQCPlayer_CalcRefdef().