]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge some changes from prediction branch
authorMario <zacjardine@y7mail.com>
Mon, 16 Mar 2015 14:09:17 +0000 (01:09 +1100)
committerMario <zacjardine@y7mail.com>
Mon, 16 Mar 2015 14:09:17 +0000 (01:09 +1100)
qcsrc/client/autocvars.qh
qcsrc/client/csqcmodel_hooks.qc
qcsrc/common/physics.qc
qcsrc/common/physics.qh
qcsrc/csqcmodellib/cl_player.qc
qcsrc/csqcmodellib/cl_player.qh

index 871ac8cdc12fee0018412b335dc68560c3996228..e35bf82dd2759122afc2cf11d46707ef5fc1177b 100644 (file)
@@ -469,5 +469,4 @@ vector autocvar_crosshair_rpc_color = '0.2 1.0 0.2';
 float autocvar_crosshair_rpc_alpha = 1;
 float autocvar_crosshair_rpc_size = 1;
 int autocvar_cl_nade_timer;
-float autocvar_speedmeter;
 #endif
index dde4461821ee9feef7e501d25961931082a79028..f1a8f649f7af532c60cf4c76f5c0752497651663 100644 (file)
@@ -657,10 +657,10 @@ void CSQCModel_Hook_PreDraw(bool isplayer)
                        bool onground = 0;
                        if(self == csqcplayer)
                        {
-                               if(self.pmove_flags & PMF_ONGROUND)
+                               if(self.flags & FL_ONGROUND)
                                        onground = 1;
-                               self.anim_prev_pmove_flags = self.pmove_flags;
-                               if(self.pmove_flags & PMF_DUCKED)
+                               self.anim_prev_pmove_flags = self.flags;
+                               if(self.flags & FL_DUCKED)
                                        animdecide_setstate(self, self.anim_state | ANIMSTATE_DUCK, false);
                                else if(self.anim_state & ANIMSTATE_DUCK)
                                        animdecide_setstate(self, self.anim_state - ANIMSTATE_DUCK, false);
index ad5bc16c1888ccf092590191a91dcfa929130288..728863ad44b22b7cafd102442a96c3f4b03aa67a 100644 (file)
@@ -494,16 +494,20 @@ float PlayerJump (void)
 
        if (!WAS_ONGROUND(self))
        {
+#ifdef SVQC
                if(autocvar_speedmeter)
                        dprint(strcat("landing velocity: ", vtos(self.velocity), " (abs: ", ftos(vlen(self.velocity)), ")\n"));
+#endif
                if(self.lastground < time - 0.3)
                {
                        self.velocity_x *= (1 - PHYS_FRICTION_ONLAND);
                        self.velocity_y *= (1 - PHYS_FRICTION_ONLAND);
                }
+#ifdef SVQC
                if(self.jumppadcount > 1)
                        dprint(strcat(ftos(self.jumppadcount), "x jumppad combo\n"));
                self.jumppadcount = 0;
+#endif
        }
 
        self.velocity_z += mjumpheight;
@@ -542,11 +546,9 @@ void CheckWaterJump()
                if (trace_fraction == 1)
                {       // open at eye level
                        self.velocity_z = 225;
-#ifdef SVQC
                        self.flags |= FL_WATERJUMP;
                        SET_JUMP_HELD(self);
                        self.teleport_time = time + 2;  // safety net
-#endif
                }
        }
 }
@@ -567,20 +569,14 @@ void CheckPlayerJump()
        float was_flying = ITEMS(self) & IT_USING_JETPACK;
 #endif
        if (JETPACK_JUMP(self) < 2)
-#ifdef SVQC
                ITEMS(self) &= ~IT_USING_JETPACK;
-#endif
 
        if(PHYS_INPUT_BUTTON_JUMP(self) || PHYS_INPUT_BUTTON_JETPACK(self))
        {
-#ifdef SVQC
                float air_jump = !PlayerJump() || self.multijump_count > 0; // PlayerJump() has important side effects
                float activate = JETPACK_JUMP(self) && air_jump && PHYS_INPUT_BUTTON_JUMP(self) || PHYS_INPUT_BUTTON_JETPACK(self);
-               float has_fuel = !autocvar_g_jetpack_fuel || self.ammo_fuel || ITEMS(self) & IT_UNLIMITED_WEAPON_AMMO;
-#else
-               PlayerJump(); // Client only
-               float has_fuel = true; // TODO
-#endif
+               float has_fuel = !PHYS_JETPACK_FUEL || PHYS_AMMO_FUEL(self) || ITEMS(self) & IT_UNLIMITED_WEAPON_AMMO;
+
                if (!(ITEMS(self) & IT_JETPACK)) { }
                else if (self.jetpack_stopped) { }
                else if (!has_fuel)
@@ -592,21 +588,15 @@ void CheckPlayerJump()
                                Send_Notification(NOTIF_ONE, self, MSG_INFO, INFO_JETPACK_NOFUEL);
 #endif
                        self.jetpack_stopped = true;
-#ifdef SVQC
                        ITEMS(self) &= ~IT_USING_JETPACK;
-#endif
                }
-#ifdef SVQC
                else if (activate && !PHYS_FROZEN(self))
                        ITEMS(self) |= IT_USING_JETPACK;
-#endif
        }
        else
        {
                self.jetpack_stopped = false;
-#ifdef SVQC
                ITEMS(self) &= ~IT_USING_JETPACK;
-#endif
        }
        if (!PHYS_INPUT_BUTTON_JUMP(self))
                UNSET_JUMP_HELD(self);
@@ -1349,196 +1339,24 @@ void PM_jetpack(float maxspd_mod)
                        self.velocity_z -= g * 0.5;
 #endif
 }
-#ifdef SVQC
-void SV_WalkMove ()
-{
-       // if PHYS_INPUT_TIMELENGTH is 0 (due to client sending the same timestamp twice),
-       // don't move
-       if (PHYS_INPUT_TIMELENGTH <= 0)
-               return;
-
-//     if (autocvar_sv_gameplayfix_unstickplayers)
-//             SV_CheckStuck (self);
-
-//     applygravity = !SV_CheckWater(self) && self.movetype == MOVETYPE_WALK && !(self.flags & FL_WATERJUMP);
-
-//     hitsupercontentsmask = SV_GenericHitSuperContentsMask(self);
-
-//     SV_CheckVelocity(self);
-
-       // do a regular slide move unless it looks like you ran into a step
-//     float oldonground = self.flags & FL_ONGROUND;
-
-       vector start_origin = self.origin;
-       vector start_velocity = self.velocity;
-
-       float clip = 0;
-//     clip = SV_FlyMove (self, PHYS_INPUT_TIMELENGTH, applygravity, NULL, hitsupercontentsmask, sv_gameplayfix_stepmultipletimes.integer ? sv_stepheight.value : 0);
-
-//     if(sv_gameplayfix_downtracesupportsongroundflag.integer)
-//     if(!(clip & 1))
-       {
-               // only try this if there was no floor in the way in the trace (no,
-               // this check seems to be not REALLY necessary, because if clip & 1,
-               // our trace will hit that thing too)
-               vector upmove = self.origin;
-               upmove_z++;
-               vector downmove = self.origin;
-               upmove_z--;
-               float type;
-               if (self.movetype == MOVETYPE_FLYMISSILE)
-                       type = MOVE_MISSILE;
-               else if (self.movetype == MOVETYPE_FLY_WORLDONLY)
-                       type = MOVE_WORLDONLY;
-               else if (self.solid == SOLID_TRIGGER || self.solid == SOLID_NOT)
-                       type = MOVE_NOMONSTERS; // only clip against bmodels
-               else
-                       type = MOVE_NORMAL;
-               vector entmins = self.mins;
-               vector entmaxs = self.maxs;
-               tracebox(upmove, entmins, entmaxs, downmove, type, self);
-               if(trace_fraction < 1 && trace_plane_normal_z > 0.7)
-                       clip |= 1; // but we HAVE found a floor
-       }
-
-       // if the move did not hit the ground at any point, we're not on ground
-//     if(!(clip & 1))
-//             self.flags = self.flags & ~FL_ONGROUND;
-
-//     SV_CheckVelocity(self);
-//     SV_LinkEdict(self);
-//     SV_LinkEdict_TouchAreaGrid(self);
-
-       if(clip & 8) // teleport
-               return;
-
-       if (self.flags & FL_WATERJUMP)
-               return;
-
-//     if (autocvar_sv_nostep)
-//             return;
-
-       vector originalmove_origin = self.origin;
-       vector originalmove_velocity = self.velocity;
-       float originalmove_flags = self.flags;
-       entity originalmove_groundentity = self.groundentity;
-
-       // if move didn't block on a step, return
-       if (clip & 2)
-       {
-               // if move was not trying to move into the step, return
-               if (fabs(start_velocity_x) < 0.03125 && fabs(start_velocity_y) < 0.03125)
-                       return;
-
-               if (self.movetype != MOVETYPE_FLY)
-               {
-                       // return if gibbed by a trigger
-                       if (self.movetype != MOVETYPE_WALK)
-                               return;
-
-                       // return if attempting to jump while airborn (unless sv_jumpstep)
-//                     if (!autocvar_sv_jumpstep)
-//                             if (!oldonground && PRVM_serveredictfloat(self, waterlevel) == 0)
-//                                     return;
-               }
-
-               // try moving up and forward to go up a step
-               // back to start pos
-               setorigin(self, start_origin);
-               self.velocity = start_velocity;
-
-               // move up
-               vector upmove = '0 0 0';
-               upmove_z = autocvar_sv_stepheight;
-//             if(!SV_PushEntity(&trace, self, upmove, true))
-//             {
-//                     // we got teleported when upstepping... must abort the move
-//                     return;
-//             }
-
-               // move forward
-               self.velocity_z = 0;
-//             clip = SV_FlyMove (self, PHYS_INPUT_TIMELENGTH, applygravity, stepnormal, hitsupercontentsmask, 0);
-               self.velocity_z += start_velocity_z;
-//             if(clip & 8)
-//             {
-//                     // we got teleported when upstepping... must abort the move
-//                     // note that z velocity handling may not be what QC expects here, but we cannot help it
-//                     return;
-//             }
-
-//             SV_CheckVelocity(self);
-//             SV_LinkEdict(self);
-//             SV_LinkEdict_TouchAreaGrid(self);
-
-               // check for stuckness, possibly due to the limited precision of floats
-               // in the clipping hulls
-               if (clip
-                && fabs(originalmove_origin_y - self.origin_y < 0.03125)
-                && fabs(originalmove_origin_x - self.origin_x < 0.03125))
-               {
-                       //Con_Printf("wall\n");
-                       // stepping up didn't make any progress, revert to original move
-                       setorigin(self, originalmove_origin);
-                       self.velocity = originalmove_velocity;
-                       self.flags = originalmove_flags;
-                       self.groundentity = originalmove_groundentity;
-                       return;
-               }
-
-               //Con_Printf("step - ");
-
-               // extra friction based on view angle
-//             if (clip & 2 && sv_wallfriction.integer)
-//                     SV_WallFriction (self, stepnormal);
-       }
-       // don't do the down move if stepdown is disabled, moving upward, not in water, or the move started offground or ended onground
-//     else if (!autocvar_sv_gameplayfix_stepdown || self.waterlevel >= 3 || start_velocity_z >= (1.0 / 32.0) || !oldonground || (self.flags & FL_ONGROUND))
-//             return;
 
-       // move down
-       vector downmove = '0 0 0';
-       downmove_z = -autocvar_sv_stepheight + start_velocity_z*PHYS_INPUT_TIMELENGTH;
-//     if(!SV_PushEntity (&downtrace, self, downmove, true))
-//     {
-//             // we got teleported when downstepping... must abort the move
-//             return;
-//     }
-
-       if (trace_fraction < 1 && trace_plane_normal_z > 0.7)
-       {
-               // this has been disabled so that you can't jump when you are stepping
-               // up while already jumping (also known as the Quake2 double jump bug)
-       }
-       else
-       {
-               //Con_Printf("slope\n");
-               // if the push down didn't end up on good ground, use the move without
-               // the step up.  This happens near wall / slope combinations, and can
-               // cause the player to hop up higher on a slope too steep to climb
-               setorigin(self, originalmove_origin);
-               self.velocity = originalmove_velocity;
-               self.flags = originalmove_flags;
-               self.groundentity = originalmove_groundentity;
-       }
-
-//     SV_CheckVelocity(self);
-//     SV_LinkEdict(self);
-//     SV_LinkEdict_TouchAreaGrid(self);
-}
-#endif
 void PM_walk(float buttons_prev, float maxspd_mod)
 {
        if (!WAS_ONGROUND(self))
        {
+#ifdef SVQC
                if (autocvar_speedmeter)
                        dprint(strcat("landing velocity: ", vtos(self.velocity), " (abs: ", ftos(vlen(self.velocity)), ")\n"));
+#endif
                if (self.lastground < time - 0.3)
                        self.velocity *= (1 - PHYS_FRICTION_ONLAND);
+#ifdef SVQC
                if (self.jumppadcount > 1)
                        dprint(strcat(ftos(self.jumppadcount), "x jumppad combo\n"));
                self.jumppadcount = 0;
+#endif
        }
+
        // walking
        makevectors(PHYS_INPUT_ANGLES(self).y * '0 1 0');
        vector wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x
@@ -1697,6 +1515,8 @@ void PM_Main()
 {
        float buttons = PHYS_INPUT_BUTTON_MASK(self);
 #ifdef CSQC
+       self.items = getstati(STAT_ITEMS, 0, 24);
+
        self.team = myteam + 1; // is this correct?
        if (!(PHYS_INPUT_BUTTON_JUMP(self))) // !jump
                UNSET_JUMP_HELD(self); // canjump = true
@@ -1869,13 +1689,13 @@ void PM_Main()
        if (IS_PLAYER(self))
                CheckPlayerJump();
 
-       if (self.flags & /* FL_WATERJUMP */ 2048)
+       if (self.flags & FL_WATERJUMP)
        {
                self.velocity_x = self.movedir_x;
                self.velocity_y = self.movedir_y;
                if (time > self.teleport_time || self.waterlevel == WATERLEVEL_NONE)
                {
-                       self.flags &= ~/* FL_WATERJUMP */ 2048;
+                       self.flags &= ~FL_WATERJUMP;
                        self.teleport_time = 0;
                }
        }
@@ -1917,7 +1737,7 @@ void PM_Main()
        if(self.conveyor.state)
                self.velocity += self.conveyor.movedir;
 
-       self.lastflags = FLAGS(self);
+       self.lastflags = self.flags;
 
        self.lastclassname = self.classname;
 }
@@ -1931,6 +1751,6 @@ void CSQC_ClientMovement_PlayerMove_Frame(void)
        PM_Main();
 
 #ifdef CSQC
-       self.pmove_flags = self.pm_flags;
+       self.pmove_flags = self.flags; // TODO
 #endif
 }
index 21ddcece988f6e142d11eb61cf68184156b6016e..52a8e9a56959d67f683ccf238bb0455ca1c26329 100644 (file)
@@ -26,12 +26,14 @@ bool IsFlying(entity a);
 
 #ifdef CSQC
 
-       .int pm_flags;
+       const int FL_WATERJUMP = 2048;  // player jumping out of water
+       const int FL_JUMPRELEASED = 4096;       // for jump debouncing
 
        float PM_multijump_checkjump();
        void PM_multijump();
 
        .float watertype;
+       .int items;
 
 // TODO
        #define IS_CLIENT(s)                                            (s).isplayermodel
@@ -71,23 +73,21 @@ bool IsFlying(entity a);
        #define GAMEPLAYFIX_Q2AIRACCELERATE                             cvar("sv_gameplayfix_q2airaccelerate")
        #define GAMEPLAYFIX_EASIERWATERJUMP                     getstati(STAT_GAMEPLAYFIX_EASIERWATERJUMP)
 
-       #define IS_DUCKED(s)                                            !!(s.pm_flags & PMF_DUCKED)
-       #define SET_DUCKED(s)                                           s.pm_flags |= PMF_DUCKED
-       #define UNSET_DUCKED(s)                                         s.pm_flags &= ~PMF_DUCKED
+       #define IS_DUCKED(s)                                            !!(s.flags & FL_DUCKED)
+       #define SET_DUCKED(s)                                           s.flags |= FL_DUCKED
+       #define UNSET_DUCKED(s)                                         s.flags &= ~FL_DUCKED
 
-       #define IS_JUMP_HELD(s)                                         !!(s.pm_flags & PMF_JUMP_HELD)
-       #define SET_JUMP_HELD(s)                                        s.pm_flags |= PMF_JUMP_HELD
-       #define UNSET_JUMP_HELD(s)                                      s.pm_flags &= ~PMF_JUMP_HELD
-
-       #define IS_ONGROUND(s)                                          !!(s.pm_flags & PMF_ONGROUND)
-       #define SET_ONGROUND(s)                                         s.pm_flags |= PMF_ONGROUND
-       #define UNSET_ONGROUND(s)                                       s.pm_flags &= ~PMF_ONGROUND
+       #define IS_JUMP_HELD(s)                                         !(s.flags & FL_JUMPRELEASED)
+       #define SET_JUMP_HELD(s)                                        s.flags &= ~FL_JUMPRELEASED
+       #define UNSET_JUMP_HELD(s)                                      s.flags |= FL_JUMPRELEASED
 
-       #define WAS_ONGROUND(s)                                         !!(s.lastflags & PMF_ONGROUND)
+       #define IS_ONGROUND(s)                                          !!(s.flags & FL_ONGROUND)
+       #define SET_ONGROUND(s)                                         s.flags |= FL_ONGROUND
+       #define UNSET_ONGROUND(s)                                       s.flags &= ~FL_ONGROUND
 
-       #define ITEMS(s)                                                        getstati(STAT_ITEMS, 0, 24)
+       #define WAS_ONGROUND(s)                                         !!(s.lastflags & FL_ONGROUND)
 
-       #define FLAGS(s)                                                        (s).pm_flags
+       #define ITEMS(s)                                                        (s).items
 
        #define PHYS_AMMO_FUEL(s)                                       getstati(STAT_FUEL)
 
@@ -209,8 +209,6 @@ bool IsFlying(entity a);
 
        #define ITEMS(s)                                                        s.items
 
-       #define FLAGS(s)                                                        (s).flags
-
        #define PHYS_AMMO_FUEL(s)                                       s.ammo_fuel
 
        #define PHYS_FROZEN(s)                                          s.frozen
index 62b60a4c4fd07fa87ddcce3e263ff742e13fbdf0..f16c5be8597fc170d6ec5c2a8d9d460640032a16 100644 (file)
@@ -105,12 +105,12 @@ void CSQCPlayer_Unpredict()
        self.origin = csqcplayer_origin;
        self.velocity = csqcplayer_velocity;
        csqcplayer_moveframe = csqcplayer_sequence+1; //+1 because the recieved frame has the move already done (server side)
-       self.pmove_flags = player_pmflags;
+       self.flags = player_pmflags;
 }
 
 void CSQCPlayer_SetMinsMaxs()
 {
-       if(self.pmove_flags & PMF_DUCKED)
+       if(self.flags & FL_DUCKED)
        {
                self.mins = PL_CROUCH_MIN;
                self.maxs = PL_CROUCH_MAX;
@@ -126,7 +126,7 @@ void CSQCPlayer_SetMinsMaxs()
 
 void CSQCPlayer_SavePrediction()
 {
-       player_pmflags = self.pmove_flags;
+       player_pmflags = self.flags;
        csqcplayer_origin = self.origin;
        csqcplayer_velocity = self.velocity;
        csqcplayer_sequence = servercommandframe;
@@ -212,15 +212,15 @@ void CSQCPlayer_SetCamera()
 
                        // get crouch state from the server
                        if(getstati(STAT_VIEWHEIGHT) == PL_VIEW_OFS_z)
-                               self.pmove_flags &= ~PMF_DUCKED;
+                               self.flags &= ~FL_DUCKED;
                        else if(getstati(STAT_VIEWHEIGHT) == PL_CROUCH_VIEW_OFS_z)
-                               self.pmove_flags |= PMF_DUCKED;
+                               self.flags |= FL_DUCKED;
 
                        // get onground state from the server
                        if(pmove_onground)
-                               self.pmove_flags |= PMF_ONGROUND;
+                               self.flags |= FL_ONGROUND;
                        else
-                               self.pmove_flags &= ~PMF_ONGROUND;
+                               self.flags &= ~FL_ONGROUND;
 
                        CSQCPlayer_SetMinsMaxs();
 
@@ -250,15 +250,15 @@ void CSQCPlayer_SetCamera()
 
                                // get crouch state from the server
                                if(getstati(STAT_VIEWHEIGHT) == PL_VIEW_OFS_z)
-                                       self.pmove_flags &= ~PMF_DUCKED;
+                                       self.flags &= ~FL_DUCKED;
                                else if(getstati(STAT_VIEWHEIGHT) == PL_CROUCH_VIEW_OFS_z)
-                                       self.pmove_flags |= PMF_DUCKED;
+                                       self.flags |= FL_DUCKED;
 
                                // get onground state from the server
                                if(pmove_onground)
-                                       self.pmove_flags |= PMF_ONGROUND;
+                                       self.flags |= FL_ONGROUND;
                                else
-                                       self.pmove_flags &= ~PMF_ONGROUND;
+                                       self.flags &= ~FL_ONGROUND;
 
                                CSQCPlayer_SavePrediction();
                        }
@@ -267,9 +267,9 @@ void CSQCPlayer_SetCamera()
 #ifdef CSQCMODEL_SERVERSIDE_CROUCH
                        // get crouch state from the server (LAG)
                        if(getstati(STAT_VIEWHEIGHT) == PL_VIEW_OFS_z)
-                               self.pmove_flags &= ~PMF_DUCKED;
+                               self.flags &= ~FL_DUCKED;
                        else if(getstati(STAT_VIEWHEIGHT) == PL_CROUCH_VIEW_OFS_z)
-                               self.pmove_flags |= PMF_DUCKED;
+                               self.flags |= FL_DUCKED;
 #endif
 
                        CSQCPlayer_SetMinsMaxs();
index 55e63cf56dfd144e886970d17f1b35967a6cccca..e427e6cf363f855510aaaa56b65b7df23384801a 100644 (file)
@@ -34,6 +34,8 @@ const int PMF_JUMP_HELD = 1;
 //const int PMF_DUCKED = 4;
 //const int PMF_ONGROUND = 8;
 
+const int FL_DUCKED = 524288;
+
 void CSQCPlayer_SetCamera();
 float CSQCPlayer_PreUpdate();
 float CSQCPlayer_PostUpdate();