]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Get notifications working
authorz411 <z411@omaera.org>
Mon, 7 Nov 2022 13:36:07 +0000 (10:36 -0300)
committerz411 <z411@omaera.org>
Mon, 7 Nov 2022 13:36:07 +0000 (10:36 -0300)
qcsrc/server/client.qc
qcsrc/server/teamplay.qc

index b080a10e659fac2d3b7eb91321a649823e256f70..74e13d75346d19c4b2493e2333177e1ef0a2b991 100644 (file)
@@ -1961,6 +1961,7 @@ bool ShowTeamSelection(entity this)
                stuffcmd(this, "_scoreboard_team_selection 1\n");
        return true;
 }
+
 void Join(entity this)
 {
        if (autocvar_g_campaign && !campaign_bots_may_start && !game_stopped && time >= game_starttime)
@@ -1972,9 +1973,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);
        }
 
        if(!this.team_selected)
@@ -1989,12 +1988,17 @@ void Join(entity this)
        PutClientInServer(this);
 
        if(IS_PLAYER(this))
-       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);
-       {}
+       if(teamplay && this.team != -1)
+       {
+               if(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;
+
+       if(to_join)
+               CS(to_join).wants_join = false;
 }
 
 int GetPlayerLimit()
@@ -2065,14 +2069,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
-               LOG_INFOF("Spec %s wants to join. Queueing.", this.netname);
-               CS(this).wants_join = true;
-               return false;
-       }
+       if (CS(this).wants_join) return false;
        return true;
 }
 
index ca0d7d8e4e5a447d0c15370a26893a47fe539748..d5040295abd16c640859cbca21bc672d297fd5fa 100644 (file)
@@ -239,7 +239,8 @@ entity SpectatorWantsJoin(entity this)
        // Check if there are spectators waiting to join
        if(!teamplay) return NULL;
 
-       FOREACH_CLIENT(IS_SPEC(it) || IS_OBSERVER(it), {
+       //FOREACH_CLIENT(IS_SPEC(it) || IS_OBSERVER(it), {
+       FOREACH_CLIENT(IS_REAL_CLIENT(it), {
                if(it == this) continue;
                if(CS(it).wants_join) {
                        LOG_INFOF("Player is waiting to join: %s", it.netname);
@@ -248,6 +249,7 @@ entity SpectatorWantsJoin(entity this)
        });
 
        // No players waiting to join
+       LOG_INFO("No players waiting to join.");
        return NULL;
 }
 
@@ -269,8 +271,16 @@ bool SetPlayerTeam(entity player, int team_index, int type)
                if (!IS_BOT_CLIENT(player))
                        TeamBalance_AutoBalanceBots();
 
-               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);
+               if (team_index != -1)
+               {
+                       if (!SpectatorWantsJoin(player))
+                       {
+                               Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(player.team, INFO_JOIN_WANTS_TEAM), player.netname);
+                               CS(player).wants_join = true; // TODO : Refactor
+                       }
+                       else
+                               Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(player.team, INFO_JOIN_PLAY_TEAM), player.netname);
+               }
        }
 
        if (team_index == -1)