]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_client.qc
Merge remote branch 'origin/fruitiex/ctsfix'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_client.qc
index 6ac29a7f83d1af4ae2878d08f85e08d9a41252b0..475771fd3a23e86c174b5a2592a0122b0babe8f8 100644 (file)
@@ -1244,18 +1244,16 @@ void ClientKill_Now_TeamChange()
 
 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()
 {
@@ -1272,7 +1270,7 @@ void KillIndicator_Think()
                ClientKill_Now(); // no oldself needed
                return;
        }
-    else if(g_cts)
+    else if(g_cts && self.health == 1) // health == 1 means that it's silent
     {
         self.nextthink = time + 1;
         self.cnt -= 1;
@@ -1311,16 +1309,25 @@ void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto, -2
        if(g_race_qualifying || g_cts)
                killtime = 0;
 
-       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(g_cts && self.killindicator && self.killindicator.health == 1) // self.killindicator.health == 1 means that the kill indicator was spawned by CTS_ClientKill
+    {
+               remove(self.killindicator);
+               self.killindicator = world;
+
+        ClientKill_Now(); // allow instant kill in this case
+        return;
+    }
 
        self.killindicator_teamchange = targetteam;
 
     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();
@@ -1381,13 +1388,14 @@ void ClientKill (void)
                ClientKill_TeamChange(0);
 }
 
-void CTS_ClientKill (entity e) // silent version of ClientKill
+void CTS_ClientKill (entity e) // silent version of ClientKill, used when player finishes a CTS run. Useful to prevent cheating by running back to the start line and starting out with more speed
 {
     e.killindicator = spawn();
     e.killindicator.owner = e;
     e.killindicator.think = KillIndicator_Think;
     e.killindicator.nextthink = time + (e.lip) * 0.05;
     e.killindicator.cnt = ceil(autocvar_g_cts_finish_kill_delay);
+    e.killindicator.health = 1; // this is used to indicate that it should be silent
     e.lip = 0;
 }