]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
replicate autoreload and impulse fallback cvars 616/head
authorMartin Taibr <taibr.martin@gmail.com>
Sun, 21 Oct 2018 16:32:10 +0000 (18:32 +0200)
committerMartin Taibr <taibr.martin@gmail.com>
Sun, 21 Oct 2018 16:32:10 +0000 (18:32 +0200)
qcsrc/client/main.qc
qcsrc/server/client.qh
qcsrc/server/defs.qh
qcsrc/server/miscfunctions.qc
qcsrc/server/weapons/selection.qc

index 51324e1c5e09aa320895b35d1725ba572d21382d..e32c0e8f57568bf4f63380368cab0570a2754874 100644 (file)
@@ -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");
 
index f8a7e2ab5fa4063b29ebe4c96c7f32ddfca42127..6cf13da2a43746c4bdc49481e991a3fe39b18ec8 100644 (file)
@@ -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));
 
index e667906f1dddb3351a48b6d9c5543fdadcf39f4d..5b5d8a66b78a017e5f077e975592e94b0b65227d 100644 (file)
@@ -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;
index 47c0cb2fe4615af49105c651d2bc3192c9452b5f..035891e5b19c0205bac6ef228d91ecbb3f974c5d 100644 (file)
@@ -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
  */
index b4c13851bf47514c57a0212e5d2df0e0a4bcc627..ea5bd22551cec73cc63b9578665b9be0dd8bf25f 100644 (file)
@@ -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);
 }