]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_client.qc
Teams: setteam
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_client.qc
index df51f8813f200776b7a55f8e29a4edb79cd20550..dbeb28fbe8cd86587e0518f11624066f912458a1 100644 (file)
@@ -23,7 +23,9 @@
 #include "bot/navigation.qh"
 
 #include "../common/ent_cs.qh"
-#include "../common/state.qh"
+#include <common/state.qh>
+
+#include <common/effects/qc/globalsound.qh>
 
 #include "../common/triggers/teleporters.qh"
 
@@ -190,6 +192,7 @@ void PutObserverInServer()
         }
         // give the spectator some space between walls for MOVETYPE_FLY_WORLDONLY
         // so that your view doesn't go into the ceiling with MOVETYPE_FLY_WORLDONLY, previously "PL_VIEW_OFS"
+        setmodel(this, MDL_Null);
         setsize(this, STAT(PL_CROUCH_MIN, NULL), STAT(PL_CROUCH_MAX, NULL));
         this.view_ofs = '0 0 0';
     }
@@ -212,7 +215,7 @@ void PutObserverInServer()
        if (mutator_returnvalue) {
            // mutator prevents resetting teams+score
        } else {
-               this.team = -1;  // move this as it is needed to log the player spectating in eventlog
+               setteam(this, -1);  // move this as it is needed to log the player spectating in eventlog
         this.frags = FRAGS_SPECTATOR;
         PlayerScore_Clear(this);  // clear scores when needed
     }
@@ -274,9 +277,6 @@ void PutObserverInServer()
 
        this.items = 0;
        this.weapons = '0 0 0';
-       this.model = "";
-       FixPlayermodel(this);
-       setmodel(this, MDL_Null);
        this.drawonlytoclient = this;
 
        this.weaponname = "";
@@ -314,7 +314,7 @@ void FixPlayermodel(entity player)
        {
                if(teamplay)
                {
-                       string s = Static_Team_ColorName_Lower(player.team);
+                       string s = Static_Team_ColorName_Lower(TMID(player.team));
                        if (s != "neutral")
                        {
                                defaultmodel = cvar_string(strcat("sv_defaultplayermodel_", s));
@@ -419,7 +419,7 @@ void PutClientInServer()
                PlayerState_attach(this);
                accuracy_resend(this);
 
-               if (this.team < 0)
+               if (TMID(this.team) < 0)
                        JoinBestTeam(this, false, true);
 
                entity spot = SelectSpawnPoint(false);
@@ -604,7 +604,7 @@ void PutClientInServer()
                if (!warmup_stage && !this.alivetime)
                        this.alivetime = time;
 
-               antilag_clear(this);
+               antilag_clear(this, CS(this));
        }
 }
 
@@ -1047,13 +1047,13 @@ void ClientConnect()
        if (autocvar_sv_eventlog)
                GameLogEcho(strcat(":join:", ftos(this.playerid), ":", ftos(etof(this)), ":", ((IS_REAL_CLIENT(this)) ? this.netaddress : "bot"), ":", this.netname));
 
-       LogTeamchange(this.playerid, this.team, 1);
+       LogTeamchange(this.playerid, TMID(this.team), 1);
 
        this.just_joined = true;  // stop spamming the eventlog with additional lines when the client connects
 
        this.netname_previous = strzone(this.netname);
 
-       Send_Notification(NOTIF_ALL, NULL, MSG_INFO, ((teamplay && IS_PLAYER(this)) ? APP_TEAM_ENT(this, INFO_JOIN_CONNECT_TEAM) : INFO_JOIN_CONNECT), this.netname);
+       Send_Notification(NOTIF_ALL, NULL, MSG_INFO, ((teamplay && IS_PLAYER(this)) ? APP_TEAM_NUM(TMID(this.team), INFO_JOIN_CONNECT_TEAM) : INFO_JOIN_CONNECT), this.netname);
 
        stuffcmd(this, clientstuff, "\n");
        stuffcmd(this, "cl_particles_reloadeffects\n"); // TODO do we still need this?
@@ -1530,66 +1530,64 @@ spectate mode routines
 
 void SpectateCopy(entity this, entity spectatee)
 {
-       MUTATOR_CALLHOOK(SpectateCopy, spectatee, self);
-       self.armortype = spectatee.armortype;
-       self.armorvalue = spectatee.armorvalue;
-       self.ammo_cells = spectatee.ammo_cells;
-       self.ammo_plasma = spectatee.ammo_plasma;
-       self.ammo_shells = spectatee.ammo_shells;
-       self.ammo_nails = spectatee.ammo_nails;
-       self.ammo_rockets = spectatee.ammo_rockets;
-       self.ammo_fuel = spectatee.ammo_fuel;
-       self.clip_load = spectatee.clip_load;
-       self.clip_size = spectatee.clip_size;
-       self.effects = spectatee.effects & EFMASK_CHEAP; // eat performance
-       self.health = spectatee.health;
-       self.impulse = 0;
-       self.items = spectatee.items;
-       self.last_pickup = spectatee.last_pickup;
-       self.hit_time = spectatee.hit_time;
-       self.strength_finished = spectatee.strength_finished;
-       self.invincible_finished = spectatee.invincible_finished;
-       self.pressedkeys = spectatee.pressedkeys;
-       self.weapons = spectatee.weapons;
-       PS(self).m_switchweapon = PS(spectatee).m_switchweapon;
-       PS(self).m_switchingweapon = PS(spectatee).m_switchingweapon;
-       PS(self).m_weapon = PS(spectatee).m_weapon;
-       self.vortex_charge = spectatee.vortex_charge;
-       self.vortex_chargepool_ammo = spectatee.vortex_chargepool_ammo;
-       self.hagar_load = spectatee.hagar_load;
-       self.arc_heat_percent = spectatee.arc_heat_percent;
-       self.minelayer_mines = spectatee.minelayer_mines;
-       self.punchangle = spectatee.punchangle;
-       self.view_ofs = spectatee.view_ofs;
-       self.velocity = spectatee.velocity;
-       self.dmg_take = spectatee.dmg_take;
-       self.dmg_save = spectatee.dmg_save;
-       self.dmg_inflictor = spectatee.dmg_inflictor;
-       self.v_angle = spectatee.v_angle;
-       self.angles = spectatee.v_angle;
-       STAT(FROZEN, self) = STAT(FROZEN, spectatee);
-       self.revive_progress = spectatee.revive_progress;
-       if(!PHYS_INPUT_BUTTON_USE(self))
-               self.fixangle = true;
-       setorigin(self, spectatee.origin);
-       setsize(self, spectatee.mins, spectatee.maxs);
+       MUTATOR_CALLHOOK(SpectateCopy, spectatee, this);
+       PS(this) = PS(spectatee);
+       this.armortype = spectatee.armortype;
+       this.armorvalue = spectatee.armorvalue;
+       this.ammo_cells = spectatee.ammo_cells;
+       this.ammo_plasma = spectatee.ammo_plasma;
+       this.ammo_shells = spectatee.ammo_shells;
+       this.ammo_nails = spectatee.ammo_nails;
+       this.ammo_rockets = spectatee.ammo_rockets;
+       this.ammo_fuel = spectatee.ammo_fuel;
+       this.clip_load = spectatee.clip_load;
+       this.clip_size = spectatee.clip_size;
+       this.effects = spectatee.effects & EFMASK_CHEAP; // eat performance
+       this.health = spectatee.health;
+       this.impulse = 0;
+       this.items = spectatee.items;
+       this.last_pickup = spectatee.last_pickup;
+       this.hit_time = spectatee.hit_time;
+       this.strength_finished = spectatee.strength_finished;
+       this.invincible_finished = spectatee.invincible_finished;
+       this.pressedkeys = spectatee.pressedkeys;
+       this.weapons = spectatee.weapons;
+       this.vortex_charge = spectatee.vortex_charge;
+       this.vortex_chargepool_ammo = spectatee.vortex_chargepool_ammo;
+       this.hagar_load = spectatee.hagar_load;
+       this.arc_heat_percent = spectatee.arc_heat_percent;
+       this.minelayer_mines = spectatee.minelayer_mines;
+       this.punchangle = spectatee.punchangle;
+       this.view_ofs = spectatee.view_ofs;
+       this.velocity = spectatee.velocity;
+       this.dmg_take = spectatee.dmg_take;
+       this.dmg_save = spectatee.dmg_save;
+       this.dmg_inflictor = spectatee.dmg_inflictor;
+       this.v_angle = spectatee.v_angle;
+       this.angles = spectatee.v_angle;
+       STAT(FROZEN, this) = STAT(FROZEN, spectatee);
+       this.revive_progress = spectatee.revive_progress;
+       if(!PHYS_INPUT_BUTTON_USE(this))
+               this.fixangle = true;
+       setorigin(this, spectatee.origin);
+       setsize(this, spectatee.mins, spectatee.maxs);
        SetZoomState(spectatee.zoomstate);
 
     anticheat_spectatecopy(spectatee);
-       self.hud = spectatee.hud;
+       this.hud = spectatee.hud;
        if(spectatee.vehicle)
     {
-        self.fixangle = false;
-        //self.velocity = spectatee.vehicle.velocity;
-        self.vehicle_health = spectatee.vehicle_health;
-        self.vehicle_shield = spectatee.vehicle_shield;
-        self.vehicle_energy = spectatee.vehicle_energy;
-        self.vehicle_ammo1 = spectatee.vehicle_ammo1;
-        self.vehicle_ammo2 = spectatee.vehicle_ammo2;
-        self.vehicle_reload1 = spectatee.vehicle_reload1;
-        self.vehicle_reload2 = spectatee.vehicle_reload2;
-
-        msg_entity = self;
+        this.fixangle = false;
+        //this.velocity = spectatee.vehicle.velocity;
+        this.vehicle_health = spectatee.vehicle_health;
+        this.vehicle_shield = spectatee.vehicle_shield;
+        this.vehicle_energy = spectatee.vehicle_energy;
+        this.vehicle_ammo1 = spectatee.vehicle_ammo1;
+        this.vehicle_ammo2 = spectatee.vehicle_ammo2;
+        this.vehicle_reload1 = spectatee.vehicle_reload1;
+        this.vehicle_reload2 = spectatee.vehicle_reload2;
+
+        msg_entity = this;
 
         WriteByte (MSG_ONE, SVC_SETVIEWANGLES);
             WriteAngle(MSG_ONE,  spectatee.v_angle.x);
@@ -1597,9 +1595,9 @@ void SpectateCopy(entity this, entity spectatee)
             WriteAngle(MSG_ONE,  spectatee.v_angle.z);
 
         //WriteByte (MSG_ONE, SVC_SETVIEW);
-        //    WriteEntity(MSG_ONE, self);
+        //    WriteEntity(MSG_ONE, this);
         //makevectors(spectatee.v_angle);
-        //setorigin(self, spectatee.origin - v_forward * 400 + v_up * 300);*/
+        //setorigin(this, spectatee.origin - v_forward * 400 + v_up * 300);*/
     }
 }
 
@@ -1754,7 +1752,7 @@ void LeaveSpectatorMode()
 
                        PutClientInServer();
 
-                       if(IS_PLAYER(self)) { Send_Notification(NOTIF_ALL, world, MSG_INFO, ((teamplay && this.team != -1) ? APP_TEAM_ENT(this, INFO_JOIN_PLAY_TEAM) : INFO_JOIN_PLAY), self.netname); }
+                       if(IS_PLAYER(self)) { Send_Notification(NOTIF_ALL, world, MSG_INFO, ((teamplay && TMID(this.team) != -1) ? APP_TEAM_NUM(TMID(this.team), INFO_JOIN_PLAY_TEAM) : INFO_JOIN_PLAY), self.netname); }
                }
                else
                        stuffcmd(self, "menu_showteamselect\n");
@@ -2068,9 +2066,9 @@ void PlayerPreThink ()
                        if(time > self.version_nagtime)
                        {
                                // don't notify git users
-                               if(strstr(self.cvar_g_xonoticversion, "git", 0) < 0 && strstr(self.cvar_g_xonoticversion, "autobuild", 0) < 0)
+                               if(strstrofs(self.cvar_g_xonoticversion, "git", 0) < 0 && strstrofs(self.cvar_g_xonoticversion, "autobuild", 0) < 0)
                                {
-                                       if(strstr(autocvar_g_xonoticversion, "git", 0) >= 0 || strstr(autocvar_g_xonoticversion, "autobuild", 0) >= 0)
+                                       if(strstrofs(autocvar_g_xonoticversion, "git", 0) >= 0 || strstrofs(autocvar_g_xonoticversion, "autobuild", 0) >= 0)
                                        {
                                                // notify release users if connecting to git
                                                LOG_TRACE("^1NOTE^7 to ", self.netname, "^7 - the server is running ^3Xonotic ", autocvar_g_xonoticversion, " (beta)^7, you have ^3Xonotic ", self.cvar_g_xonoticversion, "^1\n");