]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Don't consider the client allowed to spawn while showing the team selection dialog...
authorterencehill <piuntn@gmail.com>
Sat, 3 Sep 2016 18:10:05 +0000 (20:10 +0200)
committerterencehill <piuntn@gmail.com>
Sat, 3 Sep 2016 18:10:05 +0000 (20:10 +0200)
qcsrc/server/client.qc
qcsrc/server/command/cmd.qc
qcsrc/server/mutators/mutator/gamemode_ca.qc

index 2d1ff865778a8efda61ae4598f719ea83deaa282..d2c6c991835c74c3c4af80999268d7fcc90d00ae 100644 (file)
@@ -1867,30 +1867,34 @@ void ShowRespawnCountdown(entity this)
 }
 
 .bool team_selected;
-void JoinOrShowTeamSelection(entity this)
+bool ShowTeamSelection(entity this)
 {
        if(!teamplay || autocvar_g_campaign || autocvar_g_balance_teams || this.team_selected || (this.wasplayer && autocvar_g_changeteam_banned) || this.team_forced > 0)
-       {
-               TRANSMUTE(Player, this);
+               return false;
+       stuffcmd(this, "menu_showteamselect\n");
+       return true;
+}
+void Join(entity this)
+{
+       TRANSMUTE(Player, this);
 
-               SetSpectatee(this, NULL);
+       SetSpectatee(this, NULL);
 
-               if(autocvar_g_campaign || autocvar_g_balance_teams)
-                       JoinBestTeam(this, false, true);
+       if(!this.team_selected)
+       if(autocvar_g_campaign || autocvar_g_balance_teams)
+               JoinBestTeam(this, false, true);
 
-               if(autocvar_g_campaign)
-                       campaign_bots_may_start = true;
+       if(autocvar_g_campaign)
+               campaign_bots_may_start = true;
 
-               Kill_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CPID_PREVENT_JOIN);
+       Kill_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CPID_PREVENT_JOIN);
 
-               PutClientInServer(this);
-               PlayerScore_Clear(this);
+       PutClientInServer(this);
+       if(!this.team_selected)
+       PlayerScore_Clear(this);
 
-               Send_Notification(NOTIF_ALL, NULL, MSG_INFO, ((teamplay && this.team != -1) ? APP_TEAM_ENT(this, INFO_JOIN_PLAY_TEAM) : INFO_JOIN_PLAY), this.netname);
-               this.team_selected = false;
-       }
-       else
-               stuffcmd(this, "menu_showteamselect\n");
+       Send_Notification(NOTIF_ALL, NULL, MSG_INFO, ((teamplay && this.team != -1) ? APP_TEAM_ENT(this, INFO_JOIN_PLAY_TEAM) : INFO_JOIN_PLAY), this.netname);
+       this.team_selected = false;
 }
 
 /**
@@ -2010,6 +2014,7 @@ bool spawnAllowed(entity this)
        if (this.version_mismatch) return false;
        if (!nJoinAllowed(this, this)) return false;
        if (teamplay && lockteams) return false;
+       if (ShowTeamSelection(this)) return false;
        if (MUTATOR_CALLHOOK(ForbidSpawn, this)) return false;
        return true;
 }
@@ -2041,7 +2046,7 @@ void ObserverThink(entity this)
                        if(this.flags & FL_SPAWNING)
                        {
                                this.flags &= ~FL_SPAWNING;
-                               JoinOrShowTeamSelection(this);
+                               Join(this);
                                return;
                        }
                }
@@ -2099,7 +2104,7 @@ void SpectatorThink(entity this)
                        if(this.flags & FL_SPAWNING)
                        {
                                this.flags &= ~FL_SPAWNING;
-                               JoinOrShowTeamSelection(this);
+                               Join(this);
                                return;
                        }
                }
index bc5d560a3f398d8d424be49ad3f5763adc9ad6eb..7536b526a582d2372c7c69c0e9d74da68d6291a6 100644 (file)
@@ -160,7 +160,7 @@ void ClientCommand_mv_getpicture(entity caller, float request, float argc)  // i
 }
 
 bool spawnAllowed(entity this);
-void JoinOrShowTeamSelection(entity this);
+void Join(entity this);
 void ClientCommand_join(entity caller, float request)
 {
        switch (request)
@@ -170,7 +170,7 @@ void ClientCommand_join(entity caller, float request)
                        if (!gameover)
                        if (IS_CLIENT(caller) && !IS_PLAYER(caller))
                        if (spawnAllowed(caller))
-                               JoinOrShowTeamSelection(caller);
+                               Join(caller);
 
                        return;  // never fall through to usage
                }
index 8dda62f0b29a6d689c486c5a90eaf847e5d2f4c0..4707e9fca0032114922da14f16756523b4bb596a 100644 (file)
@@ -170,15 +170,11 @@ MUTATOR_HOOKFUNCTION(ca, ForbidSpawn)
 {
        entity player = M_ARGV(0, entity);
 
-       if (!allowed_to_spawn)
-       {
-               if (player.jointime != time && !player.caplayer) // not when connecting
-               {
-                       player.caplayer = 0.5;
-                       Send_Notification(NOTIF_ONE_ONLY, player, MSG_INFO, INFO_CA_JOIN_LATE);
-               }
+       // spectators / observers that weren't playing can join; they are
+       // immediately forced to observe in the PutClientInServer hook
+       // this way they are put in a team and can play in the next round
+       if (!allowed_to_spawn && player.caplayer)
                return true;
-       }
        return false;
 }