From: TimePath Date: Wed, 9 Mar 2016 10:38:22 +0000 (+1100) Subject: Replace uses of GetCvars with simpler REPLICATE X-Git-Tag: xonotic-v0.8.2~1139 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=80c01c94fd3d4be2b54cc6bb7f4faa2c707d6ed4;p=xonotic%2Fxonotic-data.pk3dir.git Replace uses of GetCvars with simpler REPLICATE --- diff --git a/qcsrc/common/mutators/mutator/buffs/buffs.qc b/qcsrc/common/mutators/mutator/buffs/buffs.qc index a9c56737e..30e19f0f5 100644 --- a/qcsrc/common/mutators/mutator/buffs/buffs.qc +++ b/qcsrc/common/mutators/mutator/buffs/buffs.qc @@ -1031,11 +1031,7 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerRegen) return false; } -MUTATOR_HOOKFUNCTION(buffs, GetCvars) -{ - GetCvars_handleFloat(get_cvars_s, get_cvars_f, cvar_cl_buffs_autoreplace, "cl_buffs_autoreplace"); - return false; -} +REPLICATE(cvar_cl_buffs_autoreplace, bool, "cl_buffs_autoreplace"); MUTATOR_HOOKFUNCTION(buffs, BuildMutatorsString) { diff --git a/qcsrc/common/mutators/mutator/dodging/dodging.qc b/qcsrc/common/mutators/mutator/dodging/dodging.qc index 6d3662c73..1707d0a9d 100644 --- a/qcsrc/common/mutators/mutator/dodging/dodging.qc +++ b/qcsrc/common/mutators/mutator/dodging/dodging.qc @@ -275,11 +275,7 @@ MUTATOR_HOOKFUNCTION(dodging, PlayerPhysics) #ifdef SVQC -MUTATOR_HOOKFUNCTION(dodging, GetCvars) -{ - GetCvars_handleFloat(get_cvars_s, get_cvars_f, cvar_cl_dodging_timeout, "cl_dodging_timeout"); - return false; -} +REPLICATE(cvar_cl_dodging_timeout, float, "cl_dodging_timeout"); MUTATOR_HOOKFUNCTION(dodging, GetPressedKeys) { diff --git a/qcsrc/common/mutators/mutator/multijump/multijump.qc b/qcsrc/common/mutators/mutator/multijump/multijump.qc index 43be345c1..cd369b87d 100644 --- a/qcsrc/common/mutators/mutator/multijump/multijump.qc +++ b/qcsrc/common/mutators/mutator/multijump/multijump.qc @@ -116,11 +116,7 @@ MUTATOR_HOOKFUNCTION(multijump, PlayerJump) #ifdef SVQC -MUTATOR_HOOKFUNCTION(multijump, GetCvars) -{ - GetCvars_handleFloat(get_cvars_s, get_cvars_f, cvar_cl_multijump, "cl_multijump"); - return false; -} +REPLICATE(cvar_cl_multijump, bool, "cl_multijump"); MUTATOR_HOOKFUNCTION(multijump, BuildMutatorsString) { diff --git a/qcsrc/common/mutators/mutator/nades/nades.qc b/qcsrc/common/mutators/mutator/nades/nades.qc index e80141822..12687d194 100644 --- a/qcsrc/common/mutators/mutator/nades/nades.qc +++ b/qcsrc/common/mutators/mutator/nades/nades.qc @@ -1349,13 +1349,8 @@ MUTATOR_HOOKFUNCTION(nades, SpectateCopy) return false; } -MUTATOR_HOOKFUNCTION(nades, GetCvars) -{ - GetCvars_handleFloat(get_cvars_s, get_cvars_f, cvar_cl_nade_type, "cl_nade_type"); - GetCvars_handleString(get_cvars_s, get_cvars_f, cvar_cl_pokenade_type, "cl_pokenade_type"); - - return false; -} +REPLICATE(cvar_cl_nade_type, int, "cl_nade_type"); +REPLICATE(cvar_cl_pokenade_type, string, "cl_pokenade_type"); MUTATOR_HOOKFUNCTION(nades, BuildMutatorsString) { diff --git a/qcsrc/common/mutators/mutator/spawn_near_teammate/spawn_near_teammate.qc b/qcsrc/common/mutators/mutator/spawn_near_teammate/spawn_near_teammate.qc index d94cb5397..5d3618f9e 100644 --- a/qcsrc/common/mutators/mutator/spawn_near_teammate/spawn_near_teammate.qc +++ b/qcsrc/common/mutators/mutator/spawn_near_teammate/spawn_near_teammate.qc @@ -164,9 +164,6 @@ MUTATOR_HOOKFUNCTION(spawn_near_teammate, PlayerDies) return 0; } -MUTATOR_HOOKFUNCTION(spawn_near_teammate, GetCvars) -{ - GetCvars_handleFloat(get_cvars_s, get_cvars_f, cvar_cl_spawn_near_teammate, "cl_spawn_near_teammate"); - return false; -} +REPLICATE(cvar_cl_spawn_near_teammate, bool, "cl_spawn_near_teammate"); + #endif diff --git a/qcsrc/lib/replicate.qh b/qcsrc/lib/replicate.qh index eae9a6e6f..f69b6072b 100644 --- a/qcsrc/lib/replicate.qh +++ b/qcsrc/lib/replicate.qh @@ -2,6 +2,13 @@ #ifndef MENUQC + /** + * Replicate a client cvar into a server field + * + * @param fld The field to replicate into + * @param type The field type + * @param cvar The cvar name + */ #define REPLICATE(...) EVAL_REPLICATE(OVERLOAD(REPLICATE, __VA_ARGS__)) #define EVAL_REPLICATE(...) __VA_ARGS__ diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 2a3ef8734..df0cd494b 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -375,6 +375,36 @@ string W_FixWeaponOrder_ForceComplete_AndBuildImpulseList(string wo) return o; } +REPLICATE(autoswitch, bool, "cl_autoswitch"); + +REPLICATE(cvar_cl_allow_uid2name, bool, "cl_allow_uid2name"); + +REPLICATE(cvar_cl_autoscreenshot, int, "cl_autoscreenshot"); + +REPLICATE(cvar_cl_autotaunt, float, "cl_autotaunt"); + +REPLICATE(cvar_cl_clippedspectating, bool, "cl_clippedspectating"); + +REPLICATE(cvar_cl_handicap, float, "cl_handicap"); + +REPLICATE(cvar_cl_jetpack_jump, bool, "cl_jetpack_jump"); + +REPLICATE(cvar_cl_movement_track_canjump, bool, "cl_movement_track_canjump"); + +REPLICATE(cvar_cl_newusekeysupported, bool, "cl_newusekeysupported"); + +REPLICATE(cvar_cl_noantilag, bool, "cl_noantilag"); + +REPLICATE(cvar_cl_physics, string, "cl_physics"); + +REPLICATE(cvar_cl_voice_directional, int, "cl_voice_directional"); + +REPLICATE(cvar_cl_voice_directional_taunt_attenuation, float, "cl_voice_directional_taunt_attenuation"); + +REPLICATE(cvar_cl_weaponimpulsemode, int, "cl_weaponimpulsemode"); + +REPLICATE(cvar_g_xonoticversion, string, "g_xonoticversion"); + /** * @param f -1: cleanup, 0: request, 1: receive */ @@ -393,13 +423,6 @@ void GetCvars(int f) ReplicateVars(this, s, f); - GetCvars_handleFloat(s, f, autoswitch, "cl_autoswitch"); - GetCvars_handleFloat(s, f, cvar_cl_autoscreenshot, "cl_autoscreenshot"); - GetCvars_handleFloat(s, f, cvar_cl_jetpack_jump, "cl_jetpack_jump"); - GetCvars_handleString(s, f, cvar_g_xonoticversion, "g_xonoticversion"); - GetCvars_handleString(s, f, cvar_cl_physics, "cl_physics"); - GetCvars_handleFloat(s, f, cvar_cl_handicap, "cl_handicap"); - GetCvars_handleFloat(s, f, cvar_cl_clippedspectating, "cl_clippedspectating"); GetCvars_handleString_Fixup(s, f, cvar_cl_weaponpriority, "cl_weaponpriority", W_FixWeaponOrder_ForceComplete_AndBuildImpulseList); GetCvars_handleString_Fixup(s, f, cvar_cl_weaponpriorities[0], "cl_weaponpriority0", W_FixWeaponOrder_AllowIncomplete); GetCvars_handleString_Fixup(s, f, cvar_cl_weaponpriorities[1], "cl_weaponpriority1", W_FixWeaponOrder_AllowIncomplete); @@ -411,16 +434,8 @@ void GetCvars(int f) GetCvars_handleString_Fixup(s, f, cvar_cl_weaponpriorities[7], "cl_weaponpriority7", W_FixWeaponOrder_AllowIncomplete); GetCvars_handleString_Fixup(s, f, cvar_cl_weaponpriorities[8], "cl_weaponpriority8", W_FixWeaponOrder_AllowIncomplete); GetCvars_handleString_Fixup(s, f, cvar_cl_weaponpriorities[9], "cl_weaponpriority9", W_FixWeaponOrder_AllowIncomplete); - GetCvars_handleFloat(s, f, cvar_cl_weaponimpulsemode, "cl_weaponimpulsemode"); - GetCvars_handleFloat(s, f, cvar_cl_autotaunt, "cl_autotaunt"); - GetCvars_handleFloat(s, f, cvar_cl_noantilag, "cl_noantilag"); - 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_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"); - GetCvars_handleFloat(s, f, cvar_cl_newusekeysupported, "cl_newusekeysupported"); // fixup of switchweapon (needed for LMS or when spectating is disabled, as PutClientInServer comes too early) if (f > 0)