From 341b4c12077dfdb6a5a4c4245ceea1fbba7ed6b6 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 6 Dec 2020 14:06:35 +1000 Subject: [PATCH] Add a wrapper for networked cvars and attach them to the client rather than the clientstate, possible fix for rare cases where players wouldn't be recorded in stats due to their data never being added (commands are able to be executed before clientstate exists) --- qcsrc/common/effects/qc/casings.qc | 4 +-- qcsrc/common/effects/qc/globalsound.qc | 10 +++---- qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc | 2 +- qcsrc/common/gamemodes/gamemode/cts/sv_cts.qc | 2 +- .../common/gamemodes/gamemode/race/sv_race.qc | 2 +- .../common/mutators/mutator/buffs/sv_buffs.qc | 4 +-- .../mutators/mutator/dodging/sv_dodging.qc | 4 +-- .../mutators/mutator/multijump/multijump.qc | 2 +- qcsrc/common/mutators/mutator/nades/nades.qc | 10 +++---- .../sv_spawn_near_teammate.qc | 4 +-- qcsrc/common/notifications/all.qc | 4 +-- qcsrc/common/notifications/all.qh | 2 +- qcsrc/common/physics/player.qc | 6 ++--- qcsrc/common/physics/player.qh | 2 +- qcsrc/common/playerstats.qc | 4 +-- qcsrc/common/state.qc | 2 +- qcsrc/common/state.qh | 3 +++ qcsrc/common/weapons/weapon/shockwave.qc | 2 +- qcsrc/server/antilag.qc | 10 +++---- qcsrc/server/bot/default/bot.qc | 4 +-- qcsrc/server/client.qc | 26 +++++++++---------- qcsrc/server/command/cmd.qc | 8 +++--- qcsrc/server/command/getreplies.qc | 4 +-- qcsrc/server/handicap.qc | 2 +- qcsrc/server/impulse.qc | 2 +- qcsrc/server/intermission.qc | 4 +-- qcsrc/server/items/items.qc | 6 ++--- qcsrc/server/weapons/accuracy.qc | 2 +- qcsrc/server/weapons/selection.qc | 14 +++++----- qcsrc/server/weapons/selection.qh | 2 +- qcsrc/server/weapons/tracing.qc | 2 +- 31 files changed, 79 insertions(+), 76 deletions(-) diff --git a/qcsrc/common/effects/qc/casings.qc b/qcsrc/common/effects/qc/casings.qc index 3a6b38642..d5af50fb3 100644 --- a/qcsrc/common/effects/qc/casings.qc +++ b/qcsrc/common/effects/qc/casings.qc @@ -27,9 +27,9 @@ void SpawnCasing(vector vel, float randomvel, vector ang, vector avel, float ran org = casingowner.origin + casingowner.view_ofs + org.x * v_forward - org.y * v_right + org.z * v_up; FOREACH_CLIENT(true, { - if (!(CS(it).cvar_cl_casings)) + if (!(CS_CVAR(it).cvar_cl_casings)) continue; - if (it == casingowner && !(CS(it).cvar_r_drawviewmodel)) + if (it == casingowner && !(CS_CVAR(it).cvar_r_drawviewmodel)) continue; msg_entity = it; diff --git a/qcsrc/common/effects/qc/globalsound.qc b/qcsrc/common/effects/qc/globalsound.qc index 3e855c69b..43a489105 100644 --- a/qcsrc/common/effects/qc/globalsound.qc +++ b/qcsrc/common/effects/qc/globalsound.qc @@ -331,7 +331,7 @@ msg_entity = this.pusher; if (IS_REAL_CLIENT(msg_entity)) { - float atten = (CS(msg_entity).cvar_cl_voice_directional == 1) ? ATTEN_MIN : ATTEN_NONE; + float atten = (CS_CVAR(msg_entity).cvar_cl_voice_directional == 1) ? ATTEN_MIN : ATTEN_NONE; if (gs) globalsound(MSG_ONE, this, gs, r, chan, vol, atten, thepitch); else if (ps) playersound(MSG_ONE, this, ps, r, chan, vol, atten, thepitch); else soundto(MSG_ONE, this, chan, sample, vol, atten, thepitch); @@ -351,7 +351,7 @@ { #define X() \ MACRO_BEGIN \ - float atten = (CS(msg_entity).cvar_cl_voice_directional == 1) ? ATTEN_MIN : ATTEN_NONE; \ + float atten = (CS_CVAR(msg_entity).cvar_cl_voice_directional == 1) ? ATTEN_MIN : ATTEN_NONE; \ if (gs) globalsound(MSG_ONE, this, gs, r, chan, vol, atten, thepitch); \ else if (ps) playersound(MSG_ONE, this, ps, r, chan, vol, atten, thepitch); \ else soundto(MSG_ONE, this, chan, sample, vol, atten, thepitch); \ @@ -385,10 +385,10 @@ #define X() \ MACRO_BEGIN \ - if (voicetype != VOICETYPE_AUTOTAUNT || tauntrand < CS(msg_entity).cvar_cl_autotaunt) \ + if (voicetype != VOICETYPE_AUTOTAUNT || tauntrand < CS_CVAR(msg_entity).cvar_cl_autotaunt) \ { \ - float atten = (CS(msg_entity).cvar_cl_voice_directional >= 1) \ - ? bound(ATTEN_MIN, CS(msg_entity).cvar_cl_voice_directional_taunt_attenuation, \ + float atten = (CS_CVAR(msg_entity).cvar_cl_voice_directional >= 1) \ + ? bound(ATTEN_MIN, CS_CVAR(msg_entity).cvar_cl_voice_directional_taunt_attenuation, \ ATTEN_MAX) \ : ATTEN_NONE; \ if (gs) globalsound(MSG_ONE, this, gs, r, chan, vol, atten, thepitch); \ diff --git a/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc b/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc index 937575752..83f9d2fb6 100644 --- a/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc +++ b/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc @@ -2318,7 +2318,7 @@ MUTATOR_HOOKFUNCTION(ctf, GetPressedKeys) entity player = M_ARGV(0, entity); - if(CS(player).cvar_cl_allow_uidtracking == 1 && CS(player).cvar_cl_allow_uid2name == 1) + if(CS_CVAR(player).cvar_cl_allow_uidtracking == 1 && CS_CVAR(player).cvar_cl_allow_uid2name == 1) { if (!player.stored_netname) player.stored_netname = strzone(uid2name(player.crypto_idfp)); diff --git a/qcsrc/common/gamemodes/gamemode/cts/sv_cts.qc b/qcsrc/common/gamemodes/gamemode/cts/sv_cts.qc index 70bd105ef..144788917 100644 --- a/qcsrc/common/gamemodes/gamemode/cts/sv_cts.qc +++ b/qcsrc/common/gamemodes/gamemode/cts/sv_cts.qc @@ -282,7 +282,7 @@ MUTATOR_HOOKFUNCTION(cts, GetPressedKeys) { entity player = M_ARGV(0, entity); - if(CS(player).cvar_cl_allow_uidtracking == 1 && CS(player).cvar_cl_allow_uid2name == 1) + if(CS_CVAR(player).cvar_cl_allow_uidtracking == 1 && CS_CVAR(player).cvar_cl_allow_uid2name == 1) { if (!player.stored_netname) player.stored_netname = strzone(uid2name(player.crypto_idfp)); diff --git a/qcsrc/common/gamemodes/gamemode/race/sv_race.qc b/qcsrc/common/gamemodes/gamemode/race/sv_race.qc index bd5f8b438..a69a43522 100644 --- a/qcsrc/common/gamemodes/gamemode/race/sv_race.qc +++ b/qcsrc/common/gamemodes/gamemode/race/sv_race.qc @@ -328,7 +328,7 @@ MUTATOR_HOOKFUNCTION(rc, GetPressedKeys) { entity player = M_ARGV(0, entity); - if(CS(player).cvar_cl_allow_uidtracking == 1 && CS(player).cvar_cl_allow_uid2name == 1) + if(CS_CVAR(player).cvar_cl_allow_uidtracking == 1 && CS_CVAR(player).cvar_cl_allow_uid2name == 1) { if (!player.stored_netname) player.stored_netname = strzone(uid2name(player.crypto_idfp)); diff --git a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc index 66cd90072..38345efcf 100644 --- a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc +++ b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc @@ -76,7 +76,7 @@ bool buff_Waypoint_visible_for_player(entity this, entity player, entity view) if (STAT(BUFFS, view)) { - return CS(view).cvar_cl_buffs_autoreplace == false || STAT(BUFFS, view) != STAT(BUFFS, this.owner); + return CS_CVAR(view).cvar_cl_buffs_autoreplace == false || STAT(BUFFS, view) != STAT(BUFFS, this.owner); } return WaypointSprite_visible_for_player(this, player, view); @@ -174,7 +174,7 @@ void buff_Touch(entity this, entity toucher) if (STAT(BUFFS, toucher)) { - if (CS(toucher).cvar_cl_buffs_autoreplace && STAT(BUFFS, toucher) != STAT(BUFFS, this)) + if (CS_CVAR(toucher).cvar_cl_buffs_autoreplace && STAT(BUFFS, toucher) != STAT(BUFFS, this)) { // TODO: lost-gained notification for this case int buffid = buff_FirstFromFlags(STAT(BUFFS, toucher)).m_id; diff --git a/qcsrc/common/mutators/mutator/dodging/sv_dodging.qc b/qcsrc/common/mutators/mutator/dodging/sv_dodging.qc index 19f8b1046..1103233e4 100644 --- a/qcsrc/common/mutators/mutator/dodging/sv_dodging.qc +++ b/qcsrc/common/mutators/mutator/dodging/sv_dodging.qc @@ -53,9 +53,9 @@ .float cvar_cl_dodging_timeout; .bool cvar_cl_dodging; #define PHYS_DODGING_FRAMETIME sys_frametime - #define PHYS_DODGING_TIMEOUT(s) CS(s).cvar_cl_dodging_timeout + #define PHYS_DODGING_TIMEOUT(s) CS_CVAR(s).cvar_cl_dodging_timeout #define PHYS_DODGING_PRESSED_KEYS(s) CS(s).pressedkeys - #define PHYS_DODGING_ENABLED(s) CS(s).cvar_cl_dodging + #define PHYS_DODGING_ENABLED(s) CS_CVAR(s).cvar_cl_dodging #endif #ifdef SVQC diff --git a/qcsrc/common/mutators/mutator/multijump/multijump.qc b/qcsrc/common/mutators/mutator/multijump/multijump.qc index 40bc9a33e..9642ab0b3 100644 --- a/qcsrc/common/mutators/mutator/multijump/multijump.qc +++ b/qcsrc/common/mutators/mutator/multijump/multijump.qc @@ -32,7 +32,7 @@ int autocvar_cl_multijump = -1; #elif defined(SVQC) .int cvar_cl_multijump; - #define PHYS_MULTIJUMP_CLIENT(s) CS(s).cvar_cl_multijump + #define PHYS_MULTIJUMP_CLIENT(s) CS_CVAR(s).cvar_cl_multijump #endif MUTATOR_HOOKFUNCTION(multijump, PlayerPhysics) diff --git a/qcsrc/common/mutators/mutator/nades/nades.qc b/qcsrc/common/mutators/mutator/nades/nades.qc index 66d9e2d2c..a8d9f7936 100644 --- a/qcsrc/common/mutators/mutator/nades/nades.qc +++ b/qcsrc/common/mutators/mutator/nades/nades.qc @@ -1152,8 +1152,8 @@ void nade_prime(entity this) } else { - ntype = ((autocvar_g_nades_client_select) ? CS(this).cvar_cl_nade_type : autocvar_g_nades_nade_type); - pntype = ((autocvar_g_nades_client_select) ? CS(this).cvar_cl_pokenade_type : autocvar_g_nades_pokenade_monster_type); + ntype = ((autocvar_g_nades_client_select) ? CS_CVAR(this).cvar_cl_nade_type : autocvar_g_nades_nade_type); + pntype = ((autocvar_g_nades_client_select) ? CS_CVAR(this).cvar_cl_pokenade_type : autocvar_g_nades_pokenade_monster_type); } spawn_held_nade(this, this, autocvar_g_nades_nade_lifetime, ntype, pntype); @@ -1306,8 +1306,8 @@ MUTATOR_HOOKFUNCTION(nades, PlayerPreThink) if(autocvar_g_nades_bonus_client_select) { - STAT(NADE_BONUS_TYPE, player) = CS(player).cvar_cl_nade_type; - player.pokenade_type = CS(player).cvar_cl_pokenade_type; + STAT(NADE_BONUS_TYPE, player) = CS_CVAR(player).cvar_cl_nade_type; + player.pokenade_type = CS_CVAR(player).cvar_cl_pokenade_type; } else { @@ -1414,7 +1414,7 @@ MUTATOR_HOOKFUNCTION(nades, PlayerSpawn) player.nade_refire = time + autocvar_g_nades_nade_refire; if(autocvar_g_nades_bonus_client_select) - STAT(NADE_BONUS_TYPE, player) = CS(player).cvar_cl_nade_type; + STAT(NADE_BONUS_TYPE, player) = CS_CVAR(player).cvar_cl_nade_type; STAT(NADE_TIMER, player) = 0; diff --git a/qcsrc/common/mutators/mutator/spawn_near_teammate/sv_spawn_near_teammate.qc b/qcsrc/common/mutators/mutator/spawn_near_teammate/sv_spawn_near_teammate.qc index 5c7505614..d6afab175 100644 --- a/qcsrc/common/mutators/mutator/spawn_near_teammate/sv_spawn_near_teammate.qc +++ b/qcsrc/common/mutators/mutator/spawn_near_teammate/sv_spawn_near_teammate.qc @@ -29,7 +29,7 @@ MUTATOR_HOOKFUNCTION(spawn_near_teammate, Spawn_Score) entity spawn_spot = M_ARGV(1, entity); vector spawn_score = M_ARGV(2, vector); - if(autocvar_g_spawn_near_teammate_ignore_spawnpoint == 1 || (autocvar_g_spawn_near_teammate_ignore_spawnpoint == 2 && CS(player).cvar_cl_spawn_near_teammate)) + if(autocvar_g_spawn_near_teammate_ignore_spawnpoint == 1 || (autocvar_g_spawn_near_teammate_ignore_spawnpoint == 2 && CS_CVAR(player).cvar_cl_spawn_near_teammate)) return; spawn_spot.msnt_lookat = NULL; @@ -79,7 +79,7 @@ MUTATOR_HOOKFUNCTION(spawn_near_teammate, PlayerSpawn) return; // at least 1 team has only 1 player, let's not give the bigger team too much of an advantage! // Note: when entering this, fixangle is already set. - if(autocvar_g_spawn_near_teammate_ignore_spawnpoint == 1 || (autocvar_g_spawn_near_teammate_ignore_spawnpoint == 2 && CS(player).cvar_cl_spawn_near_teammate)) + if(autocvar_g_spawn_near_teammate_ignore_spawnpoint == 1 || (autocvar_g_spawn_near_teammate_ignore_spawnpoint == 2 && CS_CVAR(player).cvar_cl_spawn_near_teammate)) { if(autocvar_g_spawn_near_teammate_ignore_spawnpoint_delay_death) player.msnt_timer = time + autocvar_g_spawn_near_teammate_ignore_spawnpoint_delay_death; diff --git a/qcsrc/common/notifications/all.qc b/qcsrc/common/notifications/all.qc index 358453e5c..d6dff6be9 100644 --- a/qcsrc/common/notifications/all.qc +++ b/qcsrc/common/notifications/all.qc @@ -762,12 +762,12 @@ void Create_Notification_Entity_Choice(entity notif, // used by MSG_CHOICE to build list of choices #ifdef SVQC -void Notification_GetCvars(entity this) +void Notification_GetCvars(entity this, entity store) { FOREACH(Notifications, it.nent_type == MSG_CHOICE && (!it.nent_teamnum || it.nent_teamnum == NUM_TEAM_1), { GetCvars_handleFloat( this, - CS(this), + store, get_cvars_s, get_cvars_f, msg_choice_choices[it.nent_choice_idx], diff --git a/qcsrc/common/notifications/all.qh b/qcsrc/common/notifications/all.qh index a94ac9ab9..72017e3dc 100644 --- a/qcsrc/common/notifications/all.qh +++ b/qcsrc/common/notifications/all.qh @@ -310,7 +310,7 @@ float autocvar_notification_lifetime_mapload = 10; #endif #ifdef SVQC -void Notification_GetCvars(entity this); +void Notification_GetCvars(entity this, entity store); float autocvar_notification_server_allows_location = 1; // 0 = no, 1 = yes #else float autocvar_notification_item_centerprinttime = 1.5; diff --git a/qcsrc/common/physics/player.qc b/qcsrc/common/physics/player.qc index 69dcf56b0..1c55d3d14 100644 --- a/qcsrc/common/physics/player.qc +++ b/qcsrc/common/physics/player.qc @@ -19,9 +19,9 @@ float Physics_ClientOption(entity this, string option, float defaultval) if(!autocvar_g_physics_clientselect) return defaultval; - if(IS_REAL_CLIENT(this) && Physics_Valid(CS(this).cvar_cl_physics)) + if(IS_REAL_CLIENT(this) && Physics_Valid(CS_CVAR(this).cvar_cl_physics)) { - string s = strcat("g_physics_", CS(this).cvar_cl_physics, "_", option); + string s = strcat("g_physics_", CS_CVAR(this).cvar_cl_physics, "_", option); if(cvar_type(s) & CVAR_TYPEFLAG_EXISTS) return cvar(s); } @@ -457,7 +457,7 @@ void CheckWaterJump(entity this) #ifdef SVQC - #define JETPACK_JUMP(s) CS(s).cvar_cl_jetpack_jump + #define JETPACK_JUMP(s) CS_CVAR(s).cvar_cl_jetpack_jump #elif defined(CSQC) float autocvar_cl_jetpack_jump; #define JETPACK_JUMP(s) autocvar_cl_jetpack_jump diff --git a/qcsrc/common/physics/player.qh b/qcsrc/common/physics/player.qh index 67c70c4b0..9d92581f4 100644 --- a/qcsrc/common/physics/player.qh +++ b/qcsrc/common/physics/player.qh @@ -327,7 +327,7 @@ STATIC_INIT(PHYS_INPUT_BUTTON) #define PHYS_JUMPSPEEDCAP_MIN autocvar_sv_jumpspeedcap_min #define PHYS_JUMPSPEEDCAP_MAX autocvar_sv_jumpspeedcap_max - #define PHYS_CL_TRACK_CANJUMP(s) (CS(s).cvar_cl_movement_track_canjump) + #define PHYS_CL_TRACK_CANJUMP(s) (CS_CVAR(s).cvar_cl_movement_track_canjump) #endif diff --git a/qcsrc/common/playerstats.qc b/qcsrc/common/playerstats.qc index 2400d4750..05a6ab797 100644 --- a/qcsrc/common/playerstats.qc +++ b/qcsrc/common/playerstats.qc @@ -136,7 +136,7 @@ void PlayerStats_GameReport_FinalizePlayer(entity p) db_put(PS_GR_OUT_DB, sprintf("%s:_playerid", p.playerstats_id), ftos(p.playerid)); - if(CS(p).cvar_cl_allow_uid2name == 1 || IS_BOT_CLIENT(p)) + if(CS_CVAR(p).cvar_cl_allow_uid2name == 1 || IS_BOT_CLIENT(p)) db_put(PS_GR_OUT_DB, sprintf("%s:_netname", p.playerstats_id), playername(p.netname, p.team, false)); if(teamplay) @@ -157,7 +157,7 @@ void PlayerStats_GameReport_FinalizePlayer(entity p) PlayerStats_GameReport_Event_Player(p, PLAYERSTATS_AVGLATENCY, latency); } - db_put(PS_GR_OUT_DB, sprintf("%s:_ranked", p.playerstats_id), ftos(CS(p).cvar_cl_allow_uidranking)); + db_put(PS_GR_OUT_DB, sprintf("%s:_ranked", p.playerstats_id), ftos(CS_CVAR(p).cvar_cl_allow_uidranking)); } strfree(p.playerstats_id); diff --git a/qcsrc/common/state.qc b/qcsrc/common/state.qc index 7a5979e2b..651a86f91 100644 --- a/qcsrc/common/state.qc +++ b/qcsrc/common/state.qc @@ -68,7 +68,7 @@ void PlayerScore_Detach(entity this); void ClientState_detach(entity this) { - GetCvars(this, CS(this), -1); // free cvars TODO: is this still needed now that it's stored on the clientstate entity? + GetCvars(this, CS_CVAR(this), -1); // free cvars TODO: is this still needed now that it's stored on the clientstate entity? accuracy_free(this); // TODO: needs to be before CS() is deleted! PlayerScore_Detach(this); // what ^they^ said W_HitPlotClose(this); diff --git a/qcsrc/common/state.qh b/qcsrc/common/state.qh index 42fc450c4..7656d47e6 100644 --- a/qcsrc/common/state.qh +++ b/qcsrc/common/state.qh @@ -47,5 +47,8 @@ ENDCLASS(ClientState) ClientState CS(Client this) { TC(Client, this); assert(this._cs); return this._cs; } #endif +// NOTE: this exists to ease migration later on - ClientState does not exist early enough for replicated cvars! +#define CS_CVAR(this) (this) + void ClientState_attach(entity this); void ClientState_detach(entity this); diff --git a/qcsrc/common/weapons/weapon/shockwave.qc b/qcsrc/common/weapons/weapon/shockwave.qc index 01a922bb8..5444980ca 100644 --- a/qcsrc/common/weapons/weapon/shockwave.qc +++ b/qcsrc/common/weapons/weapon/shockwave.qc @@ -311,7 +311,7 @@ void W_Shockwave_Attack(Weapon thiswep, entity actor, .entity weaponentity) ); float lag = ((IS_REAL_CLIENT(actor)) ? ANTILAG_LATENCY(actor) : 0); - bool noantilag = ((IS_CLIENT(actor)) ? CS(actor).cvar_cl_noantilag : false); + bool noantilag = ((IS_CLIENT(actor)) ? CS_CVAR(actor).cvar_cl_noantilag : false); if(lag < 0.001) lag = 0; if(autocvar_g_antilag == 0 || noantilag) diff --git a/qcsrc/server/antilag.qc b/qcsrc/server/antilag.qc index c3229adfd..b57627963 100644 --- a/qcsrc/server/antilag.qc +++ b/qcsrc/server/antilag.qc @@ -151,7 +151,7 @@ void antilag_restore_all(entity ignore) float antilag_getlag(entity e) { float lag = ((IS_REAL_CLIENT(e)) ? ANTILAG_LATENCY(e) : 0); - bool noantilag = ((IS_CLIENT(e)) ? CS(e).cvar_cl_noantilag : false); + bool noantilag = ((IS_CLIENT(e)) ? CS_CVAR(e).cvar_cl_noantilag : false); if(autocvar_g_antilag == 0 || noantilag || lag < 0.001) lag = 0; @@ -202,14 +202,14 @@ void traceline_antilag_force (entity source, vector v1, vector v2, float nomonst } void traceline_antilag (entity source, vector v1, vector v2, float nomonst, entity forent, float lag) { - bool noantilag = ((IS_CLIENT(source)) ? CS(source).cvar_cl_noantilag : false); + bool noantilag = ((IS_CLIENT(source)) ? CS_CVAR(source).cvar_cl_noantilag : false); if (autocvar_g_antilag != 2 || noantilag) lag = 0; traceline_antilag_force(source, v1, v2, nomonst, forent, lag); } void tracebox_antilag (entity source, vector v1, vector mi, vector ma, vector v2, float nomonst, entity forent, float lag) { - bool noantilag = ((IS_CLIENT(source)) ? CS(source).cvar_cl_noantilag : false); + bool noantilag = ((IS_CLIENT(source)) ? CS_CVAR(source).cvar_cl_noantilag : false); if (autocvar_g_antilag != 2 || noantilag) lag = 0; tracebox_antilag_force_wz(source, v1, mi, ma, v2, nomonst, forent, lag, false); @@ -220,14 +220,14 @@ void WarpZone_traceline_antilag_force (entity source, vector v1, vector v2, floa } void WarpZone_traceline_antilag (entity source, vector v1, vector v2, float nomonst, entity forent, float lag) { - bool noantilag = ((IS_CLIENT(source)) ? CS(source).cvar_cl_noantilag : false); + bool noantilag = ((IS_CLIENT(source)) ? CS_CVAR(source).cvar_cl_noantilag : false); if (autocvar_g_antilag != 2 || noantilag) lag = 0; WarpZone_traceline_antilag_force(source, v1, v2, nomonst, forent, lag); } void WarpZone_tracebox_antilag (entity source, vector v1, vector mi, vector ma, vector v2, float nomonst, entity forent, float lag) { - bool noantilag = ((IS_CLIENT(source)) ? CS(source).cvar_cl_noantilag : false); + bool noantilag = ((IS_CLIENT(source)) ? CS_CVAR(source).cvar_cl_noantilag : false); if (autocvar_g_antilag != 2 || noantilag) lag = 0; tracebox_antilag_force_wz(source, v1, mi, ma, v2, nomonst, forent, lag, true); diff --git a/qcsrc/server/bot/default/bot.qc b/qcsrc/server/bot/default/bot.qc index 7afa5a10c..9ba2a333b 100644 --- a/qcsrc/server/bot/default/bot.qc +++ b/qcsrc/server/bot/default/bot.qc @@ -35,8 +35,8 @@ STATIC_INIT(bot) { bot_calculate_stepheightvec(); } // TODO: remove this function! its only purpose is to update these fields since bot_setnameandstuff is called before ClientState void bot_setclientfields(entity this) { - CS(this).cvar_cl_accuracy_data_share = 1; // share the bots weapon accuracy data with the world - CS(this).cvar_cl_accuracy_data_receive = 0; // don't receive any weapon accuracy data + CS_CVAR(this).cvar_cl_accuracy_data_share = 1; // share the bots weapon accuracy data with the world + CS_CVAR(this).cvar_cl_accuracy_data_receive = 0; // don't receive any weapon accuracy data } entity bot_spawn() diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 8dd73f66c..6bebfeb36 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -785,7 +785,7 @@ void PutPlayerInServer(entity this) if (CS(this).impulse) ImpulseCommands(this); - W_ResetGunAlign(this, CS(this).cvar_cl_gunalign); + W_ResetGunAlign(this, CS_CVAR(this).cvar_cl_gunalign); for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) { .entity weaponentity = weaponentities[slot]; @@ -1220,7 +1220,7 @@ void ClientDisconnect(entity this) MUTATOR_CALLHOOK(ClientDisconnect, this); strfree(CS(this).netname_previous); // needs to be before the CS entity is removed! - strfree(CS(this).weaponorder_byimpulse); + strfree(CS_CVAR(this).weaponorder_byimpulse); ClientState_detach(this); Portal_ClearAll(this); @@ -2260,7 +2260,7 @@ bool PlayerThink(entity this) bool dualwielding = W_DualWielding(this); if(this.dualwielding_prev != dualwielding) { - W_ResetGunAlign(this, CS(this).cvar_cl_gunalign); + W_ResetGunAlign(this, CS_CVAR(this).cvar_cl_gunalign); this.dualwielding_prev = dualwielding; } @@ -2351,7 +2351,7 @@ void ObserverOrSpectatorThink(entity this) } } else { - int preferred_movetype = ((!PHYS_INPUT_BUTTON_USE(this) ? CS(this).cvar_cl_clippedspectating : !CS(this).cvar_cl_clippedspectating) ? MOVETYPE_FLY_WORLDONLY : MOVETYPE_NOCLIP); + int preferred_movetype = ((!PHYS_INPUT_BUTTON_USE(this) ? CS_CVAR(this).cvar_cl_clippedspectating : !CS_CVAR(this).cvar_cl_clippedspectating) ? MOVETYPE_FLY_WORLDONLY : MOVETYPE_NOCLIP); set_movetype(this, preferred_movetype); } } else { @@ -2430,8 +2430,8 @@ Called every frame for each client before the physics are run .float last_vehiclecheck; void PlayerPreThink (entity this) { - STAT(GUNALIGN, this) = CS(this).cvar_cl_gunalign; // TODO - STAT(MOVEVARS_CL_TRACK_CANJUMP, this) = CS(this).cvar_cl_movement_track_canjump; + STAT(GUNALIGN, this) = CS_CVAR(this).cvar_cl_gunalign; // TODO + STAT(MOVEVARS_CL_TRACK_CANJUMP, this) = CS_CVAR(this).cvar_cl_movement_track_canjump; WarpZone_PlayerPhysics_FixVAngle(this); @@ -2473,19 +2473,19 @@ void PlayerPreThink (entity this) } // version nagging - if (CS(this).version_nagtime && CS(this).cvar_g_xonoticversion && time > CS(this).version_nagtime) { + if (CS(this).version_nagtime && CS_CVAR(this).cvar_g_xonoticversion && time > CS(this).version_nagtime) { CS(this).version_nagtime = 0; - if (strstrofs(CS(this).cvar_g_xonoticversion, "git", 0) >= 0 || strstrofs(CS(this).cvar_g_xonoticversion, "autobuild", 0) >= 0) { + if (strstrofs(CS_CVAR(this).cvar_g_xonoticversion, "git", 0) >= 0 || strstrofs(CS_CVAR(this).cvar_g_xonoticversion, "autobuild", 0) >= 0) { // git client } else if (strstrofs(autocvar_g_xonoticversion, "git", 0) >= 0 || strstrofs(autocvar_g_xonoticversion, "autobuild", 0) >= 0) { // git server - Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_VERSION_BETA, autocvar_g_xonoticversion, CS(this).cvar_g_xonoticversion); + Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_VERSION_BETA, autocvar_g_xonoticversion, CS_CVAR(this).cvar_g_xonoticversion); } else { - int r = vercmp(CS(this).cvar_g_xonoticversion, autocvar_g_xonoticversion); + int r = vercmp(CS_CVAR(this).cvar_g_xonoticversion, autocvar_g_xonoticversion); if (r < 0) { // old client - Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_VERSION_OUTDATED, autocvar_g_xonoticversion, CS(this).cvar_g_xonoticversion); + Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_VERSION_OUTDATED, autocvar_g_xonoticversion, CS_CVAR(this).cvar_g_xonoticversion); } else if (r > 0) { // old server - Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_VERSION_OLD, autocvar_g_xonoticversion, CS(this).cvar_g_xonoticversion); + Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_VERSION_OLD, autocvar_g_xonoticversion, CS_CVAR(this).cvar_g_xonoticversion); } } } @@ -2549,7 +2549,7 @@ void PlayerPreThink (entity this) this.last_vehiclecheck = time + 1; } - if(!CS(this).cvar_cl_newusekeysupported) // FIXME remove this - it was a stupid idea to begin with, we can JUST use the button + if(!CS_CVAR(this).cvar_cl_newusekeysupported) // FIXME remove this - it was a stupid idea to begin with, we can JUST use the button { if(PHYS_INPUT_BUTTON_USE(this) && !CS(this).usekeypressed) PlayerUseKey(this); diff --git a/qcsrc/server/command/cmd.qc b/qcsrc/server/command/cmd.qc index ad3685a1f..bb227c63c 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(caller).autoswitch = InterpretBoolean(argv(1)); - sprint(caller, strcat("^1autoswitch is currently turned ", (CS(caller).autoswitch ? "on" : "off"), ".\n")); + CS_CVAR(caller).autoswitch = InterpretBoolean(argv(1)); + sprint(caller, strcat("^1autoswitch is currently turned ", (CS_CVAR(caller).autoswitch ? "on" : "off"), ".\n")); return; } } @@ -355,7 +355,7 @@ void ClientCommand_physics(entity caller, int request, int argc) } default: - sprint(caller, strcat("Current physics set: ^3", CS(caller).cvar_cl_physics, "\n")); + sprint(caller, strcat("Current physics set: ^3", CS_CVAR(caller).cvar_cl_physics, "\n")); case CMD_REQUEST_USAGE: { sprint(caller, "\nUsage:^3 cmd physics \n"); @@ -603,7 +603,7 @@ void ClientCommand_sentcvar(entity caller, int request, int argc, string command tokenize_console(s); } - GetCvars(caller, CS(caller), 1); + GetCvars(caller, CS_CVAR(caller), 1); return; } diff --git a/qcsrc/server/command/getreplies.qc b/qcsrc/server/command/getreplies.qc index d0f882dce..1001bb7d7 100644 --- a/qcsrc/server/command/getreplies.qc +++ b/qcsrc/server/command/getreplies.qc @@ -379,7 +379,7 @@ void GetCvars_handleFloatOnce(entity this, entity store, string thisname, float string W_FixWeaponOrder_ForceComplete_AndBuildImpulseList(entity this, string wo) { string o = W_FixWeaponOrder_ForceComplete(wo); - strcpy(CS(this).weaponorder_byimpulse, W_FixWeaponOrder_BuildImpulseList(o)); + strcpy(CS_CVAR(this).weaponorder_byimpulse, W_FixWeaponOrder_BuildImpulseList(o)); return o; } @@ -400,7 +400,7 @@ void GetCvars(entity this, entity store, int f) get_cvars_s = s; MUTATOR_CALLHOOK(GetCvars); - Notification_GetCvars(this); + Notification_GetCvars(this, store); ReplicateVars(this, store, s, f); diff --git a/qcsrc/server/handicap.qc b/qcsrc/server/handicap.qc index 6d03725f8..ce0d6cd0a 100644 --- a/qcsrc/server/handicap.qc +++ b/qcsrc/server/handicap.qc @@ -17,7 +17,7 @@ void Handicap_Initialize(entity player) float Handicap_GetVoluntaryHandicap(entity player) { - return bound(1.0, CS(player).cvar_cl_handicap, 10.0); + return bound(1.0, CS_CVAR(player).cvar_cl_handicap, 10.0); } float Handicap_GetForcedHandicap(entity player) diff --git a/qcsrc/server/impulse.qc b/qcsrc/server/impulse.qc index e9ebaec87..3fa3dc6c6 100644 --- a/qcsrc/server/impulse.qc +++ b/qcsrc/server/impulse.qc @@ -97,7 +97,7 @@ void weapon_priority_handle(entity this, int dir, int number, int imp) for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) { .entity weaponentity = weaponentities[slot]; - W_CycleWeapon(this, CS(this).cvar_cl_weaponpriorities[number], dir, weaponentity); + W_CycleWeapon(this, CS_CVAR(this).cvar_cl_weaponpriorities[number], dir, weaponentity); if(autocvar_g_weaponswitch_debug != 1) break; } diff --git a/qcsrc/server/intermission.qc b/qcsrc/server/intermission.qc index 001692cf9..e1fb6f607 100644 --- a/qcsrc/server/intermission.qc +++ b/qcsrc/server/intermission.qc @@ -424,8 +424,8 @@ void IntermissionThink(entity this) { FixIntermissionClient(this); - float server_screenshot = (autocvar_sv_autoscreenshot && CS(this).cvar_cl_autoscreenshot); - float client_screenshot = (CS(this).cvar_cl_autoscreenshot == 2); + float server_screenshot = (autocvar_sv_autoscreenshot && CS_CVAR(this).cvar_cl_autoscreenshot); + float client_screenshot = (CS_CVAR(this).cvar_cl_autoscreenshot == 2); if( (server_screenshot || client_screenshot) && ((this.autoscreenshot > 0) && (time > this.autoscreenshot)) ) diff --git a/qcsrc/server/items/items.qc b/qcsrc/server/items/items.qc index 36932f0ce..403125eea 100644 --- a/qcsrc/server/items/items.qc +++ b/qcsrc/server/items/items.qc @@ -481,7 +481,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(player).autoswitch) + if(CS_CVAR(player).autoswitch) { for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) { @@ -570,7 +570,7 @@ bool Item_GiveTo(entity item, entity player) return false; // crude hack to enforce switching weapons - if(g_cts && item.itemdef.instanceOfWeaponPickup && !CS(player).cvar_cl_cts_noautoswitch) + if(g_cts && item.itemdef.instanceOfWeaponPickup && !CS_CVAR(player).cvar_cl_cts_noautoswitch) { for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) { @@ -1429,7 +1429,7 @@ float GiveItems(entity e, float beginarg, float endarg) int _switchweapon = 0; - if(CS(e).autoswitch) + if(CS_CVAR(e).autoswitch) { for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) { diff --git a/qcsrc/server/weapons/accuracy.qc b/qcsrc/server/weapons/accuracy.qc index 7b5220e03..3eafbc76c 100644 --- a/qcsrc/server/weapons/accuracy.qc +++ b/qcsrc/server/weapons/accuracy.qc @@ -27,7 +27,7 @@ bool accuracy_send(entity this, entity to, int sf) a = CS(a).accuracy; if (to != a.owner) - if (!autocvar_sv_accuracy_data_share && !CS(a.owner).cvar_cl_accuracy_data_share) + if (!autocvar_sv_accuracy_data_share && !CS_CVAR(a.owner).cvar_cl_accuracy_data_share) sf = 0; // note: zero sendflags can never be sent... so we can use that to say that we send no accuracy! WriteInt24_t(MSG_ENTITY, sf); diff --git a/qcsrc/server/weapons/selection.qc b/qcsrc/server/weapons/selection.qc index 5dd3073e9..09f5e65ca 100644 --- a/qcsrc/server/weapons/selection.qc +++ b/qcsrc/server/weapons/selection.qc @@ -283,7 +283,7 @@ bool W_SwitchWeapon(entity this, Weapon w, .entity weaponentity) return false; } } - else if(!weaponLocked(this) && CS(this).cvar_cl_weapon_switch_reload) + else if(!weaponLocked(this) && CS_CVAR(this).cvar_cl_weapon_switch_reload) { entity actor = this; w.wr_reload(w, actor, weaponentity); @@ -294,7 +294,7 @@ bool W_SwitchWeapon(entity this, Weapon w, .entity weaponentity) void W_SwitchWeapon_TryOthers(entity this, Weapon w, .entity weaponentity) { - if(!W_SwitchWeapon(this, w, weaponentity) && CS(this).cvar_cl_weapon_switch_fallback_to_impulse) + if(!W_SwitchWeapon(this, w, weaponentity) && CS_CVAR(this).cvar_cl_weapon_switch_fallback_to_impulse) W_NextWeaponOnImpulse(this, w.impulse, weaponentity); } @@ -309,7 +309,7 @@ void W_CycleWeapon(entity this, string weaponorder, float dir, .entity weaponent void W_NextWeaponOnImpulse(entity this, float imp, .entity weaponentity) { float w; - w = W_GetCycleWeapon(this, CS(this).cvar_cl_weaponpriority, +1, imp, 1, (CS(this).cvar_cl_weaponimpulsemode == 0), weaponentity); + w = W_GetCycleWeapon(this, CS_CVAR(this).cvar_cl_weaponpriority, +1, imp, 1, (CS_CVAR(this).cvar_cl_weaponimpulsemode == 0), weaponentity); if(w > 0) W_SwitchWeapon(this, REGISTRY_GET(Weapons, w), weaponentity); } @@ -320,9 +320,9 @@ void W_NextWeapon(entity this, int list, .entity weaponentity) if(list == 0) W_CycleWeapon(this, weaponorder_byid, -1, weaponentity); else if(list == 1) - W_CycleWeapon(this, CS(this).weaponorder_byimpulse, -1, weaponentity); + W_CycleWeapon(this, CS_CVAR(this).weaponorder_byimpulse, -1, weaponentity); else if(list == 2) - W_CycleWeapon(this, CS(this).cvar_cl_weaponpriority, -1, weaponentity); + W_CycleWeapon(this, CS_CVAR(this).cvar_cl_weaponpriority, -1, weaponentity); } // prev weapon @@ -331,9 +331,9 @@ void W_PreviousWeapon(entity this, float list, .entity weaponentity) if(list == 0) W_CycleWeapon(this, weaponorder_byid, +1, weaponentity); else if(list == 1) - W_CycleWeapon(this, CS(this).weaponorder_byimpulse, +1, weaponentity); + W_CycleWeapon(this, CS_CVAR(this).weaponorder_byimpulse, +1, weaponentity); else if(list == 2) - W_CycleWeapon(this, CS(this).cvar_cl_weaponpriority, +1, weaponentity); + W_CycleWeapon(this, CS_CVAR(this).cvar_cl_weaponpriority, +1, weaponentity); } // previously used if exists and has ammo, (second) best otherwise diff --git a/qcsrc/server/weapons/selection.qh b/qcsrc/server/weapons/selection.qh index 363b569ef..093d6612b 100644 --- a/qcsrc/server/weapons/selection.qh +++ b/qcsrc/server/weapons/selection.qh @@ -20,7 +20,7 @@ bool client_hasweapon(entity this, Weapon wpn, .entity weaponentity, float andam .int weaponcomplainindex; float W_GetCycleWeapon(entity this, string weaponorder, float dir, float imp, float complain, float skipmissing, .entity weaponentity); -#define w_getbestweapon(ent,wepent) REGISTRY_GET(Weapons, W_GetCycleWeapon(ent, CS(ent).cvar_cl_weaponpriority, 0, -1, false, true, wepent)) +#define w_getbestweapon(ent,wepent) REGISTRY_GET(Weapons, W_GetCycleWeapon(ent, CS_CVAR(ent).cvar_cl_weaponpriority, 0, -1, false, true, wepent)) void W_SwitchWeapon_Force(Player this, Weapon w, .entity weaponentity); diff --git a/qcsrc/server/weapons/tracing.qc b/qcsrc/server/weapons/tracing.qc index b345b0984..686634c7a 100644 --- a/qcsrc/server/weapons/tracing.qc +++ b/qcsrc/server/weapons/tracing.qc @@ -107,7 +107,7 @@ void W_SetupShot_Dir_ProjectileSize_Range(entity ent, .entity weaponentity, vect //vector prevend = w_shotend; if (antilag) - if (!CS(ent).cvar_cl_noantilag) + if (!CS_CVAR(ent).cvar_cl_noantilag) { if (autocvar_g_antilag == 1) // switch to "ghost" if not hitting original { -- 2.39.2