From f024db9883580568d61028c5fc721920014c3070 Mon Sep 17 00:00:00 2001 From: z411 Date: Mon, 7 Nov 2022 08:39:06 -0300 Subject: [PATCH] Further changes --- qcsrc/common/notifications/all.inc | 1 + qcsrc/server/client.qc | 27 ++++++--------------------- qcsrc/server/teamplay.qc | 20 +++++++++++++++++++- qcsrc/server/teamplay.qh | 2 ++ 4 files changed, 28 insertions(+), 22 deletions(-) diff --git a/qcsrc/common/notifications/all.inc b/qcsrc/common/notifications/all.inc index 360a3439a..5e9015e5c 100644 --- a/qcsrc/common/notifications/all.inc +++ b/qcsrc/common/notifications/all.inc @@ -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!"), "") diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index e0539e440..b080a10e6 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -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 diff --git a/qcsrc/server/teamplay.qc b/qcsrc/server/teamplay.qc index c7c939d74..ca0d7d8e4 100644 --- a/qcsrc/server/teamplay.qc +++ b/qcsrc/server/teamplay.qc @@ -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); } diff --git a/qcsrc/server/teamplay.qh b/qcsrc/server/teamplay.qh index d96b7df4b..c79e84bff 100644 --- a/qcsrc/server/teamplay.qh +++ b/qcsrc/server/teamplay.qh @@ -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. -- 2.39.2