From: terencehill Date: Thu, 6 Jan 2022 20:30:52 +0000 (+0100) Subject: Add REPLICATE_FIELD X-Git-Tag: xonotic-v0.8.5~204^2~12 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=ef1075d628096668bbcfceeb3e51a1199ed3e989;p=xonotic%2Fxonotic-data.pk3dir.git Add REPLICATE_FIELD --- diff --git a/qcsrc/common/replicate.qh b/qcsrc/common/replicate.qh index 127ee3082..cf04d778d 100644 --- a/qcsrc/common/replicate.qh +++ b/qcsrc/common/replicate.qh @@ -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"); diff --git a/qcsrc/common/weapons/weapon/seeker.qc b/qcsrc/common/weapons/weapon/seeker.qc index c782b4eaf..cdf7d6a2e 100644 --- a/qcsrc/common/weapons/weapon/seeker.qc +++ b/qcsrc/common/weapons/weapon/seeker.qc @@ -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; } } /////////////// diff --git a/qcsrc/lib/replicate.qh b/qcsrc/lib/replicate.qh index 64d893a10..44a185d49 100644 --- a/qcsrc/lib/replicate.qh +++ b/qcsrc/lib/replicate.qh @@ -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 /** diff --git a/qcsrc/server/client.qh b/qcsrc/server/client.qh index b3ba22abd..fe0d7a8ff 100644 --- a/qcsrc/server/client.qh +++ b/qcsrc/server/client.qh @@ -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); diff --git a/qcsrc/server/command/cmd.qc b/qcsrc/server/command/cmd.qc index c9ceb31b6..672079ef4 100644 --- a/qcsrc/server/command/cmd.qc +++ b/qcsrc/server/command/cmd.qc @@ -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; } } diff --git a/qcsrc/server/items/items.qc b/qcsrc/server/items/items.qc index ade4795c5..8c1281307 100644 --- a/qcsrc/server/items/items.qc +++ b/qcsrc/server/items/items.qc @@ -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) {