From ca28b3282b10ed5651fbd2e2e03912f8a591ecc0 Mon Sep 17 00:00:00 2001 From: Martin Taibr Date: Sun, 21 Oct 2018 18:32:10 +0200 Subject: [PATCH] replicate autoreload and impulse fallback cvars --- qcsrc/client/main.qc | 3 +++ qcsrc/server/client.qh | 2 ++ qcsrc/server/defs.qh | 2 ++ qcsrc/server/miscfunctions.qc | 4 ++++ qcsrc/server/weapons/selection.qc | 6 ++---- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index 51324e1c5e..e32c0e8f57 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -140,6 +140,9 @@ void CSQC_Init() registercvar("cl_spawn_near_teammate", "1"); + registercvar("cl_weapon_switch_reload", "1"); + registercvar("cl_weapon_switch_fallback_to_impulse", "1"); + if(autocvar_cl_lockview) cvar_set("cl_lockview", "0"); diff --git a/qcsrc/server/client.qh b/qcsrc/server/client.qh index f8a7e2ab5f..6cf13da2a4 100644 --- a/qcsrc/server/client.qh +++ b/qcsrc/server/client.qh @@ -146,6 +146,8 @@ CLASS(Client, Object) ATTRIBARRAY(Client, cvar_cl_weaponpriorities, string, 10); ATTRIB(Client, cvar_cl_weaponpriority, string, this.cvar_cl_weaponpriority); ATTRIB(Client, cvar_cl_cts_noautoswitch, bool, this.cvar_cl_cts_noautoswitch); + ATTRIB(Client, cvar_cl_weapon_switch_reload, bool, this.cvar_cl_weapon_switch_reload); + ATTRIB(Client, cvar_cl_weapon_switch_fallback_to_impulse, bool, this.cvar_cl_weapon_switch_fallback_to_impulse); METHOD(Client, m_unwind, bool(Client this)); diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index e667906f1d..5b5d8a66b7 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -169,6 +169,8 @@ float default_weapon_alpha; .float cvar_cl_movement_track_canjump; .float cvar_cl_newusekeysupported; .float cvar_cl_cts_noautoswitch; +.bool cvar_cl_weapon_switch_reload; +.bool cvar_cl_weapon_switch_fallback_to_impulse; .string cvar_g_xonoticversion; .string cvar_cl_weaponpriority; diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 47c0cb2fe4..035891e5b1 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -418,6 +418,10 @@ REPLICATE(cvar_g_xonoticversion, string, "g_xonoticversion"); REPLICATE(cvar_cl_cts_noautoswitch, bool, "cl_cts_noautoswitch"); +REPLICATE(cvar_cl_weapon_switch_reload, bool, "cl_weapon_switch_reload"); + +REPLICATE(cvar_cl_weapon_switch_fallback_to_impulse, bool, "cl_weapon_switch_fallback_to_impulse"); + /** * @param f -1: cleanup, 0: request, 1: receive */ diff --git a/qcsrc/server/weapons/selection.qc b/qcsrc/server/weapons/selection.qc index b4c13851bf..ea5bd22551 100644 --- a/qcsrc/server/weapons/selection.qc +++ b/qcsrc/server/weapons/selection.qc @@ -266,7 +266,6 @@ void W_SwitchToOtherWeapon(entity this, .entity weaponentity) W_SwitchWeapon_Force(this, ww, weaponentity); } -AUTOCVAR_SAVE(cl_weapon_switch_reload, bool, true, "When trying to switch to the currently held weapon, reload it"); bool W_SwitchWeapon(entity this, Weapon w, .entity weaponentity) { if(this.(weaponentity).m_switchweapon != w) @@ -282,7 +281,7 @@ bool W_SwitchWeapon(entity this, Weapon w, .entity weaponentity) return false; } } - else if(!forbidWeaponUse(this) && autocvar_cl_weapon_switch_reload) + else if(!forbidWeaponUse(this) && CS(this).cvar_cl_weapon_switch_reload) { entity actor = this; w.wr_reload(w, actor, weaponentity); @@ -291,10 +290,9 @@ bool W_SwitchWeapon(entity this, Weapon w, .entity weaponentity) return true; // player already has the weapon out or needs to reload } -AUTOCVAR_SAVE(cl_weapon_switch_fallback_to_impulse, bool, true, "When trying to switch to a weapon that is not available, switch to an alternative from the same impulse"); void W_SwitchWeapon_TryOthers(entity this, Weapon w, .entity weaponentity) { - if(!W_SwitchWeapon(this, w, weaponentity) && autocvar_cl_weapon_switch_fallback_to_impulse) + if(!W_SwitchWeapon(this, w, weaponentity) && CS(this).cvar_cl_weapon_switch_fallback_to_impulse) W_NextWeaponOnImpulse(this, w.impulse, weaponentity); } -- 2.39.2