]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_client.qc
Merge remote branch 'origin/master' into samual/mutator_ctf
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_client.qc
index 655eed0fa7151f3eff0cd8612e8a52b39cdf1e64..5d630057e4864c908b312e6c3a879054b255ceeb 100644 (file)
@@ -404,8 +404,7 @@ void PutObserverInServer (void)
        DropAllRunes(self);
        MUTATOR_CALLHOOK(MakePlayerObserver);
 
-       if (g_minstagib)
-               minstagib_stop_countdown();
+       minstagib_stop_countdown(self);
 
        Portal_ClearAll(self);
 
@@ -421,9 +420,6 @@ void PutObserverInServer (void)
        if(self.flagcarried)
                ctf_Handle_Drop(self); // FIXCTF
 
-       if(self.ballcarried && g_nexball)
-               DropBall(self.ballcarried, self.origin + self.ballcarried.origin, self.velocity);
-
        WaypointSprite_PlayerDead();
 
        if not(g_ca)  // don't reset teams when moving a ca player to the spectators
@@ -645,11 +641,14 @@ Called when a client spawns in the server
 =============
 */
 //void() ctf_playerchanged;
+
 void PutClientInServer (void)
 {
        if(clienttype(self) == CLIENTTYPE_BOT)
        {
                self.classname = "player";
+               if(g_ca)
+                       self.caplayer = 1;
        }
        else if(clienttype(self) == CLIENTTYPE_REAL)
        {
@@ -657,7 +656,7 @@ void PutClientInServer (void)
                WriteByte(MSG_ONE, SVC_SETVIEW);
                WriteEntity(MSG_ONE, self);
        }
-       
+
        // reset player keys
        self.itemkeys = 0;
 
@@ -669,8 +668,7 @@ void PutClientInServer (void)
                        self.classname = "observer";
        }
 
-       if(g_arena || (g_ca && !allowed_to_spawn))
-       if(!self.spawned)
+       if((g_arena && !self.spawned) || (g_ca && !allowed_to_spawn))
                self.classname = "observer";
 
        if(gameover)
@@ -834,13 +832,12 @@ void PutClientInServer (void)
                self.lastrocket = world; // stop rocket guiding, no revenge from the grave!
                self.lastteleporttime = time; // prevent insane speeds due to changing origin
         self.hud = HUD_NORMAL;
-        
+
                if(g_arena)
                {
                        Spawnqueue_Remove(self);
                        Spawnqueue_Mark(self);
                }
-
                else if(g_ca)
                        self.caplayer = 1;
 
@@ -924,7 +921,7 @@ void PutClientInServer (void)
                        self.alivetime = time;
 
                antilag_clear(self);
-       } else if(self.classname == "observer" || (g_ca && !allowed_to_spawn)) {
+       } else if(self.classname == "observer") {
                PutObserverInServer ();
        }
 
@@ -1596,8 +1593,12 @@ void ClientConnect (void)
        CSQCMODEL_AUTOINIT();
 
        self.model_randomizer = random();
+    
+    if(clienttype(self) != CLIENTTYPE_REAL)
+        return;
+        
+    sv_notice_join();
 }
-
 /*
 =============
 ClientDisconnect
@@ -1653,8 +1654,6 @@ void ClientDisconnect (void)
        RemoveGrapplingHook(self);
        if(self.flagcarried)
                ctf_Handle_Drop(self); // FIXCTF
-       if(self.ballcarried && g_nexball)
-               DropBall(self.ballcarried, self.origin + self.ballcarried.origin, self.velocity);
 
        // Here, everything has been done that requires this player to be a client.
 
@@ -2314,7 +2313,7 @@ void ShowRespawnCountdown()
 .float prevent_join_msgtime;
 void LeaveSpectatorMode()
 {
-       if(nJoinAllowed(1)) {
+       if(nJoinAllowed(self)) {
                if(!teamplay || autocvar_g_campaign || autocvar_g_balance_teams || (self.wasplayer && autocvar_g_changeteam_banned) || self.team_forced > 0) {
                        self.classname = "player";
 
@@ -2364,26 +2363,36 @@ void LeaveSpectatorMode()
  * it checks whether the number of currently playing players exceeds g_maxplayers.
  * @return int number of free slots for players, 0 if none
  */
-float nJoinAllowed(float includeMe) {
+float nJoinAllowed(entity ignore) {
+       if(!ignore)
+       // this is called that way when checking if anyone may be able to join (to build qcstatus)
+       // so report 0 free slots if restricted
+       {
+               if(autocvar_g_forced_team_otherwise == "spectate")
+                       return 0;
+               if(autocvar_g_forced_team_otherwise == "spectator")
+                       return 0;
+       }
+
        if(self.team_forced < 0)
-               return FALSE; // forced spectators can never join
+               return 0; // forced spectators can never join
 
        // TODO simplify this
        entity e;
-
        float totalClients;
        FOR_EACH_CLIENT(e)
-               totalClients += 1;
+               if(e != ignore)
+                       totalClients += 1;
 
        if (!autocvar_g_maxplayers)
-               return maxclients - totalClients + includeMe;
+               return maxclients - totalClients;
 
        float currentlyPlaying;
        FOR_EACH_REALPLAYER(e)
                currentlyPlaying += 1;
 
        if(currentlyPlaying < autocvar_g_maxplayers)
-               return min(maxclients - totalClients + includeMe, autocvar_g_maxplayers - currentlyPlaying);
+               return min(maxclients - totalClients, autocvar_g_maxplayers - currentlyPlaying);
 
        return 0;
 }
@@ -3037,8 +3046,6 @@ void PlayerPostThink (void)
        }
        */
 
-       Arena_Warmup();
-
        //pointparticles(particleeffectnum("machinegun_impact"), self.origin + self.view_ofs + '0 0 7', '0 0 0', 1);
 
        if(self.waypointsprite_attachedforcarrier)