]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_client.qc
Make sure a vote is actually running before trying to count it when a client leaves
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_client.qc
index 20068e0131a760305aff8d8e0db77abc539e5f5d..de2603437e253f69e2c2322706a55ba846f8c92f 100644 (file)
@@ -209,7 +209,7 @@ void PutObserverInServer()
        if(self.vehicle)
                vehicles_exit(VHEF_RELEASE);
 
-       WaypointSprite_PlayerDead();
+       WaypointSprite_PlayerDead(self);
 
        if(!mutator_returnvalue)  // mutator prevents resetting teams
                self.team = -1;  // move this as it is needed to log the player spectating in eventlog
@@ -731,21 +731,21 @@ Called when a client types 'kill' in the console
 */
 
 .float clientkill_nexttime;
-void ClientKill_Now_TeamChange()
-{SELFPARAM();
-       if(self.killindicator_teamchange == -1)
+void ClientKill_Now_TeamChange(entity this)
+{
+       if(this.killindicator_teamchange == -1)
        {
-               JoinBestTeam( self, false, true );
+               JoinBestTeam( this, false, true );
        }
-       else if(self.killindicator_teamchange == -2)
+       else if(this.killindicator_teamchange == -2)
        {
                if(blockSpectators)
-                       Send_Notification(NOTIF_ONE_ONLY, self, MSG_INFO, INFO_SPECTATE_WARNING, autocvar_g_maxplayers_spectator_blocktime);
-               PutObserverInServer();
+                       Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_SPECTATE_WARNING, autocvar_g_maxplayers_spectator_blocktime);
+               WITH(entity, self, this, PutObserverInServer());
        }
        else
-               SV_ChangeTeam(self.killindicator_teamchange - 1);
-       self.killindicator_teamchange = 0;
+               WITH(entity, self, this, SV_ChangeTeam(this.killindicator_teamchange - 1));
+       this.killindicator_teamchange = 0;
 }
 
 void ClientKill_Now()
@@ -766,7 +766,7 @@ void ClientKill_Now()
        self.killindicator = world;
 
        if(self.killindicator_teamchange)
-               ClientKill_Now_TeamChange();
+               ClientKill_Now_TeamChange(self);
 
        if(IS_PLAYER(self))
                Damage(self, self, self, 100000, DEATH_KILL.m_id, self.origin, '0 0 0');
@@ -1078,7 +1078,7 @@ void ClientConnect()
 
        this.netname_previous = strzone(this.netname);
 
-       Send_Notification(NOTIF_ALL, NULL, MSG_INFO, (teamplay ? APP_TEAM_ENT_4(this, INFO_JOIN_CONNECT_TEAM_) : INFO_JOIN_CONNECT), this.netname);
+       Send_Notification(NOTIF_ALL, NULL, MSG_INFO, ((teamplay && IS_PLAYER(this)) ? APP_TEAM_ENT_4(this, 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?
@@ -1244,6 +1244,9 @@ void ClientDisconnect ()
 
        self.playerid = 0;
        ReadyCount();
+       if(vote_called)
+       if(IS_REAL_CLIENT(self))
+               VoteCount(false);
 
        // free cvars
        GetCvars(-1);
@@ -1263,7 +1266,7 @@ void ChatBubbleThink()
 
        self.mdl = "";
 
-       if ( !self.owner.deadflag && IS_PLAYER(self.owner) )
+       if ( !IS_DEAD(self.owner) && IS_PLAYER(self.owner) )
        {
                if ( self.owner.active_minigame )
                        self.mdl = "models/sprites/minigame_busy.iqm";
@@ -1330,7 +1333,7 @@ void respawn()
                        SUB_SetFade (self, time + autocvar_g_respawn_ghosts_maxtime / 2 + random () * (autocvar_g_respawn_ghosts_maxtime - autocvar_g_respawn_ghosts_maxtime / 2), 1.5);
        }
 
-       CopyBody(1);
+       CopyBody(self, 1);
 
        self.effects |= EF_NODRAW; // prevent another CopyBody
        PutClientInServer();
@@ -1349,14 +1352,14 @@ void player_powerups ()
        // add a way to see what the items were BEFORE all of these checks for the mutator hook
        int items_prev = self.items;
 
-       if((self.items & IT_USING_JETPACK) && !self.deadflag && !gameover)
+       if((self.items & IT_USING_JETPACK) && !IS_DEAD(self) && !gameover)
                self.modelflags |= MF_ROCKET;
        else
                self.modelflags &= ~MF_ROCKET;
 
        self.effects &= ~(EF_RED | EF_BLUE | EF_ADDITIVE | EF_FULLBRIGHT | EF_FLAME | EF_NODEPTHTEST);
 
-       if((self.alpha < 0 || self.deadflag) && !self.vehicle) // don't apply the flags if the player is gibbed
+       if((self.alpha < 0 || IS_DEAD(self)) && !self.vehicle) // don't apply the flags if the player is gibbed
                return;
 
        Fire_ApplyDamage(self);
@@ -1552,7 +1555,7 @@ void player_regen ()
                if(self.vehicle)
                        vehicles_exit(VHEF_RELEASE);
                if(self.event_damage)
-                       self.event_damage(self, self, 1, DEATH_ROT.m_id, self.origin, '0 0 0');
+                       self.event_damage(self, self, self, 1, DEATH_ROT.m_id, self.origin, '0 0 0');
        }
 
        if (!(self.items & IT_UNLIMITED_WEAPON_AMMO))
@@ -1827,7 +1830,7 @@ void LeaveSpectatorMode()
 
                        PutClientInServer();
 
-                       if(IS_PLAYER(self)) { Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_JOIN_PLAY, self.netname); }
+                       if(IS_PLAYER(self)) { Send_Notification(NOTIF_ALL, world, MSG_INFO, ((teamplay && this.team != -1) ? APP_TEAM_ENT_4(this, INFO_JOIN_PLAY_TEAM_) : INFO_JOIN_PLAY), self.netname); }
                }
                else
                        stuffcmd(self, "menu_showteamselect\n");
@@ -2195,7 +2198,7 @@ void PlayerPreThink ()
                {
                        if(self.vehicle)
                                vehicles_exit(VHEF_RELEASE);
-                       self.event_damage(self, self.frozen_by, 1, DEATH_NADE_ICE_FREEZE.m_id, self.origin, '0 0 0');
+                       self.event_damage(self, self, self.frozen_by, 1, DEATH_NADE_ICE_FREEZE.m_id, self.origin, '0 0 0');
                }
                else if ( self.revive_progress <= 0 )
                        Unfreeze(self);
@@ -2397,7 +2400,7 @@ void PlayerPreThink ()
                secrets_setstatus();
 
                // monsters status
-               monsters_setstatus();
+               monsters_setstatus(self);
 
                self.dmg_team = max(0, self.dmg_team - autocvar_g_teamdamage_resetspeed * frametime);