]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/physics.qc
Merge remote-tracking branch 'origin/TimePath/experiments/csqc_prediction' into TimeP...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / physics.qc
index a1e2886d328f490c4620fa16dce19fe82745bae4..b8fdb1a6c838b8415b41481f38f7733c1a1d1811 100644 (file)
@@ -1,38 +1,6 @@
-.float race_penalty;
-.float restart_jump;
+#include "physics.qh"
 
-.float gravity;
-.float swamp_slowdown;
-.float lastflags;
-.float lastground;
-.float wasFlying;
-.float spectatorspeed;
-
-.vector movement_old;
-.float buttons_old;
-.vector v_angle_old;
-.string lastclassname;
-
-.float() PlayerPhysplug;
-float AdjustAirAccelQW(float accelqw, float factor);
-
-#ifdef CSQC
-
-.float watertype;
-
-#elif defined(SVQC)
-.float stat_sv_airaccel_qw;
-.float stat_sv_airstrafeaccel_qw;
-.float stat_sv_airspeedlimit_nonqw;
-.float stat_sv_maxspeed;
-.float stat_movement_highspeed;
-
-.float stat_jetpack_accel_side;
-.float stat_jetpack_accel_up;
-.float stat_jetpack_antigravity;
-.float stat_jetpack_fuel;
-.float stat_jetpack_maxspeed_up;
-.float stat_jetpack_maxspeed_side;
+#ifdef SVQC
 
 void Physics_AddStats()
 {
@@ -50,6 +18,21 @@ void Physics_AddStats()
        addstat(STAT_JETPACK_FUEL, AS_FLOAT, stat_jetpack_fuel);
        addstat(STAT_JETPACK_MAXSPEED_UP, AS_FLOAT, stat_jetpack_maxspeed_up);
        addstat(STAT_JETPACK_MAXSPEED_SIDE, AS_FLOAT, stat_jetpack_maxspeed_side);
+
+       // hack to fix track_canjump
+       addstat(STAT_MOVEVARS_TRACK_CANJUMP, AS_INT, cvar_cl_movement_track_canjump);
+
+       // double jump
+       addstat(STAT_DOUBLEJUMP, AS_INT, stat_doublejump);
+
+       // jump speed caps
+       addstat(STAT_MOVEVARS_JUMPSPEEDCAP_MIN, AS_FLOAT, stat_jumpspeedcap_min);
+       addstat(STAT_MOVEVARS_JUMPSPEEDCAP_MIN, AS_FLOAT, stat_jumpspeedcap_min);
+       addstat(STAT_MOVEVARS_JUMPSPEEDCAP_DISABLE_ONRAMPS, AS_INT, stat_jumpspeedcap_disable_onramps);
+
+       // hacks
+       addstat(STAT_MOVEVARS_FRICTION_ONLAND, AS_FLOAT, stat_sv_friction_on_land);
+       addstat(STAT_MOVEVARS_FRICTION_SLICK, AS_FLOAT, stat_sv_friction_slick);
 }
 
 void Physics_UpdateStats(float maxspd_mod)
@@ -63,12 +46,21 @@ void Physics_UpdateStats(float maxspd_mod)
        self.stat_sv_maxspeed = autocvar_sv_maxspeed * maxspd_mod; // also slow walking
        self.stat_movement_highspeed = PHYS_HIGHSPEED; // TODO: remove this!
 
+       self.stat_doublejump = PHYS_DOUBLEJUMP;
+
        self.stat_jetpack_antigravity = PHYS_JETPACK_ANTIGRAVITY;
        self.stat_jetpack_accel_up = PHYS_JETPACK_ACCEL_UP;
        self.stat_jetpack_accel_side = PHYS_JETPACK_ACCEL_SIDE;
        self.stat_jetpack_maxspeed_side = PHYS_JETPACK_MAXSPEED_SIDE;
        self.stat_jetpack_maxspeed_up = PHYS_JETPACK_MAXSPEED_UP;
        self.stat_jetpack_fuel = PHYS_JETPACK_FUEL;
+
+       self.stat_jumpspeedcap_min = PHYS_JUMPSPEEDCAP_MIN;
+       self.stat_jumpspeedcap_max = PHYS_JUMPSPEEDCAP_MAX;
+       self.stat_jumpspeedcap_disable_onramps = PHYS_JUMPSPEEDCAP_DISABLE_ONRAMPS;
+
+       self.stat_sv_friction_on_land = PHYS_FRICTION_ONLAND;
+       self.stat_sv_friction_slick = PHYS_FRICTION_SLICK;
 }
 #endif
 
@@ -163,7 +155,7 @@ void PM_ClientMovement_UpdateStatus()
                SET_ONGROUND(self);
 
                // this code actually "predicts" an impact; so let's clip velocity first
-               float f = dotproduct(self.velocity, trace_plane_normal);
+               float f = self.velocity * trace_plane_normal;
                if (f < 0) // only if moving downwards actually
                        self.velocity -= f * trace_plane_normal;
        }
@@ -226,7 +218,6 @@ void PM_ClientMovement_Move()
                                float old_trace2_fraction = trace_fraction;
                                vector old_trace2_plane_normal = trace_plane_normal;
                                tracebox(currentorigin2, self.mins, self.maxs, neworigin2, MOVE_NORMAL, self);
-                               //Con_Printf("%f %f %f %f : %f %f %f %f : %f %f %f %f\n", trace.fraction, trace.endpos[0], trace.endpos[1], trace.endpos[2], trace2.fraction, trace2.endpos[0], trace2.endpos[1], trace2.endpos[2], trace3.fraction, trace3.endpos[0], trace3.endpos[1], trace3.endpos[2]);
                                // accept the new trace if it made some progress
                                if (fabs(trace_endpos_x - old_trace1_endpos_x) >= 0.03125 || fabs(trace_endpos_y - old_trace1_endpos_y) >= 0.03125)
                                {
@@ -260,7 +251,7 @@ void PM_ClientMovement_Move()
 
                t -= t * trace_fraction;
 
-               float f = dotproduct(self.velocity, trace_plane_normal);
+               float f = self.velocity * trace_plane_normal;
                self.velocity -= f * trace_plane_normal;
        }
        if (pmove_waterjumptime > 0)
@@ -270,17 +261,9 @@ void PM_ClientMovement_Move()
 
 void CPM_PM_Aircontrol(vector wishdir, float wishspeed)
 {
-       float k;
-#if 0
-       // this doesn't play well with analog input
-       if (PHYS_INPUT_MOVEVALUES(self).x == 0 || PHYS_INPUT_MOVEVALUES(self).y != 0)
-               return; // can't control movement if not moving forward or backward
-       k = 32;
-#else
-       k = 32 * (2 * IsMoveInDirection(PHYS_INPUT_MOVEVALUES(self), 0) - 1);
+       float k = 32 * (2 * IsMoveInDirection(PHYS_INPUT_MOVEVALUES(self), 0) - 1);
        if (k <= 0)
                return;
-#endif
 
        k *= bound(0, wishspeed / PHYS_MAXAIRSPEED, 1);
 
@@ -417,34 +400,40 @@ void PM_AirAccelerate(vector wishdir, float wishspeed)
 PlayerJump
 
 When you press the jump key
+returns true if handled
 =============
 */
-void PlayerJump (void)
+float PlayerJump (void)
 {
-#ifdef SVQC
        if (PHYS_FROZEN(self))
-               return; // no jumping in freezetag when frozen
+               return true; // no jumping in freezetag when frozen
 
+#ifdef SVQC
        if (self.player_blocked)
-               return; // no jumping while blocked
+               return true; // no jumping while blocked
+#endif
 
-       float doublejump = FALSE;
+       float doublejump = false;
        float mjumpheight = PHYS_JUMPVELOCITY;
 
        player_multijump = doublejump;
        player_jumpheight = mjumpheight;
+#ifdef SVQC
        if (MUTATOR_CALLHOOK(PlayerJump))
-               return;
+#elif defined(CSQC)
+       if(PM_multijump_checkjump())
+#endif
+               return true;
 
        doublejump = player_multijump;
        mjumpheight = player_jumpheight;
 
-       if (autocvar_sv_doublejump)
+       if (PHYS_DOUBLEJUMP)
        {
                tracebox(self.origin + '0 0 0.01', self.mins, self.maxs, self.origin - '0 0 0.01', MOVE_NORMAL, self);
                if (trace_fraction < 1 && trace_plane_normal_z > 0.7)
                {
-                       doublejump = TRUE;
+                       doublejump = true;
 
                        // we MUST clip velocity here!
                        float f;
@@ -457,70 +446,72 @@ void PlayerJump (void)
        if (self.waterlevel >= WATERLEVEL_SWIMMING)
        {
                self.velocity_z = PHYS_MAXSPEED(self) * 0.7;
-               return;
+               return true;
        }
 
        if (!doublejump)
                if (!IS_ONGROUND(self))
-                       return;
+                       return IS_JUMP_HELD(self);
 
-       if (self.cvar_cl_movement_track_canjump)
-               if (!(self.flags & FL_JUMPRELEASED))
-                       return;
+       if (PHYS_TRACK_CANJUMP(self))
+               if (IS_JUMP_HELD(self))
+                       return true;
 
        // sv_jumpspeedcap_min/sv_jumpspeedcap_max act as baseline
        // velocity bounds.  Final velocity is bound between (jumpheight *
        // min + jumpheight) and (jumpheight * max + jumpheight);
 
-       if (autocvar_sv_jumpspeedcap_min != "")
+       if(PHYS_JUMPSPEEDCAP_MIN)
        {
-               float minjumpspeed = mjumpheight * stof(autocvar_sv_jumpspeedcap_min);
+               float minjumpspeed = mjumpheight * PHYS_JUMPSPEEDCAP_MIN;
 
                if (self.velocity_z < minjumpspeed)
                        mjumpheight += minjumpspeed - self.velocity_z;
        }
 
-       if (autocvar_sv_jumpspeedcap_max != "")
+       if(PHYS_JUMPSPEEDCAP_MAX)
        {
                // don't do jump speedcaps on ramps to preserve old xonotic ramjump style
                tracebox(self.origin + '0 0 0.01', self.mins, self.maxs, self.origin - '0 0 0.01', MOVE_NORMAL, self);
 
-               if (!(trace_fraction < 1 && trace_plane_normal_z < 0.98 && autocvar_sv_jumpspeedcap_max_disable_on_ramps))
+               if (!(trace_fraction < 1 && trace_plane_normal_z < 0.98 && PHYS_JUMPSPEEDCAP_DISABLE_ONRAMPS))
                {
-                       float maxjumpspeed = mjumpheight * stof(autocvar_sv_jumpspeedcap_max);
+                       float maxjumpspeed = mjumpheight * PHYS_JUMPSPEEDCAP_MAX;
 
                        if (self.velocity_z > maxjumpspeed)
                                mjumpheight -= self.velocity_z - maxjumpspeed;
                }
        }
 
-       if (!(self.lastflags & FL_ONGROUND))
+       if (!WAS_ONGROUND(self))
        {
-               if (autocvar_speedmeter)
+               if(autocvar_speedmeter)
                        dprint(strcat("landing velocity: ", vtos(self.velocity), " (abs: ", ftos(vlen(self.velocity)), ")\n"));
-               if (self.lastground < time - 0.3)
+               if(self.lastground < time - 0.3)
                {
-                       self.velocity_x *= (1 - autocvar_sv_friction_on_land);
-                       self.velocity_y *= (1 - autocvar_sv_friction_on_land);
+                       self.velocity_x *= (1 - PHYS_FRICTION_ONLAND);
+                       self.velocity_y *= (1 - PHYS_FRICTION_ONLAND);
                }
-               if (self.jumppadcount > 1)
+               if(self.jumppadcount > 1)
                        dprint(strcat(ftos(self.jumppadcount), "x jumppad combo\n"));
                self.jumppadcount = 0;
        }
 
-       self.oldvelocity_z = self.velocity_z += mjumpheight;
+       self.velocity_z += mjumpheight;
 
        UNSET_ONGROUND(self);
-       self.flags &= ~FL_JUMPRELEASED;
+       SET_JUMP_HELD(self);
+
+#ifdef SVQC
 
-       animdecide_setaction(self, ANIMACTION_JUMP, TRUE);
+       self.oldvelocity_z = self.velocity_z;
+
+       animdecide_setaction(self, ANIMACTION_JUMP, true);
 
        if (autocvar_g_jump_grunt)
                PlayerSound(playersound_jump, CH_PLAYER, VOICETYPE_PLAYERSOUND);
-
-       self.restart_jump = -1; // restart jump anim next time
-       // value -1 is used to not use the teleport bit (workaround for tiny hitch when re-jumping)
 #endif
+       return true;
 }
 
 void CheckWaterJump()
@@ -532,34 +523,85 @@ void CheckWaterJump()
        v_forward_z = 0;
        normalize(v_forward);
        vector end = start + v_forward*24;
-       traceline (start, end, TRUE, self);
+       traceline (start, end, true, self);
        if (trace_fraction < 1)
        {       // solid at waist
                start_z = start_z + self.maxs_z - 8;
                end = start + v_forward*24;
                self.movedir = trace_plane_normal * -50;
-               traceline(start, end, TRUE, self);
+               traceline(start, end, true, self);
                if (trace_fraction == 1)
                {       // open at eye level
                        self.velocity_z = 225;
 #ifdef SVQC
                        self.flags |= FL_WATERJUMP;
-                       self.flags &= ~FL_JUMPRELEASED;
+                       SET_JUMP_HELD(self);
                        self.teleport_time = time + 2;  // safety net
 #endif
                }
        }
 }
 
+
+#ifdef SVQC
+       #define JETPACK_JUMP(s) s.cvar_cl_jetpack_jump
+#elif defined(CSQC)
+       float autocvar_cl_jetpack_jump;
+       #define JETPACK_JUMP(s) autocvar_cl_jetpack_jump
+#endif
+.float jetpack_stopped;
+// Hack: shouldn't need to know about this
+.float multijump_count;
 void CheckPlayerJump()
 {
 #ifdef SVQC
-       if (self.BUTTON_JUMP)
-               PlayerJump();
-       else
-               self.flags |= FL_JUMPRELEASED;
+       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
+               if (!(ITEMS(self) & IT_JETPACK)) { }
+               else if (self.jetpack_stopped) { }
+               else if (!has_fuel)
+               {
+#ifdef SVQC
+                       if (was_flying) // TODO: ran out of fuel message
+                               Send_Notification(NOTIF_ONE, self, MSG_INFO, INFO_JETPACK_NOFUEL);
+                       else if (activate)
+                               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);
+
        if (self.waterlevel == WATERLEVEL_SWIMMING)
                CheckWaterJump();
 }
@@ -802,40 +844,6 @@ void SpecialCommand()
 #endif
 }
 
-#ifdef SVQC
-float speedaward_speed;
-string speedaward_holder;
-string speedaward_uid;
-#endif
-void race_send_speedaward(float msg)
-{
-#ifdef SVQC
-       // send the best speed of the round
-       WriteByte(msg, SVC_TEMPENTITY);
-       WriteByte(msg, TE_CSQC_RACE);
-       WriteByte(msg, RACE_NET_SPEED_AWARD);
-       WriteInt24_t(msg, floor(speedaward_speed+0.5));
-       WriteString(msg, speedaward_holder);
-#endif
-}
-
-#ifdef SVQC
-float speedaward_alltimebest;
-string speedaward_alltimebest_holder;
-string speedaward_alltimebest_uid;
-#endif
-void race_send_speedaward_alltimebest(float msg)
-{
-#ifdef SVQC
-       // send the best speed
-       WriteByte(msg, SVC_TEMPENTITY);
-       WriteByte(msg, TE_CSQC_RACE);
-       WriteByte(msg, RACE_NET_SPEED_AWARD_BEST);
-       WriteInt24_t(msg, floor(speedaward_alltimebest+0.5));
-       WriteString(msg, speedaward_alltimebest_holder);
-#endif
-}
-
 float PM_check_keepaway(void)
 {
 #ifdef SVQC
@@ -884,13 +892,13 @@ float PM_check_specialcommand(float buttons)
                {
                        self.specialcommand_pos = 0;
                        SpecialCommand();
-                       return TRUE;
+                       return true;
                }
        }
        else if (self.specialcommand_pos && (c != substring(specialcommand, self.specialcommand_pos - 1, 1)))
                self.specialcommand_pos = 0;
 #endif
-       return FALSE;
+       return false;
 }
 
 void PM_check_nickspam(void)
@@ -909,7 +917,7 @@ void PM_check_nickspam(void)
                        PHYS_INPUT_ANGLES(self)_x = random() * 360;
                        PHYS_INPUT_ANGLES(self)_y = random() * 360;
                        // at least I'm not forcing retardedview by also assigning to angles_z
-                       self.fixangle = TRUE;
+                       self.fixangle = true;
                }
        }
 #endif
@@ -1024,14 +1032,15 @@ void PM_check_race(void)
 void PM_check_vortex(void)
 {
 #ifdef SVQC
+       // WEAPONTODO
        float xyspeed = vlen(vec2(self.velocity));
-       if (self.weapon == WEP_NEX && autocvar_g_balance_nex_charge && autocvar_g_balance_nex_charge_velocity_rate && xyspeed > autocvar_g_balance_nex_charge_minspeed)
+       if (self.weapon == WEP_VORTEX && WEP_CVAR(vortex, charge) && WEP_CVAR(vortex, charge_velocity_rate) && xyspeed > WEP_CVAR(vortex, charge_minspeed))
        {
                // add a maximum of charge_velocity_rate when going fast (f = 1), gradually increasing from minspeed (f = 0) to maxspeed
-               xyspeed = min(xyspeed, autocvar_g_balance_nex_charge_maxspeed);
-               float f = (xyspeed - autocvar_g_balance_nex_charge_minspeed) / (autocvar_g_balance_nex_charge_maxspeed - autocvar_g_balance_nex_charge_minspeed);
+               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.nex_charge = min(1, self.nex_charge + autocvar_g_balance_nex_charge_velocity_rate * f * PHYS_INPUT_TIMELENGTH);
+               self.vortex_charge = min(1, self.vortex_charge + WEP_CVAR(vortex, charge_velocity_rate) * f * PHYS_INPUT_TIMELENGTH);
        }
 #endif
 }
@@ -1190,6 +1199,18 @@ void PM_ladder(float maxspd_mod)
                PM_Accelerate(wishdir, wishspeed, wishspeed, PHYS_ACCELERATE*maxspd_mod, 1, 0, 0, 0);
 }
 
+void PM_check_jumppad()
+{
+#ifdef CSQC
+       entity oldself = self;
+
+       for(self = world; (self = find(self, classname, "jumppad")); )
+               trigger_push_draw();
+
+       self = oldself;
+#endif
+}
+
 void PM_jetpack(float maxspd_mod)
 {
        //makevectors(PHYS_INPUT_ANGLES(self).y * '0 1 0');
@@ -1286,7 +1307,7 @@ void PM_jetpack(float maxspd_mod)
                if (!(ITEMS(self) & IT_UNLIMITED_WEAPON_AMMO))
                        self.ammo_fuel -= PHYS_JETPACK_FUEL * PHYS_INPUT_TIMELENGTH * fvel * f;
 
-               self.items |= IT_USING_JETPACK;
+               ITEMS(self) |= IT_USING_JETPACK;
 
                // jetpack also inhibits health regeneration, but only for 1 second
                self.pauseregen_finished = max(self.pauseregen_finished, time + autocvar_g_balance_pause_fuel_regen);
@@ -1305,24 +1326,196 @@ 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
-       // we get here if we ran out of ammo
-       if ((ITEMS(self) & IT_JETPACK) && self.BUTTON_HOOK && !(buttons_prev & 32) && self.ammo_fuel < 0.01)
-               sprint(self, "You don't have any fuel for the ^2Jetpack\n");
-       if (!(self.lastflags & FL_ONGROUND))
+       if (!WAS_ONGROUND(self))
        {
                if (autocvar_speedmeter)
                        dprint(strcat("landing velocity: ", vtos(self.velocity), " (abs: ", ftos(vlen(self.velocity)), ")\n"));
                if (self.lastground < time - 0.3)
-                       self.velocity *= (1 - autocvar_sv_friction_on_land);
+                       self.velocity *= (1 - PHYS_FRICTION_ONLAND);
                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
@@ -1339,9 +1532,17 @@ void PM_walk(float buttons_prev, float maxspd_mod)
        float f = vlen(vec2(self.velocity));
        if (f > 0)
        {
+               float realfriction;
+               trace_dphitq3surfaceflags = 0;
+               tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 1', MOVE_NOMONSTERS, self);
                // TODO: apply edge friction
                // apply ground friction
-               f = 1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION * ((f < PHYS_STOPSPEED) ? (PHYS_STOPSPEED / f) : 1);
+               if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK)
+                       realfriction = PHYS_FRICTION_SLICK;
+               else
+                       realfriction = PHYS_FRICTION;
+
+               f = 1 - PHYS_INPUT_TIMELENGTH * realfriction * ((f < PHYS_STOPSPEED) ? (PHYS_STOPSPEED / f) : 1);
                f = max(0, f);
                self.velocity *= f;
                /*
@@ -1385,11 +1586,6 @@ void PM_walk(float buttons_prev, float maxspd_mod)
 
 void PM_air(float buttons_prev, float maxspd_mod)
 {
-#ifdef SVQC
-       // we get here if we ran out of ammo
-       if ((ITEMS(self) & IT_JETPACK) && self.BUTTON_HOOK && !(buttons_prev & 32) && PHYS_AMMO_FUEL(self) < 0.01)
-               sprint(self, "You don't have any fuel for the ^2Jetpack\n");
-#endif
        makevectors(PHYS_INPUT_ANGLES(self).y * '0 1 0');
        vector wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x
                                        + v_right * PHYS_INPUT_MOVEVALUES(self).y;
@@ -1476,12 +1672,12 @@ void PM_Main()
 {
        float buttons = PHYS_INPUT_BUTTON_MASK(self);
 #ifdef CSQC
-       //Con_Printf(" %f", PHYS_INPUT_TIMELENGTH);
+       self.team = myteam + 1; // is this correct?
        if (!(PHYS_INPUT_BUTTON_JUMP(self))) // !jump
                UNSET_JUMP_HELD(self); // canjump = true
        pmove_waterjumptime -= PHYS_INPUT_TIMELENGTH;
-       PM_ClientMovement_UpdateStatus();
 #endif
+       PM_ClientMovement_UpdateStatus();
 
 #ifdef SVQC
        WarpZone_PlayerPhysics_FixVAngle();
@@ -1528,8 +1724,6 @@ void PM_Main()
                bot_think();
        }
 
-       self.items &= ~IT_USING_JETPACK;
-
        if (IS_PLAYER(self))
 #endif
        {
@@ -1545,9 +1739,8 @@ void PM_Main()
                        not_allowed_to_move = 1;
 #endif
 #ifdef SVQC
-               if (!autocvar_sv_ready_restart_after_countdown)
-                       if (time < game_starttime)
-                               not_allowed_to_move = 1;
+               if (time < game_starttime)
+                       not_allowed_to_move = 1;
 #endif
 
                if (not_allowed_to_move)
@@ -1590,15 +1783,17 @@ void PM_Main()
        }
 #endif
 
-#ifdef SVQC
        // conveyors: first fix velocity
        if (self.conveyor.state)
                self.velocity -= self.conveyor.movedir;
-#endif
 
 #ifdef SVQC
        MUTATOR_CALLHOOK(PlayerPhysics);
 #endif
+#ifdef CSQC
+       PM_multijump();
+#endif
+
 //     float forcedodge = 1;
 //     if(forcedodge) {
 //#ifdef CSQC
@@ -1678,6 +1873,7 @@ void PM_Main()
 #endif
                CheckPlayerJump();
 
+       PM_check_jumppad();
 
        if (self.flags & /* FL_WATERJUMP */ 2048)
        {
@@ -1704,26 +1900,11 @@ void PM_Main()
        else if (time < self.ladder_time)
                PM_ladder(maxspeed_mod);
 
-       else if ((ITEMS(self) & IT_JETPACK) && PHYS_INPUT_BUTTON_HOOK(self) && (!PHYS_JETPACK_FUEL || PHYS_AMMO_FUEL(self) > 0 || (ITEMS(self) & IT_UNLIMITED_WEAPON_AMMO)) && !PHYS_FROZEN(self))
+       else if (ITEMS(self) & IT_USING_JETPACK)
                PM_jetpack(maxspeed_mod);
 
        else
        {
-#ifdef CSQC
-               // jump if on ground with jump button pressed but only if it has been
-               // released at least once since the last jump
-               if (PHYS_INPUT_BUTTON_JUMP(self))
-               {
-                       if (IS_ONGROUND(self) && (!IS_JUMP_HELD(self) || !cvar("cl_movement_track_canjump")))
-                       {
-                               self.velocity_z += PHYS_JUMPVELOCITY;
-                               UNSET_ONGROUND(self);
-                               SET_JUMP_HELD(self); // canjump = false
-                       }
-               }
-               else
-                       UNSET_JUMP_HELD(self); // canjump = true
-#endif
                if (IS_ONGROUND(self))
                        PM_walk(buttons_prev, maxspeed_mod);
                else
@@ -1740,38 +1921,24 @@ void PM_Main()
        if (IS_ONGROUND(self))
                self.lastground = time;
 
-#ifdef SVQC
        // conveyors: then break velocity again
        if (self.conveyor.state)
                self.velocity += self.conveyor.movedir;
-#endif
+
+#ifdef SVQC
        self.lastflags = self.flags;
-       self.lastclassname = self.classname;
-}
+#elif defined(CSQC)
+       self.lastflags = self.pmove_flags;
+#endif
 
-void CSQC_ClientMovement_PlayerMove_Frame()
-{
-       // if a move is more than 50ms, do it as two moves (matching qwsv)
-       //Con_Printf("%i ", self.cmd.msec);
-       if (PHYS_INPUT_TIMELENGTH > 0.0005)
-       {
-               if (PHYS_INPUT_TIMELENGTH > 0.05)
-               {
-                       PHYS_INPUT_TIMELENGTH /= 2;
-                       PM_Main();
-               }
-               PM_Main();
-       }
-       else
-               // we REALLY need this handling to happen, even if the move is not executed
-               if (!(PHYS_INPUT_BUTTON_JUMP(self))) // !jump
-                       UNSET_JUMP_HELD(self); // canjump = true
+       self.lastclassname = self.classname;
 }
 
 #ifdef SVQC
-// Entry point
 void SV_PlayerPhysics(void)
+#elif defined(CSQC)
+void CSQC_ClientMovement_PlayerMove_Frame(void)
+#endif
 {
        PM_Main();
 }
-#endif
\ No newline at end of file