X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcsqcmodellib%2Fcl_player.qc;h=2711867dbc445cb68f9930c4a81600d9d3601d14;hb=e557ad1d2eaf0e18be5931c5548049aa4cfecb39;hp=40ba3f7a9f73c4d0a283dc6578b54a396211f00e;hpb=48a9eb74e54b8e703797522a2591c65d19596915;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/csqcmodellib/cl_player.qc b/qcsrc/csqcmodellib/cl_player.qc index 40ba3f7a9..2711867db 100644 --- a/qcsrc/csqcmodellib/cl_player.qc +++ b/qcsrc/csqcmodellib/cl_player.qc @@ -20,18 +20,13 @@ * IN THE SOFTWARE. */ -var float autocvar_cl_predictionerrorcompensation = 0; +var float autocvar_cl_movement_errorcompensation = 0; // engine stuff -.float pmove_flags; -float pmove_onground; // weird engine flag we shouldn't really use but have to for now -#define PMF_JUMP_HELD 1 -#define PMF_DUCKED 4 -#define PMF_ONGROUND 8 #define REFDEFFLAG_TELEPORTED 1 #define REFDEFFLAG_JUMPING 2 +float pmove_onground; // weird engine flag we shouldn't really use but have to for now -entity csqcplayer; vector csqcplayer_origin, csqcplayer_velocity; float csqcplayer_sequence, player_pmflags; float csqcplayer_moveframe; @@ -54,23 +49,36 @@ vector CSQCPlayer_GetPredictionErrorV() return csqcplayer_predictionerrorv * (csqcplayer_predictionerrortime - time) * csqcplayer_predictionerrorfactor; } -void CSQCPlayer_SetPredictionError(vector o, vector v) +void CSQCPlayer_SetPredictionError(vector o, vector v, float onground_diff) { - if(!autocvar_cl_predictionerrorcompensation) + // error too big to compensate, we LIKELY hit a teleport or a + // jumppad, or it's a jump time disagreement that'll get fixed + // next frame + + // FIXME we sometimes have disagreement in order of jump velocity. Do not act on them! + /* + // commented out as this one did not help + if(onground_diff) { - csqcplayer_predictionerrorfactor = 0; + print(sprintf("ONGROUND MISMATCH: %d x=%v v=%v\n", onground_diff, o, v)); + return; + } + */ + if(vlen(o) > 32 || vlen(v) > 192) + { + //print(sprintf("TOO BIG: x=%v v=%v\n", o, v)); return; } - // error too big to compensate, we LIKELY hit a teleport or a - // jumppad, or it's a jump time disagreement that'll get fixed - // next frame - if(vlen(o) > 32 || vlen(v) > 128) + if(!autocvar_cl_movement_errorcompensation) + { + csqcplayer_predictionerrorfactor = 0; return; + } csqcplayer_predictionerroro = CSQCPlayer_GetPredictionErrorO() + o; csqcplayer_predictionerrorv = CSQCPlayer_GetPredictionErrorV() + v; - csqcplayer_predictionerrorfactor = autocvar_cl_predictionerrorcompensation / ticrate; + csqcplayer_predictionerrorfactor = autocvar_cl_movement_errorcompensation / ticrate; csqcplayer_predictionerrortime = time + 1.0 / csqcplayer_predictionerrorfactor; } @@ -123,8 +131,9 @@ void CSQCPlayer_PredictTo(float endframe, float apply_error) csqcplayer_status = CSQCPLAYERSTATUS_PREDICTED; - // FIXME do we really NEED this? dead players have servercommandframe - // == 0 and thus won't predict +#if 0 + // we don't need this + // darkplaces makes servercommandframe == 0 in these cases anyway if (getstatf(STAT_HEALTH) <= 0) { csqcplayer_moveframe = clientcommandframe; @@ -132,6 +141,7 @@ void CSQCPlayer_PredictTo(float endframe, float apply_error) print("the Weird code path got hit\n"); return; } +#endif if(csqcplayer_moveframe >= endframe) { @@ -203,6 +213,11 @@ void CSQCPlayer_SetCamera() } else { + float flg = self.iflags; + self.iflags &~= IFLAG_ORIGIN | IFLAG_ANGLES; + InterpolateOrigin_Do(); + self.iflags = flg; + if(csqcplayer_status == CSQCPLAYERSTATUS_FROMSERVER) { vector o, v; @@ -210,7 +225,7 @@ void CSQCPlayer_SetCamera() v = v0; csqcplayer_status = CSQCPLAYERSTATUS_PREDICTED; CSQCPlayer_PredictTo(servercommandframe + 1, FALSE); - CSQCPlayer_SetPredictionError(self.origin - o, self.velocity - v); + CSQCPlayer_SetPredictionError(self.origin - o, self.velocity - v, pmove_onground - !!(self.pmove_flags & PMF_ONGROUND)); self.origin = o; self.velocity = v; @@ -230,6 +245,14 @@ void CSQCPlayer_SetCamera() } CSQCPlayer_PredictTo(clientcommandframe + 1, TRUE); +#ifdef CSQCMODEL_SERVERSIDE_CROUCH + // get crouch state from the server (LAG) + if(getstati(STAT_VIEWHEIGHT) == PL_VIEW_OFS_z) + self.pmove_flags &~= PMF_DUCKED; + else if(getstati(STAT_VIEWHEIGHT) == PL_CROUCH_VIEW_OFS_z) + self.pmove_flags |= PMF_DUCKED; +#endif + CSQCPlayer_SetMinsMaxs(); self.angles_y = input_angles_y;