]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_client.qc
possibly fix the kill indicator leak bug
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_client.qc
index 5ff519bd70695e15627a7680d7342b2ef9f441d7..2b8dc1881c77a9fca7d4dce51fda57ebbb6d2f8a 100644 (file)
@@ -1222,6 +1222,7 @@ Called when a client types 'kill' in the console
 =============
 */
 
+.float clientkill_nexttime;
 void ClientKill_Now_TeamChange()
 {
        if(self.killindicator_teamchange == -1)
@@ -1229,24 +1230,30 @@ void ClientKill_Now_TeamChange()
                self.team = -1;
                JoinBestTeam( self, FALSE, FALSE );
        }
+       else if(self.killindicator_teamchange == -2)
+       {
+               if(g_ca)
+                       self.caplayer = 0;
+               if(blockSpectators)
+                       sprint(self, strcat("^7You have to become a player within the next ", ftos(autocvar_g_maxplayers_spectator_blocktime), " seconds, otherwise you will be kicked, because spectators aren't allowed at this time!\n"));
+               PutObserverInServer();
+       }
        else
                SV_ChangeTeam(self.killindicator_teamchange - 1);
 }
 
 void ClientKill_Now()
 {
+       remove(self.killindicator);
+       self.killindicator = world;
+
        if(self.killindicator_teamchange)
                ClientKill_Now_TeamChange();
 
        // in any case:
        Damage(self, self, self, 100000, DEATH_KILL, self.origin, '0 0 0');
 
-       if(self.killindicator)
-       {
-               dprint("Cleaned up after a leaked kill indicator.\n");
-               remove(self.killindicator);
-               self.killindicator = world;
-       }
+       // now I am sure the player IS dead
 }
 void KillIndicator_Think()
 {
@@ -1275,6 +1282,8 @@ void KillIndicator_Think()
                        {
                                if(self.owner.killindicator_teamchange == -1)
                                        centerprint(self.owner, strcat("Changing team in ", ftos(self.cnt), " seconds"));
+                               else if(self.owner.killindicator_teamchange == -2)
+                                       centerprint(self.owner, strcat("Spectating in ", ftos(self.cnt), " seconds"));
                                else
                                        centerprint(self.owner, strcat("Changing to ", ColoredTeamName(self.owner.killindicator_teamchange), " in ", ftos(self.cnt), " seconds"));
                        }
@@ -1286,7 +1295,7 @@ void KillIndicator_Think()
        }
 }
 
-void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto
+void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto, -2 = spec
 {
        float killtime;
        entity e;
@@ -1299,6 +1308,12 @@ void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto
 
        if(!self.killindicator)
        {
+               if(self.modelindex && self.deadflag == DEAD_NO)
+               {
+                       killtime = max(killtime, self.clientkill_nexttime - time);
+                       self.clientkill_nexttime = time + killtime + autocvar_g_balance_kill_antispam;
+               }
+
                if(killtime <= 0 || !self.modelindex || self.deadflag != DEAD_NO)
                {
                        ClientKill_Now();
@@ -1334,10 +1349,14 @@ void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto
        }
        if(self.killindicator)
        {
-               if(targetteam)
-                       self.killindicator.colormod = TeamColor(targetteam);
-               else
+               if(targetteam == 0) // just die
                        self.killindicator.colormod = '0 0 0';
+               else if(targetteam == -1) // auto
+                       self.killindicator.colormod = '0 1 0';
+               else if(targetteam == -2) // spectate
+                       self.killindicator.colormod = '0.5 0.5 0.5';
+               else
+                       self.killindicator.colormod = TeamColor(targetteam);
        }
 }