]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_physics.qc
Merge branch 'master' into divVerent/speedlimit
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_physics.qc
index 0051d8759a4d9a3a9384152d53e848d0a8427dc4..5e70e79bd4d29902e71e6a32b247e924e80be631 100644 (file)
@@ -21,6 +21,7 @@ float sv_warsowbunny_accel;
 float sv_warsowbunny_topspeed;
 float sv_warsowbunny_turnaccel;
 float sv_warsowbunny_backtosideratio;
 float sv_warsowbunny_topspeed;
 float sv_warsowbunny_turnaccel;
 float sv_warsowbunny_backtosideratio;
+float sv_speedlimit;
 
 .float ladder_time;
 .entity ladder_entity;
 
 .float ladder_time;
 .entity ladder_entity;
@@ -477,6 +478,11 @@ void CPM_PM_Aircontrol(vector wishdir, float wishspeed)
        self.velocity_z = zspeed;
 }
 
        self.velocity_z = zspeed;
 }
 
+float AdjustAirAccelQW(float accelqw, float factor)
+{
+       return copysign(bound(0.000001, 1 - (1 - fabs(accelqw)) * factor, 1), accelqw);
+}
+
 // example config for alternate speed clamping:
 //   sv_airaccel_qw 0.8
 //   sv_airaccel_sideways_friction 0
 // example config for alternate speed clamping:
 //   sv_airaccel_qw 0.8
 //   sv_airaccel_sideways_friction 0
@@ -509,6 +515,8 @@ void PM_Accelerate(vector wishdir, float wishspeed, float wishspeed0, float acce
        step = accel * frametime * wishspeed0;
 
        vel_xy_current  = vlen(vel_xy);
        step = accel * frametime * wishspeed0;
 
        vel_xy_current  = vlen(vel_xy);
+       if(sv_speedlimit)
+               accelqw = AdjustAirAccelQW(accelqw, (sv_speedlimit - bound(wishspeed, vel_xy_current, sv_speedlimit)) / max(1, sv_speedlimit - wishspeed));
        vel_xy_forward  = vel_xy_current + bound(0, wishspeed - vel_xy_current, step) * accelqw + step * (1 - accelqw);
        vel_xy_backward = vel_xy_current - bound(0, wishspeed + vel_xy_current, step) * accelqw - step * (1 - accelqw);
        if(vel_xy_backward < 0)
        vel_xy_forward  = vel_xy_current + bound(0, wishspeed - vel_xy_current, step) * accelqw + step * (1 - accelqw);
        vel_xy_backward = vel_xy_current - bound(0, wishspeed + vel_xy_current, step) * accelqw - step * (1 - accelqw);
        if(vel_xy_backward < 0)
@@ -644,9 +652,9 @@ void SV_PlayerPhysics()
        string c;
 
        // fix physics stats for g_movement_highspeed
        string c;
 
        // fix physics stats for g_movement_highspeed
-       self.stat_sv_airaccel_qw = copysign(bound(0, 1-(1-fabs(sv_airaccel_qw))*autocvar_g_movement_highspeed, 1), sv_airaccel_qw);
+       self.stat_sv_airaccel_qw = AdjustAirAccelQW(sv_airaccel_qw, autocvar_g_movement_highspeed);
        if(sv_airstrafeaccel_qw)
        if(sv_airstrafeaccel_qw)
-               self.stat_sv_airstrafeaccel_qw = copysign(bound(0.001, 1-(1-fabs(sv_airstrafeaccel_qw))*autocvar_g_movement_highspeed, 1), sv_airstrafeaccel_qw);
+               self.stat_sv_airstrafeaccel_qw = AdjustAirAccelQW(sv_airstrafeaccel_qw, autocvar_g_movement_highspeed);
        else
                self.stat_sv_airstrafeaccel_qw = 0;
 
        else
                self.stat_sv_airstrafeaccel_qw = 0;