Merge branch 'master' into Mario/speed_var
authorMario <mario.mario@y7mail.com>
Fri, 17 Jul 2020 07:33:02 +0000 (17:33 +1000)
committerMario <mario.mario@y7mail.com>
Fri, 17 Jul 2020 07:33:02 +0000 (17:33 +1000)
qcsrc/common/stats.qh
qcsrc/ecs/systems/cl_physics.qc
qcsrc/ecs/systems/sv_physics.qc

index 9ecac9f7c0bdd0bf2ee59dad460c6beea9905fc0..153ff98d2203ba3051b357c6174ca50b2695071b 100644 (file)
@@ -340,6 +340,8 @@ bool autocvar_g_shootfromeye;
 REGISTER_STAT(SHOOTFROMEYE, bool, autocvar_g_shootfromeye)
 REGISTER_STAT(SHOOTFROMCENTER, bool, autocvar_g_shootfromcenter)
 
+REGISTER_STAT(MOVEVARS_SPEED, float)
+
 REGISTER_STAT(MOVEVARS_AIRACCEL_QW_STRETCHFACTOR, float)
 REGISTER_STAT(MOVEVARS_AIRCONTROL_PENALTY, float)
 REGISTER_STAT(MOVEVARS_AIRSPEEDLIMIT_NONQW, float)
index 624e0a9126e8a497272cf0ad2a9c98ec6b26b2eb..4d38c574d9cdac5345bdf9782989aed40b694f7d 100644 (file)
@@ -24,4 +24,15 @@ void sys_phys_pregame_hold(entity this) {}
 
 void sys_phys_spectator_control(entity this) {}
 
-void sys_phys_fixspeed(entity this, float maxspeed_mod) {}
+void sys_phys_fixspeed(entity this, float maxspeed_mod)
+{
+       float spd = STAT(MOVEVARS_SPEED, this);
+       if (this.speed != spd) {
+               this.speed = spd;
+               string temps = ftos(spd);
+               cvar_set("cl_forwardspeed", temps);
+               cvar_set("cl_backspeed", temps);
+               cvar_set("cl_sidespeed", temps);
+               cvar_set("cl_upspeed", temps);
+       }
+}
index 45128393baee77d55b07b436b735291ae9c08e0c..196f6f193cf539598cadd7662cb8af8b269a1a8c 100644 (file)
@@ -85,14 +85,7 @@ void sys_phys_spectator_control(entity this)
 void sys_phys_fixspeed(entity this, float maxspeed_mod)
 {
        float spd = max(PHYS_MAXSPEED(this), PHYS_MAXAIRSPEED(this)) * maxspeed_mod;
-       if (this.speed != spd) {
-               this.speed = spd; // TODO: send this as a stat and set the below cvars on the client?
-               string temps = ftos(spd);
-               stuffcmd(this, strcat("cl_forwardspeed ", temps, "\n"));
-               stuffcmd(this, strcat("cl_backspeed ", temps, "\n"));
-               stuffcmd(this, strcat("cl_sidespeed ", temps, "\n"));
-               stuffcmd(this, strcat("cl_upspeed ", temps, "\n"));
-       }
+       STAT(MOVEVARS_SPEED, this) = spd;
 
        if (this.jumpspeedcap_min != autocvar_sv_jumpspeedcap_min) {
                this.jumpspeedcap_min = autocvar_sv_jumpspeedcap_min;