From: z411 Date: Mon, 7 Nov 2022 13:36:07 +0000 (-0300) Subject: Get notifications working X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=2b8a7cbf36c40c90c4b94370938ab90c79ba3a5a;p=xonotic%2Fxonotic-data.pk3dir.git Get notifications working --- diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index b080a10e6..74e13d753 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -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; } diff --git a/qcsrc/server/teamplay.qc b/qcsrc/server/teamplay.qc index ca0d7d8e4..d5040295a 100644 --- a/qcsrc/server/teamplay.qc +++ b/qcsrc/server/teamplay.qc @@ -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)