if (CS(this).just_joined)
CS(this).just_joined = false;
+ if (this.wants_join)
+ this.wants_join = 0;
}
int player_getspecies(entity this)
GameLogEcho(strcat(":join:", ftos(this.playerid), ":", ftos(etof(this)), ":", ((IS_REAL_CLIENT(this)) ? GameLog_ProcessIP(this.netaddress) : "bot"), ":", playername(this.netname, this.team, false)));
CS(this).just_joined = true; // stop spamming the eventlog with additional lines when the client connects
+ this.wants_join = 0;
stuffcmd(this, clientstuff, "\n");
stuffcmd(this, "cl_particles_reloadeffects\n"); // TODO do we still need this?
if (player_count == 0)
localcmd("\nsv_hook_lastleave\n");
+
+ if (teamplay && autocvar_g_balance_teams_remove)
+ TeamBalance_RemoveExcessPlayers(NULL);
}
void ChatBubbleThink(entity this)
}
}
-.bool team_selected;
bool ShowTeamSelection(entity this)
{
if (!teamplay || autocvar_g_campaign || autocvar_g_balance_teams || this.team_selected || (CS(this).wasplayer && autocvar_g_changeteam_banned) || Player_HasRealForcedTeam(this))
return false;
+ if (SpectatorWantsJoin(this))
+ return false;
if (frametime) // once per frame is more than enough
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)
TRANSMUTE(Player, this);
+ entity queued_join = SpectatorWantsJoin(this);
+ if(queued_join)
+ this.team_selected = false; // Don't let this player select team
+
if(!this.team_selected)
- if(autocvar_g_campaign || autocvar_g_balance_teams)
+ if(autocvar_g_campaign || autocvar_g_balance_teams || queued_join)
TeamBalance_JoinBestTeam(this);
if(autocvar_g_campaign)
if(IS_PLAYER(this))
if(teamplay && this.team != -1)
{
+ if(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;
+ this.wants_join = 0;
+
+ if(queued_join)
+ Join(queued_join);
}
int GetPlayerLimit()
return free_slots;
}
+bool queuePlayer(entity this)
+{
+ if(IsQueueNeeded(this) && !SpectatorWantsJoin(this))
+ {
+ if(autocvar_g_balance_teams)
+ TeamBalance_JoinBestTeam(this);
+ return true;
+ }
+ return false;
+}
+
bool joinAllowed(entity this)
{
if (CS(this).version_mismatch) return false;
if (teamplay && lockteams) return false;
if (MUTATOR_CALLHOOK(ForbidSpawn, this)) return false;
if (ShowTeamSelection(this)) return false;
+ if (this.wants_join) return false;
+ if (queuePlayer(this)) return false;
return true;
}
{
Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_MOVETOSPEC_IDLING, this.netname, maxidle_time);
PutObserverInServer(this, true, true);
+ if(autocvar_g_balance_teams_remove)
+ TeamBalance_RemoveExcessPlayers(this);
}
else
{