]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'Mario/cs_clientcvars' into 'master'
authorMario <zacjardine@y7mail.com>
Wed, 9 Aug 2017 13:10:10 +0000 (13:10 +0000)
committerMario <zacjardine@y7mail.com>
Wed, 9 Aug 2017 13:10:10 +0000 (13:10 +0000)
Merge branch Mario/cs_clientcvars (M merge request)

See merge request !458

1  2 
qcsrc/common/stats.qh
qcsrc/server/client.qc
qcsrc/server/client.qh
qcsrc/server/command/cmd.qc
qcsrc/server/g_subs.qc
qcsrc/server/g_world.qc
qcsrc/server/miscfunctions.qc
qcsrc/server/mutators/mutator/gamemode_ctf.qc
qcsrc/server/player.qc
qcsrc/server/weapons/tracing.qc

diff --combined qcsrc/common/stats.qh
index c452b1128188603f4ec3d62027e90590d2cfd335,c8907f8e6e0c6b783860b79479650c306b1547c1..94e408d7f614be2d769fc229625a390bfd357ba0
@@@ -1,7 -1,6 +1,7 @@@
  #pragma once
  
  #ifdef SVQC
 +#include <server/autocvars.qh>
  #include <server/client.qh>
  #endif
  
@@@ -352,7 -351,7 +352,7 @@@ noref int autocvar_cl_gunalign
  .int cvar_cl_gunalign;
  REPLICATE(cvar_cl_gunalign, int, "cl_gunalign");
  #endif
- REGISTER_STAT(GUNALIGN, int, this.cvar_cl_gunalign)
+ REGISTER_STAT(GUNALIGN, int)
  #ifdef SVQC
  SPECTATE_COPYFIELD(_STAT(GUNALIGN))
  #endif
diff --combined qcsrc/server/client.qc
index a8e2ef34818796c0b7da326d99590baee6a3eed3,82d648fd284dc08970da5ce827059b12a7aa1b52..b0eb75ae41bd1c1954a3bdad671924a5133b947c
@@@ -1,8 -1,5 +1,8 @@@
  #include "client.qh"
  
 +#include <server/defs.qh>
 +#include <server/miscfunctions.qh>
 +#include <common/effects/all.qh>
  #include "anticheat.qh"
  #include "impulse.qh"
  #include "player.qh"
@@@ -2311,7 -2308,7 +2311,7 @@@ void ObserverThink(entity this
                                TRANSMUTE(Spectator, this);
                        }
                } else {
-                       int preferred_movetype = ((!PHYS_INPUT_BUTTON_USE(this) ? this.cvar_cl_clippedspectating : !this.cvar_cl_clippedspectating) ? MOVETYPE_FLY_WORLDONLY : MOVETYPE_NOCLIP);
+                       int preferred_movetype = ((!PHYS_INPUT_BUTTON_USE(this) ? CS(this).cvar_cl_clippedspectating : !CS(this).cvar_cl_clippedspectating) ? MOVETYPE_FLY_WORLDONLY : MOVETYPE_NOCLIP);
                        set_movetype(this, preferred_movetype);
                }
        } else {
@@@ -2449,6 -2446,9 +2449,9 @@@ Called every frame for each client befo
  .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;
        WarpZone_PlayerPhysics_FixVAngle(this);
  
        if (frametime) {
        }
  
        // version nagging
-       if (CS(this).version_nagtime && this.cvar_g_xonoticversion && time > CS(this).version_nagtime) {
+       if (CS(this).version_nagtime && CS(this).cvar_g_xonoticversion && time > CS(this).version_nagtime) {
          CS(this).version_nagtime = 0;
-         if (strstrofs(this.cvar_g_xonoticversion, "git", 0) >= 0 || strstrofs(this.cvar_g_xonoticversion, "autobuild", 0) >= 0) {
+         if (strstrofs(CS(this).cvar_g_xonoticversion, "git", 0) >= 0 || strstrofs(CS(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, this.cvar_g_xonoticversion);
+             Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_VERSION_BETA, autocvar_g_xonoticversion, CS(this).cvar_g_xonoticversion);
          } else {
-             int r = vercmp(this.cvar_g_xonoticversion, autocvar_g_xonoticversion);
+             int r = vercmp(CS(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, this.cvar_g_xonoticversion);
+                 Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_VERSION_OUTDATED, autocvar_g_xonoticversion, CS(this).cvar_g_xonoticversion);
              } else if (r > 0) { // old server
-                 Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_VERSION_OLD, autocvar_g_xonoticversion, this.cvar_g_xonoticversion);
+                 Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_VERSION_OLD, autocvar_g_xonoticversion, CS(this).cvar_g_xonoticversion);
              }
          }
      }
                this.last_vehiclecheck = time + 1;
        }
  
-       if(!this.cvar_cl_newusekeysupported) // FIXME remove this - it was a stupid idea to begin with, we can JUST use the button
+       if(!CS(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 --combined qcsrc/server/client.qh
index 383383ad76aaacdf4d0566a05a6de34115aa257d,63666c01ebb592e0a01ef1424eae1b6095f8808d..614916019f60c4c385851febb2d25c8e102d38ad
@@@ -1,8 -1,5 +1,8 @@@
  #pragma once
  
 +#include "utils.qh"
 +#include <common/sounds/all.qh>
 +
  void ClientState_attach(entity this);
  
  IntrusiveList g_players;
@@@ -110,8 -107,38 +110,38 @@@ CLASS(Client, Object
      ATTRIB(Client, specialcommand_pos, int, this.specialcommand_pos);
      ATTRIB(Client, hitplotfh, int, this.hitplotfh);
      ATTRIB(Client, clientdata, entity, this.clientdata);
+     ATTRIB(Client, cmd_floodcount, int, this.cmd_floodcount);
+     ATTRIB(Client, cmd_floodtime, float, this.cmd_floodtime);
      ATTRIB(Client, wasplayer, bool, this.wasplayer);
  
+     // networked cvars
+     ATTRIB(Client, cvar_cl_allow_uid2name, int, this.cvar_cl_allow_uid2name);
+     ATTRIB(Client, cvar_cl_allow_uidtracking, int, this.cvar_cl_allow_uidtracking);
+     ATTRIB(Client, cvar_cl_autotaunt, float, this.cvar_cl_autotaunt);
+     ATTRIB(Client, cvar_cl_voice_directional, int, this.cvar_cl_voice_directional);
+     ATTRIB(Client, cvar_cl_voice_directional_taunt_attenuation, float, this.cvar_cl_voice_directional_taunt_attenuation);
+     ATTRIB(Client, cvar_cl_physics, string, this.cvar_cl_physics);
+     ATTRIB(Client, cvar_cl_buffs_autoreplace, bool, this.cvar_cl_buffs_autoreplace);
+     ATTRIB(Client, cvar_cl_nade_type, int, this.cvar_cl_nade_type);
+     ATTRIB(Client, cvar_cl_pokenade_type, string, this.cvar_cl_pokenade_type);
+     ATTRIB(Client, cvar_cl_spawn_near_teammate, bool, this.cvar_cl_spawn_near_teammate);
+     ATTRIB(Client, cvar_cl_gunalign, int, this.cvar_cl_gunalign);
+     ATTRIB(Client, cvar_cl_handicap, float, this.cvar_cl_handicap);
+     ATTRIB(Client, cvar_cl_clippedspectating, bool, this.cvar_cl_clippedspectating);
+     ATTRIB(Client, cvar_cl_autoscreenshot, int, this.cvar_cl_autoscreenshot);
+     ATTRIB(Client, cvar_cl_jetpack_jump, bool, this.cvar_cl_jetpack_jump);
+     ATTRIB(Client, cvar_cl_newusekeysupported, bool, this.cvar_cl_newusekeysupported);
+     ATTRIB(Client, cvar_cl_noantilag, bool, this.cvar_cl_noantilag);
+     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_dodging_timeout, float, this.cvar_cl_dodging_timeout);
+     ATTRIB(Client, cvar_cl_multijump, bool, this.cvar_cl_multijump);
+     ATTRIB(Client, cvar_cl_accuracy_data_share, bool, this.cvar_cl_accuracy_data_share);
+     ATTRIB(Client, cvar_cl_accuracy_data_receive, bool, this.cvar_cl_accuracy_data_receive);
      METHOD(Client, m_unwind, bool(Client this));
  
      STATIC_METHOD(Client, Add, void(Client this, int _team));
index d1d79981182ceb91e560895f22f7f3d2e4c3a3df,bc3b809dcc05779b6a127e54864fe8f59861102a..50250f9a5c2974bfb246dc3eff04dd0f2b18d346
@@@ -1,8 -1,4 +1,8 @@@
  #include "cmd.qh"
 +
 +#include <server/defs.qh>
 +#include <server/miscfunctions.qh>
 +
  #include <common/command/_mod.qh>
  
  #include "common.qh"
@@@ -49,17 -45,19 +49,19 @@@ void ClientKill_TeamChange(entity this
  
  bool SV_ParseClientCommand_floodcheck(entity this)
  {
+       entity store = IS_CLIENT(this) ? CS(this) : this; // unfortunately, we need to store these on the client initially
        if (!timeout_status)  // not while paused
        {
-               if (time <= (this.cmd_floodtime + autocvar_sv_clientcommand_antispam_time))
+               if (time <= (store.cmd_floodtime + autocvar_sv_clientcommand_antispam_time))
                {
-                       this.cmd_floodcount += 1;
-                       if (this.cmd_floodcount > autocvar_sv_clientcommand_antispam_count)   return false;  // too much spam, halt
+                       store.cmd_floodcount += 1;
+                       if (store.cmd_floodcount > autocvar_sv_clientcommand_antispam_count)   return false;  // too much spam, halt
                }
                else
                {
-                       this.cmd_floodtime = time;
-                       this.cmd_floodcount = 1;
+                       store.cmd_floodtime = time;
+                       store.cmd_floodcount = 1;
                }
        }
        return true;  // continue, as we're not flooding yet
@@@ -78,8 -76,8 +80,8 @@@ void ClientCommand_autoswitch(entity ca
                {
                        if (argv(1) != "")
                        {
-                               caller.autoswitch = InterpretBoolean(argv(1));
-                               sprint(caller, strcat("^1autoswitch is currently turned ", (caller.autoswitch ? "on" : "off"), ".\n"));
+                               CS(caller).autoswitch = InterpretBoolean(argv(1));
+                               sprint(caller, strcat("^1autoswitch is currently turned ", (CS(caller).autoswitch ? "on" : "off"), ".\n"));
                                return;
                        }
                }
@@@ -218,7 -216,7 +220,7 @@@ void ClientCommand_physics(entity calle
                }
  
                default:
-                       sprint(caller, strcat("Current physics set: ^3", caller.cvar_cl_physics, "\n"));
+                       sprint(caller, strcat("Current physics set: ^3", CS(caller).cvar_cl_physics, "\n"));
                case CMD_REQUEST_USAGE:
                {
                        sprint(caller, "\nUsage:^3 cmd physics <physics>\n");
diff --combined qcsrc/server/g_subs.qc
index 8c39f88c9480507ab63f6cd4a5815d3db248d1d9,68421f4bd9f2e1633a1a6306860ffc1e3f11c5e8..713577fad17beb0c5d46932b7d845cea4b18cd7e
@@@ -1,7 -1,5 +1,7 @@@
  #include "g_subs.qh"
  
 +#include <server/defs.qh>
 +#include <server/miscfunctions.qh>
  #include "antilag.qh"
  #include "command/common.qh"
  #include "../common/state.qh"
@@@ -85,13 -83,15 +85,15 @@@ void traceline_antilag_force (entity so
  }
  void traceline_antilag (entity source, vector v1, vector v2, float nomonst, entity forent, float lag)
  {
-       if (autocvar_g_antilag != 2 || source.cvar_cl_noantilag)
+       bool noantilag = ((IS_CLIENT(source)) ? CS(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)
  {
-       if (autocvar_g_antilag != 2 || source.cvar_cl_noantilag)
+       bool noantilag = ((IS_CLIENT(source)) ? CS(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);
  }
@@@ -101,13 -101,15 +103,15 @@@ void WarpZone_traceline_antilag_force (
  }
  void WarpZone_traceline_antilag (entity source, vector v1, vector v2, float nomonst, entity forent, float lag)
  {
-       if (autocvar_g_antilag != 2 || source.cvar_cl_noantilag)
+       bool noantilag = ((IS_CLIENT(source)) ? CS(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)
  {
-       if (autocvar_g_antilag != 2 || source.cvar_cl_noantilag)
+       bool noantilag = ((IS_CLIENT(source)) ? CS(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 --combined qcsrc/server/g_world.qc
index 73349ecac7503edaae239003cedefb681997881a,486bf571cc497763ea126deb2e9ab96b1a0720c8..2812da09d08cd5b6e26a3c9407bc43d17bdf3a3b
@@@ -53,7 -53,7 +53,7 @@@ void PingPLReport_Think(entity this
        this.nextthink = time + delta;
  
        e = edict_num(this.cnt + 1);
 -      if(IS_REAL_CLIENT(e))
 +      if(IS_CLIENT(e) && IS_REAL_CLIENT(e))
        {
                WriteHeader(MSG_BROADCAST, TE_CSQC_PINGPLREPORT);
                WriteByte(MSG_BROADCAST, this.cnt);
@@@ -1330,8 -1330,8 +1330,8 @@@ void IntermissionThink(entity this
  {
        FixIntermissionClient(this);
  
-       float server_screenshot = (autocvar_sv_autoscreenshot && this.cvar_cl_autoscreenshot);
-       float client_screenshot = (this.cvar_cl_autoscreenshot == 2);
+       float server_screenshot = (autocvar_sv_autoscreenshot && CS(this).cvar_cl_autoscreenshot);
+       float client_screenshot = (CS(this).cvar_cl_autoscreenshot == 2);
  
        if( (server_screenshot || client_screenshot)
                && ((this.autoscreenshot > 0) && (time > this.autoscreenshot)) )
index ffc0e9ea568cbd65278a5f050a6f8d1babd91404,cd3290d181fd3cde55ee4726f9332d6010657dcd..38d8926371282ba17882a2f623da0427673b29a9
@@@ -1,5 -1,4 +1,5 @@@
  #include "miscfunctions.qh"
 +
  #include "antilag.qh"
  #include "command/common.qh"
  #include "constants.qh"
@@@ -421,7 -420,7 +421,7 @@@ void GetCvars(entity this, int f
  
        Notification_GetCvars(this);
  
-       ReplicateVars(this, s, f);
+       ReplicateVars(this, CS(this), s, f);
  
        GetCvars_handleString_Fixup(this, s, f, cvar_cl_weaponpriority, "cl_weaponpriority", W_FixWeaponOrder_ForceComplete_AndBuildImpulseList);
        GetCvars_handleString_Fixup(this, s, f, cvar_cl_weaponpriorities[0], "cl_weaponpriority0", W_FixWeaponOrder_AllowIncomplete);
        GetCvars_handleString_Fixup(this, s, f, cvar_cl_weaponpriorities[8], "cl_weaponpriority8", W_FixWeaponOrder_AllowIncomplete);
        GetCvars_handleString_Fixup(this, s, f, cvar_cl_weaponpriorities[9], "cl_weaponpriority9", W_FixWeaponOrder_AllowIncomplete);
  
-       GetCvars_handleFloat(this, this, s, f, cvar_cl_allow_uidtracking, "cl_allow_uidtracking");
+       GetCvars_handleFloat(this, CS(this), s, f, cvar_cl_allow_uidtracking, "cl_allow_uidtracking");
  
        // fixup of switchweapon (needed for LMS or when spectating is disabled, as PutClientInServer comes too early)
        if (f > 0)
index c1698c554a0161e4e5a52523c60a0d74c425d689,a0d15c5465b0073e948dd523651095f5c8e28602..4c88d5e45f76d5abf32348cbbe0e0339525d34d6
@@@ -1,7 -1,6 +1,7 @@@
  #include "gamemode_ctf.qh"
  
  #ifndef CSQC
 +#include <common/effects/all.qh>
  void ctf_Initialize();
  
  REGISTER_MUTATOR(ctf, false)
@@@ -2238,7 -2237,7 +2238,7 @@@ MUTATOR_HOOKFUNCTION(ctf, GetPressedKey
  
        entity player = M_ARGV(0, entity);
  
-       if(player.cvar_cl_allow_uidtracking == 1 && player.cvar_cl_allow_uid2name == 1)
+       if(CS(player).cvar_cl_allow_uidtracking == 1 && CS(player).cvar_cl_allow_uid2name == 1)
        {
                if (!player.stored_netname)
                        player.stored_netname = strzone(uid2name(player.crypto_idfp));
diff --combined qcsrc/server/player.qc
index 827c86ae47ccda1a6c8acfae6e8809ee75f57728,9308886e23eee277b8c88695de4b04c6b9d9e253..9ac2249a234b50bd1bbf33dab9d2739dd433b1c3
@@@ -1,6 -1,5 +1,6 @@@
  #include "player.qh"
  
 +#include <common/effects/all.qh>
  #include "bot/api.qh"
  #include "cheats.qh"
  #include "g_damage.qh"
@@@ -317,9 -316,9 +317,9 @@@ void PlayerDamage(entity this, entity i
  
        if(!DEATH_ISSPECIAL(deathtype))
        {
-               damage *= bound(1.0, this.cvar_cl_handicap, 10.0);
-               if(this != attacker)
-                       damage /= bound(1.0, attacker.cvar_cl_handicap, 10.0);
+               damage *= bound(1.0, CS(this).cvar_cl_handicap, 10.0);
+               if(this != attacker && IS_PLAYER(attacker))
+                       damage /= bound(1.0, CS(attacker).cvar_cl_handicap, 10.0);
        }
  
        if (time < this.spawnshieldtime && autocvar_g_spawnshield_blockdamage < 1)
index 649726658784d163dfbfbd92427bfc1dde6f0d33,fbb39b9e64192ceb15d1656e9ba67cb8d1514a2b..f657789f8cc5f8a920f2fb096b89b7476405dcf7
@@@ -1,7 -1,5 +1,7 @@@
  #include "tracing.qh"
  
 +#include <common/effects/all.qh>
 +
  #include "accuracy.qh"
  #include "common.qh"
  #include "hitplot.qh"
@@@ -86,7 -84,7 +86,7 @@@ void W_SetupShot_Dir_ProjectileSize_Ran
        //vector prevend = w_shotend;
  
        if (antilag)
-       if (!ent.cvar_cl_noantilag)
+       if (!CS(ent).cvar_cl_noantilag)
        {
                if (autocvar_g_antilag == 1) // switch to "ghost" if not hitting original
                {
@@@ -353,7 -351,8 +353,8 @@@ void fireBullet(entity this, .entity we
        float lag = ((IS_REAL_CLIENT(this)) ? ANTILAG_LATENCY(this) : 0);
        if(lag < 0.001)
                lag = 0;
-       if(autocvar_g_antilag == 0 || this.cvar_cl_noantilag)
+       bool noantilag = ((IS_CLIENT(this)) ? CS(this).cvar_cl_noantilag : false);
+       if(autocvar_g_antilag == 0 || noantilag)
                lag = 0; // only do hitscan, but no antilag
        if(lag)
        {