]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Further changes
authorz411 <z411@omaera.org>
Mon, 7 Nov 2022 11:39:06 +0000 (08:39 -0300)
committerz411 <z411@omaera.org>
Mon, 7 Nov 2022 11:39:06 +0000 (08:39 -0300)
qcsrc/common/notifications/all.inc
qcsrc/server/client.qc
qcsrc/server/teamplay.qc
qcsrc/server/teamplay.qh

index 360a3439a61478ac7d649a0c2e26ad247239c37f..5e9015e5c10d564c05724a4bd26bdffb96cad4fc 100644 (file)
@@ -380,6 +380,7 @@ string multiteam_info_sprintf(string input, string teamname) { return ((input !=
     MSG_INFO_NOTIF(JOIN_CONNECT,                            N_CHATCON,  1, 0, "s1", "",         "",     _("^BG%s^F3 connected"), "")
     MSG_INFO_NOTIF(JOIN_PLAY,                               N_CHATCON,  1, 0, "s1", "",         "",     _("^BG%s^F3 is now playing"), "")
     MULTITEAM_INFO(JOIN_PLAY_TEAM,                          N_CHATCON,  1, 0, "s1", "",         "",     _("^BG%s^F3 is now playing on the ^TC^TT team"), "", NAME)
+       MULTITEAM_INFO(JOIN_WANTS_TEAM,                         N_CHATCON,  1, 0, "s1", "",         "",     _("^BG%s^F3 wants to play on the ^TC^TT team"), "", NAME)
 
     MSG_INFO_NOTIF(KEEPAWAY_DROPPED,                        N_CONSOLE,  1, 0, "s1", "s1",       "notify_balldropped",       _("^BG%s^BG has dropped the ball!"), "")
     MSG_INFO_NOTIF(KEEPAWAY_PICKUP,                         N_CONSOLE,  1, 0, "s1", "s1",       "notify_ballpickedup",      _("^BG%s^BG has picked up the ball!"), "")
index e0539e4409f0a0ac9bd17a55b282578179df1cb3..b080a10e659fac2d3b7eb91321a649823e256f70 100644 (file)
@@ -1111,6 +1111,7 @@ void ClientConnect(entity this)
 
        CS(this).just_joined = true;  // stop spamming the eventlog with additional lines when the client connects
 
+       LOG_INFO("Wants join set to false");
        CS(this).wants_join = false;
 
        stuffcmd(this, clientstuff, "\n");
@@ -1949,22 +1950,6 @@ void ShowRespawnCountdown(entity this)
        }
 }
 
-entity SpectatorWantsJoin(entity this)
-{
-       if(!teamplay) return NULL;
-
-       FOREACH_CLIENT(IS_SPEC(it) || IS_OBSERVER(it), {
-               if(it == this) continue;
-               if(CS(it).wants_join) {
-                       LOG_INFO("Returning entity");
-                       return it;
-               }
-       });
-
-       LOG_INFO("Returning NULL");
-       return NULL;
-}
-
 .bool team_selected;
 bool ShowTeamSelection(entity this)
 {
@@ -1987,6 +1972,7 @@ void Join(entity this)
        if(to_join)
        {
                Join(to_join);
+               CS(this).wants_join = false;
                this.team_selected = false; // Don't let this player select team
                LOG_INFOF("Forcing joining of queued player %s!", to_join.netname);
        }
@@ -2003,14 +1989,12 @@ void Join(entity this)
        PutClientInServer(this);
 
        if(IS_PLAYER(this))
-       if(teamplay && this.team != -1)
-       {
-       }
+       if(teamplay && this.team != -1 && CS(this).wants_join)
+               //Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(this.team, INFO_JOIN_PLAY_TEAM), this.netname);
+       {}
        else
                Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_JOIN_PLAY, this.netname);
        this.team_selected = false;
-
-       CS(this).wants_join = false;
 }
 
 int GetPlayerLimit()
@@ -2081,6 +2065,7 @@ bool joinAllowed(entity this)
        if (teamplay && lockteams) return false;
        if (MUTATOR_CALLHOOK(ForbidSpawn, this)) return false;
        if (ShowTeamSelection(this)) return false;
+       //if (CS(this).wants_join) return false;
        if (teamplay && !SpectatorWantsJoin(this))
        {
                // TODO : Refactor
index c7c939d74d6e4f3c553f958b611f8008aec2c1a3..ca0d7d8e4e5a447d0c15370a26893a47fe539748 100644 (file)
@@ -234,8 +234,26 @@ bool Player_SetTeamIndex(entity player, int index)
        return true;
 }
 
+entity SpectatorWantsJoin(entity this)
+{
+       // Check if there are spectators waiting to join
+       if(!teamplay) return NULL;
+
+       FOREACH_CLIENT(IS_SPEC(it) || IS_OBSERVER(it), {
+               if(it == this) continue;
+               if(CS(it).wants_join) {
+                       LOG_INFOF("Player is waiting to join: %s", it.netname);
+                       return it;
+               }
+       });
+
+       // No players waiting to join
+       return NULL;
+}
+
 bool SetPlayerTeam(entity player, int team_index, int type)
 {
+       LOG_INFO("SetPlayerTeam");
        int old_team_index = Entity_GetTeamIndex(player);
 
        if (!Player_SetTeamIndex(player, team_index))
@@ -251,7 +269,7 @@ bool SetPlayerTeam(entity player, int team_index, int type)
                if (!IS_BOT_CLIENT(player))
                        TeamBalance_AutoBalanceBots();
 
-               if (team_index != -1)
+               if (team_index != -1 && IS_PLAYER(player))
                        Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(player.team, INFO_JOIN_PLAY_TEAM), player.netname);
        }
 
index d96b7df4b25e9559172db0f4b741cad32886a9ed..c79e84bffaa6ad5beff45c71f2a3923ccdf960e3 100644 (file)
@@ -113,6 +113,8 @@ enum
        TEAM_CHANGE_SPECTATOR = 4 ///< Player is joining spectators. //TODO: Remove?
 };
 
+entity SpectatorWantsJoin(entity this);
+
 /// \brief Sets the team of the player.
 /// \param[in,out] player Player to adjust.
 /// \param[in] team_index Index of the team to set.