]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Enhance LeaveSpectatorMode code so it can handle the join command too (called by...
authorterencehill <piuntn@gmail.com>
Wed, 24 Aug 2016 23:40:38 +0000 (01:40 +0200)
committerterencehill <piuntn@gmail.com>
Wed, 24 Aug 2016 23:40:38 +0000 (01:40 +0200)
qcsrc/server/client.qc
qcsrc/server/command/cmd.qc

index 0c48324254d567bc20c2ede64e6f1df0544bca3c..c9a8dd5d85ace0cad09a42669496b48384d05477 100644 (file)
@@ -1861,11 +1861,12 @@ void ShowRespawnCountdown(entity this)
        }
 }
 
+.int team_selected;
 void LeaveSpectatorMode(entity this)
 {
        if(nJoinAllowed(this, this))
        {
-               if(!teamplay || autocvar_g_campaign || autocvar_g_balance_teams || (this.wasplayer && autocvar_g_changeteam_banned) || this.team_forced > 0)
+               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);
 
@@ -1880,8 +1881,10 @@ void LeaveSpectatorMode(entity this)
                        Kill_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CPID_PREVENT_JOIN);
 
                        PutClientInServer(this);
+                       PlayerScore_Clear(this);
 
                        if(IS_PLAYER(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");
@@ -1998,6 +2001,14 @@ void PrintWelcomeMessage(entity this)
        }
 }
 
+bool spawnAllowed(entity this)
+{
+       if (this.version_mismatch) return false;
+       if (teamplay && lockteams) return false;
+       if (MUTATOR_CALLHOOK(ForbidSpawn, this)) return false;
+       return true;
+}
+
 void ObserverThink(entity this)
 {
        if ( this.impulse )
@@ -2007,7 +2018,7 @@ void ObserverThink(entity this)
        }
 
        if (this.flags & FL_JUMPRELEASED) {
-               if (PHYS_INPUT_BUTTON_JUMP(this) && !this.version_mismatch && !MUTATOR_CALLHOOK(ForbidSpawn, this)) {
+               if (PHYS_INPUT_BUTTON_JUMP(this) && spawnAllowed(this)) {
                        this.flags &= ~FL_JUMPRELEASED;
                        this.flags |= FL_SPAWNING;
                } else if(PHYS_INPUT_BUTTON_ATCK(this) && !this.version_mismatch) {
@@ -2048,7 +2059,7 @@ void SpectatorThink(entity this)
        }
 
        if (this.flags & FL_JUMPRELEASED) {
-               if (PHYS_INPUT_BUTTON_JUMP(this) && !this.version_mismatch && !MUTATOR_CALLHOOK(ForbidSpawn, this)) {
+               if (PHYS_INPUT_BUTTON_JUMP(this) && spawnAllowed(this)) {
                        this.flags &= ~FL_JUMPRELEASED;
                        this.flags |= FL_SPAWNING;
                } else if(PHYS_INPUT_BUTTON_ATCK(this) || this.impulse == 10 || this.impulse == 15 || this.impulse == 18 || (this.impulse >= 200 && this.impulse <= 209)) {
index e23f9bc9892a70ddf649f69ee7f7725b9bc66035..5d6ad3adab263edf38a8c51bec8febbab19528d8 100644 (file)
@@ -159,33 +159,19 @@ void ClientCommand_mv_getpicture(entity caller, float request, float argc)  // i
        }
 }
 
+bool spawnAllowed(entity this);
+void LeaveSpectatorMode(entity this);
 void ClientCommand_join(entity caller, float request)
 {
        switch (request)
        {
                case CMD_REQUEST_COMMAND:
                {
-                       if (IS_CLIENT(caller))
-                       {
-                               if (!IS_PLAYER(caller) && !lockteams && !gameover)
-                               {
-                                       if (caller.caplayer) return;
-                                       if (nJoinAllowed(caller, caller))
-                                       {
-                                               if (autocvar_g_campaign)   campaign_bots_may_start = true;
-                                               TRANSMUTE(Player, caller);
-                                               PlayerScore_Clear(caller);
-                                               Kill_Notification(NOTIF_ONE_ONLY, caller, MSG_CENTER, CPID_PREVENT_JOIN);
-                                               Send_Notification(NOTIF_ALL, NULL, MSG_INFO, ((teamplay && caller.team != -1) ? APP_TEAM_ENT(caller, INFO_JOIN_PLAY_TEAM) : INFO_JOIN_PLAY), caller.netname);
-                                               PutClientInServer(caller);
-                                       }
-                                       else
-                                       {
-                                               // player may not join because of g_maxplayers is set
-                                               Send_Notification(NOTIF_ONE_ONLY, caller, MSG_CENTER, CENTER_JOIN_PREVENT);
-                                       }
-                               }
-                       }
+                       if (!gameover)
+                       if (IS_CLIENT(caller) && !IS_PLAYER(caller))
+                       if (spawnAllowed(caller))
+                               LeaveSpectatorMode(caller);
+
                        return;  // never fall through to usage
                }
 
@@ -326,6 +312,7 @@ void ClientCommand_say_team(entity caller, float request, float argc, string com
        }
 }
 
+.int selectedteam;
 void ClientCommand_selectteam(entity caller, float request, float argc)
 {
        switch (request)
@@ -363,7 +350,7 @@ void ClientCommand_selectteam(entity caller, float request, float argc)
 
                                                                if (selection)
                                                                {
-                                                                       if (caller.team == selection && !IS_DEAD(caller))
+                                                                       if (caller.team == selection && selection != -1 && !IS_DEAD(caller))
                                                                        {
                                                                                sprint(caller, "^7You already are on that team.\n");
                                                                        }
@@ -385,6 +372,8 @@ void ClientCommand_selectteam(entity caller, float request, float argc)
                                                                                }
                                                                                ClientKill_TeamChange(caller, selection);
                                                                        }
+                                                                       if(!IS_PLAYER(caller))
+                                                                               caller.team_selected = true; // avoids asking again for team selection on join
                                                                }
                                                        }
                                                        else