]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Send the speed value as a stat and do the setting of client cvars on the client
authorMario <mario@smbclan.net>
Fri, 26 Oct 2018 07:59:30 +0000 (17:59 +1000)
committerMario <mario@smbclan.net>
Fri, 26 Oct 2018 07:59:30 +0000 (17:59 +1000)
qcsrc/common/stats.qh
qcsrc/ecs/systems/cl_physics.qc
qcsrc/ecs/systems/sv_physics.qc

index cf51ea66b3ebf7b24d86c16c89756347fa5bca0c..16204679879de62729bc9cc9a04a2e82ff04508c 100644 (file)
@@ -318,6 +318,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 fa087b5eb48bbb29c78bee163e703ee7e9e60a3a..848000db3a6b142da8a8e29ae7c09a1e3b21ab8a 100644 (file)
@@ -25,4 +25,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;