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!"), "")
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");
}
}
-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)
{
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);
}
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()
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
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))
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);
}
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.