X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Flib%2Fcsqcmodel%2Fcl_player.qc;h=66613b53229ad6ef53d34a9ad43bc0b0ed413abd;hb=b0a563c3658ec620ddb9037b9417b743a47002a5;hp=e0eaccae11f957539f2d42f565b911482da16d89;hpb=bda4e58210275f23266f9a1231de949b6bc64893;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/lib/csqcmodel/cl_player.qc b/qcsrc/lib/csqcmodel/cl_player.qc index e0eaccae1..66613b532 100644 --- a/qcsrc/lib/csqcmodel/cl_player.qc +++ b/qcsrc/lib/csqcmodel/cl_player.qc @@ -25,16 +25,18 @@ #include "cl_model.qh" #include "common.qh" #include "interpolate.qh" -#include "../../client/defs.qh" -#include "../../client/main.qh" -#include "../../common/constants.qh" -#include "../../common/physics.qh" -#include "../../common/stats.qh" -#include "../../common/triggers/trigger/viewloc.qh" -#include "../../common/util.qh" -#include "../../common/viewloc.qh" +#include +#include +#include +#include +#include +#include +#include +#include +#include float autocvar_cl_movement_errorcompensation = 0; +bool autocvar_cl_movement_intermissionrunning = false; // engine stuff float pmove_onground; // weird engine flag we shouldn't really use but have to for now @@ -75,7 +77,7 @@ void CSQCPlayer_SetPredictionError(vector o, vector v, float onground_diff) return; } */ - if(vlen(o) > 32 || vlen(v) > 192) + if(vdist(o, >, 32) || vdist(v, >, 192)) { //printf("TOO BIG: x=%v v=%v\n", o, v); return; @@ -96,7 +98,7 @@ void CSQCPlayer_SetPredictionError(vector o, vector v, float onground_diff) void CSQCPlayer_Unpredict(entity this) { if (csqcplayer_status == CSQCPLAYERSTATUS_UNPREDICTED) return; - if (csqcplayer_status != CSQCPLAYERSTATUS_PREDICTED) LOG_FATALF("Cannot unpredict in current status (%d)\n", csqcplayer_status); + if (csqcplayer_status != CSQCPLAYERSTATUS_PREDICTED) LOG_FATALF("Cannot unpredict in current status (%d)", csqcplayer_status); this.origin = csqcplayer_origin; this.velocity = csqcplayer_velocity; csqcplayer_moveframe = csqcplayer_sequence + 1; // + 1 because the recieved frame has the move already done (server side) @@ -105,17 +107,17 @@ void CSQCPlayer_Unpredict(entity this) void CSQCPlayer_SetMinsMaxs(entity this) { - if (this.flags & FL_DUCKED) + if (IS_DUCKED(this) || !this.isplayermodel) { - this.mins = PL_CROUCH_MIN; - this.maxs = PL_CROUCH_MAX; - this.view_ofs = PL_CROUCH_VIEW_OFS; + this.mins = STAT(PL_CROUCH_MIN, NULL); + this.maxs = STAT(PL_CROUCH_MAX, NULL); + this.view_ofs = STAT(PL_CROUCH_VIEW_OFS, NULL); } else { - this.mins = PL_MIN; - this.maxs = PL_MAX; - this.view_ofs = PL_VIEW_OFS; + this.mins = STAT(PL_MIN, NULL); + this.maxs = STAT(PL_MAX, NULL); + this.view_ofs = STAT(PL_VIEW_OFS, NULL); } } @@ -129,36 +131,31 @@ void CSQCPlayer_SavePrediction(entity this) } void CSQC_ClientMovement_PlayerMove_Frame(entity this); -void _Movetype_Physics_Frame(entity this, float movedt); -void Movetype_Physics_Spam(entity this) // optimized +void CSQCPlayer_Physics(entity this) { - _Movetype_Physics_Frame(this, PHYS_INPUT_TIMELENGTH); - if(wasfreed(this)) - return; + if(!autocvar_cl_movement) { return; } - this.avelocity = this.move_avelocity; - this.velocity = this.move_velocity; - this.angles = this.move_angles; - setorigin(this, this.move_origin); -} + _Movetype_CheckWater(this); // we apparently need to check water *before* physics so it can use this for water jump -void CSQCPlayer_Physics(entity this) -{ - if(autocvar_cl_movement) - { - CSQC_ClientMovement_PlayerMove_Frame(this); + vector oldv_angle = this.v_angle; + vector oldangles = this.angles; // we need to save these, as they're abused by other code + this.v_angle = PHYS_INPUT_ANGLES(this); + this.angles = PHYS_WORLD_ANGLES(this); - if(autocvar_cl_movement == 3) - { - this.move_origin = this.origin; - this.move_angles = this.angles; - this.move_movetype = MOVETYPE_WALK; // temp - this.move_velocity = this.velocity; - this.move_avelocity = this.avelocity; - Movetype_Physics_Spam(this); - } - } + CSQC_ClientMovement_PlayerMove_Frame(this); + + Movetype_Physics_NoMatchTicrate(this, PHYS_INPUT_TIMELENGTH, true); + + view_angles = this.v_angle; + input_angles = this.angles; + this.v_angle = oldv_angle; + this.angles = oldangles; + + this.pmove_flags = + ((IS_DUCKED(this)) ? PMF_DUCKED : 0) | + ((IS_JUMP_HELD(this)) ? PMF_JUMP_HELD : 0) | + ((IS_ONGROUND(this)) ? PMF_ONGROUND : 0); } void CSQCPlayer_PredictTo(entity this, float endframe, bool apply_error) @@ -176,7 +173,7 @@ void CSQCPlayer_PredictTo(entity this, float endframe, bool apply_error) #if 0 // we don't need this // darkplaces makes servercommandframe == 0 in these cases anyway - if (getstatf(STAT_HEALTH) <= 0) + if (STAT(HEALTH) <= 0) { csqcplayer_moveframe = clientcommandframe; getinputstate(csqcplayer_moveframe-1); @@ -194,6 +191,15 @@ void CSQCPlayer_PredictTo(entity this, float endframe, bool apply_error) do { if (!getinputstate(csqcplayer_moveframe)) break; + /*if (input_timelength > 0.0005) + { + if (input_timelength > 0.05) + { + input_timelength /= 2; + CSQCPlayer_Physics(this); + } + CSQCPlayer_Physics(this); + }*/ CSQCPlayer_Physics(this); CSQCPlayer_SetMinsMaxs(this); ++csqcplayer_moveframe; @@ -218,10 +224,10 @@ void CSQCPlayer_SetViewLocation() /** Called once per CSQC_UpdateView() */ void CSQCPlayer_SetCamera() { - const vector v0 = pmove_vel; // TRICK: pmove_vel is set by the engine when we get here. No need to network velocity - const float vh = getstati(STAT_VIEWHEIGHT); - const vector pl_viewofs = PL_VIEW_OFS; - const vector pl_viewofs_crouch = PL_CROUCH_VIEW_OFS; + const 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 + const float vh = STAT(VIEWHEIGHT); + const vector pl_viewofs = STAT(PL_VIEW_OFS, NULL); + const vector pl_viewofs_crouch = STAT(PL_CROUCH_VIEW_OFS, NULL); const entity e = csqcplayer; if (e) { @@ -256,7 +262,7 @@ void CSQCPlayer_SetCamera() const vector o = e.origin; csqcplayer_status = CSQCPLAYERSTATUS_PREDICTED; CSQCPlayer_PredictTo(e, servercommandframe + 1, false); - CSQCPlayer_SetPredictionError(e.origin - o, e.velocity - v0, pmove_onground - boolean(e.flags & FL_ONGROUND)); + CSQCPlayer_SetPredictionError(e.origin - o, e.velocity - v0, pmove_onground - IS_ONGROUND(e)); e.origin = o; e.velocity = v0; @@ -297,7 +303,7 @@ void CSQCPlayer_SetCamera() if (view.csqcmodel_teleported) refdefflags |= REFDEFFLAG_TELEPORTED; if (input_buttons & BIT(1)) refdefflags |= REFDEFFLAG_JUMPING; // note: these two only work in WIP2, but are harmless in WIP1 - if (getstati(STAT_HEALTH) <= 0) refdefflags |= REFDEFFLAG_DEAD; + if (STAT(HEALTH) <= 0 && STAT(HEALTH) != -666 && STAT(HEALTH) != -2342) refdefflags |= REFDEFFLAG_DEAD; if (intermission) refdefflags |= REFDEFFLAG_INTERMISSION; V_CalcRefdef(view, refdefflags); } @@ -313,7 +319,7 @@ void CSQCPlayer_SetCamera() CSQCPLAYER_HOOK_POSTCAMERASETUP(); } -void CSQCPlayer_Remove() +void CSQCPlayer_Remove(entity this) { csqcplayer = NULL; cvar_settemp("cl_movement_replay", "1");