]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Begin porting SV_WalkMove for the stair jump fix
authorTimePath <andrew.hardaker1995@gmail.com>
Mon, 15 Dec 2014 02:53:12 +0000 (13:53 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Mon, 15 Dec 2014 02:53:12 +0000 (13:53 +1100)
qcsrc/common/physics.qc

index a97d69fb939c60b9e71e432cd757364d89b51d29..531cbeed5facdc819e3bad2c0a91553560075fd8 100644 (file)
@@ -1052,7 +1052,7 @@ void PM_check_vortex(void)
                xyspeed = min(xyspeed, WEP_CVAR(vortex, charge_maxspeed));
                float f = (xyspeed - WEP_CVAR(vortex, charge_minspeed)) / (WEP_CVAR(vortex, charge_maxspeed) - WEP_CVAR(vortex, charge_minspeed));
                // add the extra charge
-               self.vortex_charge = min(1, self.vortex_charge + WEP_CVAR(vortex, charge_velocity_rate) * f * frametime);
+               self.vortex_charge = min(1, self.vortex_charge + WEP_CVAR(vortex, charge_velocity_rate) * f * PHYS_INPUT_TIMELENGTH);
        }
 #endif
 }
@@ -1338,7 +1338,184 @@ 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
+               self.origin = 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
+                       self.origin = 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
+               self.origin = 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)
 {
 #ifdef SVQC