From 47b3f2cb8ec72e825516be688bc9239443a24708 Mon Sep 17 00:00:00 2001 From: TimePath Date: Fri, 18 Dec 2015 09:27:15 +1100 Subject: [PATCH] cl_gunalign: stat. Fixes #1607 --- qcsrc/client/autocvars.qh | 1 - qcsrc/common/stats.qh | 15 +++++++++++++++ qcsrc/common/weapons/all.qc | 6 +----- qcsrc/common/weapons/calculations.qc | 6 +----- qcsrc/server/defs.qh | 1 - qcsrc/server/miscfunctions.qc | 1 - 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/qcsrc/client/autocvars.qh b/qcsrc/client/autocvars.qh index 4697319d1..49cafb896 100644 --- a/qcsrc/client/autocvars.qh +++ b/qcsrc/client/autocvars.qh @@ -53,7 +53,6 @@ float autocvar_cl_gibs_velocity_random = 1; float autocvar_cl_gibs_velocity_scale = 1; float autocvar_cl_gibs_avelocity_scale = 1; float autocvar_cl_gibs_velocity_up; -int autocvar_cl_gunalign; bool autocvar_cl_hidewaypoints; bool autocvar_cl_lockview; bool autocvar_cl_nogibs; diff --git a/qcsrc/common/stats.qh b/qcsrc/common/stats.qh index 300442866..fc82c1320 100644 --- a/qcsrc/common/stats.qh +++ b/qcsrc/common/stats.qh @@ -292,4 +292,19 @@ REGISTER_STAT(MOVEVARS_MAXAIRSPEED, float) REGISTER_STAT(MOVEVARS_STEPHEIGHT, float, autocvar_sv_stepheight) REGISTER_STAT(MOVEVARS_AIRACCEL_QW, float) REGISTER_STAT(MOVEVARS_AIRACCEL_SIDEWAYS_FRICTION, float) + + +#ifdef CSQC +noref int autocvar_cl_gunalign; +#endif +#ifdef SVQC +.int cvar_cl_gunalign; +REPLICATE(cvar_cl_gunalign, int, "cl_gunalign"); +#endif +REGISTER_STAT(GUNALIGN, int, this.cvar_cl_gunalign) +#ifdef SVQC +SPECTATE_COPY(_STAT(GUNALIGN)) +#endif + + #endif diff --git a/qcsrc/common/weapons/all.qc b/qcsrc/common/weapons/all.qc index b18d6991a..7d107fd61 100644 --- a/qcsrc/common/weapons/all.qc +++ b/qcsrc/common/weapons/all.qc @@ -517,11 +517,7 @@ void CL_WeaponEntity_SetModel(entity this, string name) if (this.movedir.x >= 0) { -#ifdef SVQC - int algn = this.owner.cvar_cl_gunalign; -#else - int algn = autocvar_cl_gunalign; -#endif + int algn = STAT(GUNALIGN, this.owner); vector v = this.movedir; this.movedir = shotorg_adjust(v, false, false, algn); this.view_ofs = shotorg_adjust(v, false, true, algn) - v; diff --git a/qcsrc/common/weapons/calculations.qc b/qcsrc/common/weapons/calculations.qc index 97c1999f8..1a4888434 100644 --- a/qcsrc/common/weapons/calculations.qc +++ b/qcsrc/common/weapons/calculations.qc @@ -144,11 +144,7 @@ vector findperpendicular(vector v) int W_GetGunAlignment(entity player) { -#ifdef SVQC - int gunalign = player.cvar_cl_gunalign; -#else - int gunalign = autocvar_cl_gunalign; -#endif + int gunalign = STAT(GUNALIGN, player); if(gunalign < 1 || gunalign > 4) gunalign = 3; // default value --gunalign; diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index 1aa3059c8..1674f6d1d 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -205,7 +205,6 @@ float default_weapon_alpha; .string cvar_g_xonoticversion; .string cvar_cl_weaponpriority; .string cvar_cl_weaponpriorities[10]; -.float cvar_cl_gunalign; .float cvar_cl_noantilag; .string weaponorder_byimpulse; diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 7e8f4cfd3..3c4897b09 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -417,7 +417,6 @@ void GetCvars(int f) GetCvars_handleFloat(s, f, cvar_cl_voice_directional, "cl_voice_directional"); GetCvars_handleFloat(s, f, cvar_cl_voice_directional_taunt_attenuation, "cl_voice_directional_taunt_attenuation"); - GetCvars_handleFloatOnce(s, f, cvar_cl_gunalign, "cl_gunalign"); GetCvars_handleFloat(s, f, cvar_cl_allow_uid2name, "cl_allow_uid2name"); GetCvars_handleFloat(s, f, cvar_cl_allow_uidtracking, "cl_allow_uidtracking"); GetCvars_handleFloat(s, f, cvar_cl_movement_track_canjump, "cl_movement_track_canjump"); -- 2.39.2