]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Make work the string fixup function called inside REPLICATE so we can get rid of...
authorterencehill <piuntn@gmail.com>
Thu, 6 Jan 2022 22:48:34 +0000 (23:48 +0100)
committerterencehill <piuntn@gmail.com>
Thu, 6 Jan 2022 22:48:34 +0000 (23:48 +0100)
qcsrc/common/replicate.qh
qcsrc/common/weapons/all.qc
qcsrc/common/weapons/all.qh
qcsrc/lib/replicate.qh
qcsrc/server/command/getreplies.qc
qcsrc/server/main.qh
qcsrc/server/mutators/events.qh

index a8818718b1178527b12f9c44b5c88dc482827948..2c362be79306fecaccd4adaa3d7fabb100c9ae89 100644 (file)
@@ -21,8 +21,6 @@ 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
 
@@ -57,16 +55,4 @@ float cvar_cl_newusekeysupported;
 REPLICATE(cvar_cl_newusekeysupported, bool, "cl_newusekeysupported");
 */
 
-REPLICATE(cvar_cl_weaponpriority, string, "cl_weaponpriority");
-
-REPLICATE(cvar_cl_weaponpriorities[0], string, "cl_weaponpriority0");
-REPLICATE(cvar_cl_weaponpriorities[1], string, "cl_weaponpriority1");
-REPLICATE(cvar_cl_weaponpriorities[2], string, "cl_weaponpriority2");
-REPLICATE(cvar_cl_weaponpriorities[3], string, "cl_weaponpriority3");
-REPLICATE(cvar_cl_weaponpriorities[4], string, "cl_weaponpriority4");
-REPLICATE(cvar_cl_weaponpriorities[5], string, "cl_weaponpriority5");
-REPLICATE(cvar_cl_weaponpriorities[6], string, "cl_weaponpriority6");
-REPLICATE(cvar_cl_weaponpriorities[7], string, "cl_weaponpriority7");
-REPLICATE(cvar_cl_weaponpriorities[8], string, "cl_weaponpriority8");
-REPLICATE(cvar_cl_weaponpriorities[9], string, "cl_weaponpriority9");
 #endif
index 7ef3cc1e8d7a5ee18ff37591f899d635d8e0ee6d..f44668061f16083c7ee0e57ebea5674a95e7f75d 100644 (file)
@@ -826,3 +826,12 @@ NET_HANDLE(w_muzzleflash, bool isNew)
 #endif
 
 #endif
+
+#ifdef SVQC
+string W_FixWeaponOrder_ForceComplete_AndBuildImpulseList(entity this, string wo)
+{
+       string o = W_FixWeaponOrder_ForceComplete(wo);
+       strcpy(CS_CVAR(this).weaponorder_byimpulse, W_FixWeaponOrder_BuildImpulseList(o));
+       return o;
+}
+#endif
index 24057a0b8348209686ba56c3242df57f1889576e..0016790c86ef2b584c3599ae44d33db4aa7f6d1f 100644 (file)
@@ -403,9 +403,25 @@ REPLICATE(cvar_cl_accuracy_data_receive, bool, "cl_accuracy_data_receive");
 
 #ifdef SVQC
 void wframe_send(entity actor, entity weaponentity, int wepframe, float attackrate, bool restartanim);
-#endif
 
-#ifdef SVQC
 void W_MuzzleFlash(Weapon thiswep, entity actor, .entity weaponentity, vector shotorg, vector shotdir);
+
+string W_FixWeaponOrder_ForceComplete_AndBuildImpulseList(entity this, string wo);
+string W_FixWeaponOrder_AllowIncomplete(entity this, string order);
 #endif
+
+REPLICATE_FIELD(string, cvar_cl_weaponpriority);
+REPLICATE_FIELD(string, cvar_cl_weaponpriorities[10]);
+REPLICATE(cvar_cl_weaponpriority, string, "cl_weaponpriority", W_FixWeaponOrder_ForceComplete_AndBuildImpulseList);
+REPLICATE(cvar_cl_weaponpriorities[0], string, "cl_weaponpriority0", W_FixWeaponOrder_AllowIncomplete);
+REPLICATE(cvar_cl_weaponpriorities[1], string, "cl_weaponpriority1", W_FixWeaponOrder_AllowIncomplete);
+REPLICATE(cvar_cl_weaponpriorities[2], string, "cl_weaponpriority2", W_FixWeaponOrder_AllowIncomplete);
+REPLICATE(cvar_cl_weaponpriorities[3], string, "cl_weaponpriority3", W_FixWeaponOrder_AllowIncomplete);
+REPLICATE(cvar_cl_weaponpriorities[4], string, "cl_weaponpriority4", W_FixWeaponOrder_AllowIncomplete);
+REPLICATE(cvar_cl_weaponpriorities[5], string, "cl_weaponpriority5", W_FixWeaponOrder_AllowIncomplete);
+REPLICATE(cvar_cl_weaponpriorities[6], string, "cl_weaponpriority6", W_FixWeaponOrder_AllowIncomplete);
+REPLICATE(cvar_cl_weaponpriorities[7], string, "cl_weaponpriority7", W_FixWeaponOrder_AllowIncomplete);
+REPLICATE(cvar_cl_weaponpriorities[8], string, "cl_weaponpriority8", W_FixWeaponOrder_AllowIncomplete);
+REPLICATE(cvar_cl_weaponpriorities[9], string, "cl_weaponpriority9", W_FixWeaponOrder_AllowIncomplete);
+
 #endif
index 44a185d495d8235e99b9c8962fc6bd651cbd2752..873db04b81ed918a746c7373541f372c81818902 100644 (file)
@@ -1,5 +1,9 @@
 #pragma once
 
+#ifdef SVQC
+// copies a string to a tempstring (so one can strunzone it)
+string strcat1(string s) = #115; // FRIK_FILE
+#endif
 
 #if defined(CSQC)
 #define REPLICATE_FIELD(type, name) type name
@@ -34,7 +38,7 @@
                { strfree(field); }, \
                { \
                        /* also initialize to the default value of func when requesting cvars */ \
-                       string s = func(field); \
+                       string s = func(this, strcat1(field)); \
                        if (s != field) \
                        { \
                                strcpy(field, s); \
index c6e967de319de0e9320f988f347f3669fe246051..96ad99af068f8aa4b18b4e9d47c9782cf626d495 100644 (file)
@@ -304,6 +304,7 @@ string getmonsterlist()
 =============
 GetCvars
 =============
+Superseded by REPLICATE
 Called with:
   0:  sends the request
   >0: receives a cvar from name=argv(f) value=argv(f+1)
@@ -373,12 +374,6 @@ void GetCvars_handleFloatOnce(entity this, entity store, string thisname, float
                        stuffcmd(this, strcat("cl_cmd sendcvar ", name, "\n"));
        }
 }
-string W_FixWeaponOrder_ForceComplete_AndBuildImpulseList(entity this, string wo)
-{
-       string o = W_FixWeaponOrder_ForceComplete(wo);
-       strcpy(CS_CVAR(this).weaponorder_byimpulse, W_FixWeaponOrder_BuildImpulseList(o));
-       return o;
-}
 
 /**
  * @param f -1: cleanup, 0: request, 1: receive
@@ -401,18 +396,6 @@ void GetCvars(entity this, entity store, int f)
 
        ReplicateVars(this, store, s, f);
 
-       GetCvars_handleString_Fixup(this, store, s, f, cvar_cl_weaponpriority, "cl_weaponpriority", W_FixWeaponOrder_ForceComplete_AndBuildImpulseList);
-       GetCvars_handleString_Fixup(this, store, s, f, cvar_cl_weaponpriorities[0], "cl_weaponpriority0", W_FixWeaponOrder_AllowIncomplete);
-       GetCvars_handleString_Fixup(this, store, s, f, cvar_cl_weaponpriorities[1], "cl_weaponpriority1", W_FixWeaponOrder_AllowIncomplete);
-       GetCvars_handleString_Fixup(this, store, s, f, cvar_cl_weaponpriorities[2], "cl_weaponpriority2", W_FixWeaponOrder_AllowIncomplete);
-       GetCvars_handleString_Fixup(this, store, s, f, cvar_cl_weaponpriorities[3], "cl_weaponpriority3", W_FixWeaponOrder_AllowIncomplete);
-       GetCvars_handleString_Fixup(this, store, s, f, cvar_cl_weaponpriorities[4], "cl_weaponpriority4", W_FixWeaponOrder_AllowIncomplete);
-       GetCvars_handleString_Fixup(this, store, s, f, cvar_cl_weaponpriorities[5], "cl_weaponpriority5", W_FixWeaponOrder_AllowIncomplete);
-       GetCvars_handleString_Fixup(this, store, s, f, cvar_cl_weaponpriorities[6], "cl_weaponpriority6", W_FixWeaponOrder_AllowIncomplete);
-       GetCvars_handleString_Fixup(this, store, s, f, cvar_cl_weaponpriorities[7], "cl_weaponpriority7", W_FixWeaponOrder_AllowIncomplete);
-       GetCvars_handleString_Fixup(this, store, s, f, cvar_cl_weaponpriorities[8], "cl_weaponpriority8", W_FixWeaponOrder_AllowIncomplete);
-       GetCvars_handleString_Fixup(this, store, s, f, cvar_cl_weaponpriorities[9], "cl_weaponpriority9", W_FixWeaponOrder_AllowIncomplete);
-
        // fixup of switchweapon (needed for LMS or when spectating is disabled, as PutClientInServer comes too early)
        if (f > 0)
        {
index e189601a7c467cf9f757616fbc9ada286c9d62ae..172e0a9e5719c0e1efe37faf3e43bf6e17f34859 100644 (file)
@@ -28,9 +28,6 @@ void remove_safely(entity e);
 
 void remove_unsafely(entity e);
 
-// copies a string to a tempstring (so one can strunzone it)
-string strcat1(string s) = #115; // FRIK_FILE
-
 #ifdef PROFILING
 float client_cefc_accumulator;
 float client_cefc_accumulatortime;
index ee5d18a69157a9d6210bc211ed0f813748578442..c9c8ab8517be036b29d6c1ec9d5798aee2eb41f1 100644 (file)
@@ -317,8 +317,17 @@ MUTATOR_HOOKABLE(PlayerPreThink, EV_PlayerPreThink);
     /**/
 MUTATOR_HOOKABLE(GetPressedKeys, EV_GetPressedKeys);
 
-/** is meant to call GetCvars_handle*(get_cvars_s, get_cvars_f, cvarfield, "cvarname") for cvars this mutator needs from the client */
-// NOTE: requesting cvar values (get_cvars_f 0) is deprecated
+/**
+ * is meant to call GetCvars_handle* for cvars this mutator needs from the client, e.g.:
+       MUTATOR_HOOKFUNCTION(mymutator, GetCvars)
+       {
+               GetCvars_handleFloat(this, store, s, f, cvar_mycvar, "mycvar");
+               return false;
+       }
+ * Usually you can just use REPLICATE instead of this hook, e.g.:
+       REPLICATE(cvar_mycvar, int, "mycvar");
+ * NOTE: requesting cvar values (get_cvars_f 0) is deprecated
+ */
 #define EV_GetCvars(i, o) \
     /**/ i(float, get_cvars_f) \
     /**/ i(string, get_cvars_s) \