From 35d6275275bc926fccf5f3aa9f4b38b74c506aa3 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 26 Oct 2018 17:59:30 +1000 Subject: [PATCH] Send the speed value as a stat and do the setting of client cvars on the client --- qcsrc/common/stats.qh | 2 ++ qcsrc/ecs/systems/cl_physics.qc | 13 ++++++++++++- qcsrc/ecs/systems/sv_physics.qc | 9 +-------- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/qcsrc/common/stats.qh b/qcsrc/common/stats.qh index cf51ea66b..162046798 100644 --- a/qcsrc/common/stats.qh +++ b/qcsrc/common/stats.qh @@ -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) diff --git a/qcsrc/ecs/systems/cl_physics.qc b/qcsrc/ecs/systems/cl_physics.qc index fa087b5eb..848000db3 100644 --- a/qcsrc/ecs/systems/cl_physics.qc +++ b/qcsrc/ecs/systems/cl_physics.qc @@ -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); + } +} diff --git a/qcsrc/ecs/systems/sv_physics.qc b/qcsrc/ecs/systems/sv_physics.qc index 45128393b..196f6f193 100644 --- a/qcsrc/ecs/systems/sv_physics.qc +++ b/qcsrc/ecs/systems/sv_physics.qc @@ -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; -- 2.39.2