]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add REPLICATE_FIELD
authorterencehill <piuntn@gmail.com>
Thu, 6 Jan 2022 20:30:52 +0000 (21:30 +0100)
committerterencehill <piuntn@gmail.com>
Thu, 6 Jan 2022 20:47:55 +0000 (21:47 +0100)
qcsrc/common/replicate.qh
qcsrc/common/weapons/weapon/seeker.qc
qcsrc/lib/replicate.qh
qcsrc/server/client.qh
qcsrc/server/command/cmd.qc
qcsrc/server/items/items.qc

index 127ee308255ceae7287011f1f3b13e013e916525..cf04d778d6b8330d90ba77eb179639220eb74f63 100644 (file)
@@ -1,66 +1,38 @@
 #pragma once
 
-// TODO: sort/merge these!
-#if defined(CSQC)
-       float autoswitch;
-       bool cvar_cl_allow_uid2name;
-       float cvar_cl_allow_uidtracking;
-       bool cvar_cl_allow_uidranking;
-       float cvar_cl_autoscreenshot;
-       float cvar_cl_autotaunt;
-       bool cvar_cl_clippedspectating;
-       int cvar_cl_gunalign;
-       float cvar_cl_handicap;
-       float cvar_cl_jetpack_jump;
-       float cvar_cl_movement_track_canjump;
-       float cvar_cl_noantilag;
-       string cvar_cl_physics;
-       float cvar_cl_voice_directional;
-       float cvar_cl_voice_directional_taunt_attenuation;
-       float cvar_cl_weaponimpulsemode;
-
-       string cvar_g_xonoticversion;
-       string cvar_cl_weaponpriority;
-       string cvar_cl_weaponpriorities[10];
-       float cvar_cl_cts_noautoswitch;
-       bool cvar_cl_weapon_switch_reload;
-       bool cvar_cl_weapon_switch_fallback_to_impulse;
-#elif defined(SVQC)
-       .float cvar_cl_handicap;
-       .int cvar_cl_gunalign;
-       .bool cvar_cl_clippedspectating;
-       .float cvar_cl_autoscreenshot;
-       .float cvar_cl_jetpack_jump;
-       .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;
-       .string cvar_cl_weaponpriorities[10];
-       .float cvar_cl_noantilag;
-
-       // WEAPONTODO
-       .float autoswitch;
-       .float cvar_cl_weaponimpulsemode;
-
-       .float cvar_cl_allow_uid2name;
-       .float cvar_cl_allow_uidtracking;
-       .bool cvar_cl_allow_uidranking;
-
-       .string cvar_cl_physics;
+#ifdef GAMEQC
+// TODO: merge into REPLICATE
+REPLICATE_FIELD(bool, cvar_cl_autoswitch);
+REPLICATE_FIELD(int, cvar_cl_allow_uid2name);
+REPLICATE_FIELD(bool, cvar_cl_allow_uidranking);
+REPLICATE_FIELD(int, cvar_cl_allow_uidtracking);
+REPLICATE_FIELD(int, cvar_cl_autoscreenshot);
+REPLICATE_FIELD(float, cvar_cl_autotaunt);
+REPLICATE_FIELD(bool, cvar_cl_clippedspectating);
+REPLICATE_FIELD(bool, cvar_cl_cts_noautoswitch);
+REPLICATE_FIELD(int, cvar_cl_gunalign);
+REPLICATE_FIELD(float, cvar_cl_handicap);
+REPLICATE_FIELD(bool, cvar_cl_jetpack_jump);
+REPLICATE_FIELD(bool, cvar_cl_movement_track_canjump);
+REPLICATE_FIELD(bool, cvar_cl_noantilag);
+REPLICATE_FIELD(string, cvar_cl_physics);
+REPLICATE_FIELD(int, cvar_cl_voice_directional);
+REPLICATE_FIELD(float, cvar_cl_voice_directional_taunt_attenuation);
+REPLICATE_FIELD(bool, cvar_cl_weapon_switch_reload);
+REPLICATE_FIELD(bool, cvar_cl_weapon_switch_fallback_to_impulse);
+REPLICATE_FIELD(int, cvar_cl_weaponimpulsemode);
+REPLICATE_FIELD(string, cvar_cl_weaponpriority);
+REPLICATE_FIELD(string, cvar_cl_weaponpriorities[10]);
+REPLICATE_FIELD(string, cvar_g_xonoticversion);
+#endif
 
-       // autotaunt system
-       .float cvar_cl_autotaunt;
-       .float cvar_cl_voice_directional;
-       .float cvar_cl_voice_directional_taunt_attenuation;
+#ifdef SVQC
+.float cvar_cl_newusekeysupported;
 #endif
 
 #ifdef GAMEQC
-REPLICATE(autoswitch, bool, "cl_autoswitch");
-REPLICATE(cvar_cl_allow_uid2name, bool, "cl_allow_uid2name");
+REPLICATE(cvar_cl_autoswitch, bool, "cl_autoswitch");
+REPLICATE(cvar_cl_allow_uid2name, int, "cl_allow_uid2name");
 REPLICATE(cvar_cl_allow_uidranking, bool, "cl_allow_uidranking");
 REPLICATE(cvar_cl_autoscreenshot, int, "cl_autoscreenshot");
 REPLICATE(cvar_cl_autotaunt, float, "cl_autotaunt");
index c782b4eafc55de68a6d555359d617f17a5ae5efc..cdf7d6a2e3e3f83b3bd41a88bee123cce6597690 100644 (file)
@@ -86,23 +86,23 @@ void W_Seeker_Missile_Think(entity this)
        {
                if(dist <= WEP_CVAR(seeker, missile_proxy_maxrange))
                {
-                       if(this.autoswitch == 0)
+                       if(this.cvar_cl_autoswitch == 0)
                        {
-                               this.autoswitch = time + WEP_CVAR(seeker, missile_proxy_delay);
+                               this.cvar_cl_autoswitch = time + WEP_CVAR(seeker, missile_proxy_delay);
                        }
                        else
                        {
-                               if(this.autoswitch <= time)
+                               if(this.cvar_cl_autoswitch <= time)
                                {
                                        W_Seeker_Missile_Explode(this, NULL);
-                                       this.autoswitch = 0;
+                                       this.cvar_cl_autoswitch = 0;
                                }
                        }
                }
                else
                {
-                       if(this.autoswitch != 0)
-                               this.autoswitch = 0;
+                       if(this.cvar_cl_autoswitch != 0)
+                               this.cvar_cl_autoswitch = 0;
                }
        }
        ///////////////
index 64d893a103b3dc53de35ca4e5eb736830c352b3a..44a185d495d8235e99b9c8962fc6bd651cbd2752 100644 (file)
@@ -1,5 +1,12 @@
 #pragma once
 
+
+#if defined(CSQC)
+#define REPLICATE_FIELD(type, name) type name
+#elif defined(SVQC)
+#define REPLICATE_FIELD(type, name) .type name
+#endif
+
 #ifdef GAMEQC
 
     /**
index b3ba22abd8738371809ab3b5e1f9b4e927dca192..fe0d7a8ffa278ee6ff95a428f51adcda79943b04 100644 (file)
@@ -216,7 +216,7 @@ CLASS(Client, Object)
     ATTRIB(Client, cvar_cl_movement_track_canjump, bool, this.cvar_cl_movement_track_canjump);
     ATTRIB(Client, cvar_cl_weaponimpulsemode, int, this.cvar_cl_weaponimpulsemode);
     ATTRIB(Client, cvar_g_xonoticversion, string, this.cvar_g_xonoticversion);
-    ATTRIB(Client, autoswitch, bool, this.autoswitch);
+    ATTRIB(Client, cvar_cl_autoswitch, bool, this.cvar_cl_autoswitch);
     ATTRIB(Client, cvar_cl_casings, bool, this.cvar_cl_casings);
     ATTRIB(Client, cvar_r_drawviewmodel, bool, this.cvar_r_drawviewmodel);
     ATTRIB(Client, cvar_cl_dodging_timeout, float, this.cvar_cl_dodging_timeout);
index c9ceb31b6dc14cc09d4fe24c4d1a9446ec27cb97..672079ef421a2fa82988dd8941887eb19872366d 100644 (file)
@@ -73,8 +73,8 @@ void ClientCommand_autoswitch(entity caller, int request, int argc)
                {
                        if (argv(1) != "")
                        {
-                               CS_CVAR(caller).autoswitch = InterpretBoolean(argv(1));
-                               sprint(caller, strcat("^1autoswitch is currently turned ", (CS_CVAR(caller).autoswitch ? "on" : "off"), ".\n"));
+                               CS_CVAR(caller).cvar_cl_autoswitch = InterpretBoolean(argv(1));
+                               sprint(caller, strcat("^1autoswitch is currently turned ", (CS_CVAR(caller).cvar_cl_autoswitch ? "on" : "off"), ".\n"));
                                return;
                        }
                }
index ade4795c523e420e56c77f4f5b5164cbc8250179..8c1281307b20ef15ce32d342bb0eea2d592b483e 100644 (file)
@@ -483,7 +483,7 @@ bool Item_GiveTo(entity item, entity player)
        // if the player is using their best weapon before items are given, they
        // probably want to switch to an even better weapon after items are given
 
-       if(CS_CVAR(player).autoswitch)
+       if(CS_CVAR(player).cvar_cl_autoswitch)
        {
                for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
                {
@@ -1512,7 +1512,7 @@ float GiveItems(entity e, float beginarg, float endarg)
 
        int _switchweapon = 0;
 
-       if(CS_CVAR(e).autoswitch)
+       if(CS_CVAR(e).cvar_cl_autoswitch)
        {
                for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
                {