From: terencehill Date: Sat, 3 Sep 2016 18:10:05 +0000 (+0200) Subject: Don't consider the client allowed to spawn while showing the team selection dialog... X-Git-Tag: xonotic-v0.8.2~620^2~4 X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=commitdiff_plain;h=66458c7ed8a69280410c2b7cb395552cd42efac7 Don't consider the client allowed to spawn while showing the team selection dialog; restore the old CA spawn behaviour (the alternative less hackish one was bugged) adapting it to this change so that it now works in a cleaner way (no weird bug while spectating) --- diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 2d1ff86577..d2c6c99183 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -1867,30 +1867,34 @@ void ShowRespawnCountdown(entity this) } .bool team_selected; -void JoinOrShowTeamSelection(entity this) +bool ShowTeamSelection(entity this) { if(!teamplay || autocvar_g_campaign || autocvar_g_balance_teams || this.team_selected || (this.wasplayer && autocvar_g_changeteam_banned) || this.team_forced > 0) - { - TRANSMUTE(Player, this); + return false; + stuffcmd(this, "menu_showteamselect\n"); + return true; +} +void Join(entity this) +{ + TRANSMUTE(Player, this); - SetSpectatee(this, NULL); + SetSpectatee(this, NULL); - if(autocvar_g_campaign || autocvar_g_balance_teams) - JoinBestTeam(this, false, true); + if(!this.team_selected) + if(autocvar_g_campaign || autocvar_g_balance_teams) + JoinBestTeam(this, false, true); - if(autocvar_g_campaign) - campaign_bots_may_start = true; + if(autocvar_g_campaign) + campaign_bots_may_start = true; - Kill_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CPID_PREVENT_JOIN); + Kill_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CPID_PREVENT_JOIN); - PutClientInServer(this); - PlayerScore_Clear(this); + PutClientInServer(this); + if(!this.team_selected) + PlayerScore_Clear(this); - Send_Notification(NOTIF_ALL, NULL, MSG_INFO, ((teamplay && this.team != -1) ? APP_TEAM_ENT(this, INFO_JOIN_PLAY_TEAM) : INFO_JOIN_PLAY), this.netname); - this.team_selected = false; - } - else - stuffcmd(this, "menu_showteamselect\n"); + Send_Notification(NOTIF_ALL, NULL, MSG_INFO, ((teamplay && this.team != -1) ? APP_TEAM_ENT(this, INFO_JOIN_PLAY_TEAM) : INFO_JOIN_PLAY), this.netname); + this.team_selected = false; } /** @@ -2010,6 +2014,7 @@ bool spawnAllowed(entity this) if (this.version_mismatch) return false; if (!nJoinAllowed(this, this)) return false; if (teamplay && lockteams) return false; + if (ShowTeamSelection(this)) return false; if (MUTATOR_CALLHOOK(ForbidSpawn, this)) return false; return true; } @@ -2041,7 +2046,7 @@ void ObserverThink(entity this) if(this.flags & FL_SPAWNING) { this.flags &= ~FL_SPAWNING; - JoinOrShowTeamSelection(this); + Join(this); return; } } @@ -2099,7 +2104,7 @@ void SpectatorThink(entity this) if(this.flags & FL_SPAWNING) { this.flags &= ~FL_SPAWNING; - JoinOrShowTeamSelection(this); + Join(this); return; } } diff --git a/qcsrc/server/command/cmd.qc b/qcsrc/server/command/cmd.qc index bc5d560a3f..7536b526a5 100644 --- a/qcsrc/server/command/cmd.qc +++ b/qcsrc/server/command/cmd.qc @@ -160,7 +160,7 @@ void ClientCommand_mv_getpicture(entity caller, float request, float argc) // i } bool spawnAllowed(entity this); -void JoinOrShowTeamSelection(entity this); +void Join(entity this); void ClientCommand_join(entity caller, float request) { switch (request) @@ -170,7 +170,7 @@ void ClientCommand_join(entity caller, float request) if (!gameover) if (IS_CLIENT(caller) && !IS_PLAYER(caller)) if (spawnAllowed(caller)) - JoinOrShowTeamSelection(caller); + Join(caller); return; // never fall through to usage } diff --git a/qcsrc/server/mutators/mutator/gamemode_ca.qc b/qcsrc/server/mutators/mutator/gamemode_ca.qc index 8dda62f0b2..4707e9fca0 100644 --- a/qcsrc/server/mutators/mutator/gamemode_ca.qc +++ b/qcsrc/server/mutators/mutator/gamemode_ca.qc @@ -170,15 +170,11 @@ MUTATOR_HOOKFUNCTION(ca, ForbidSpawn) { entity player = M_ARGV(0, entity); - if (!allowed_to_spawn) - { - if (player.jointime != time && !player.caplayer) // not when connecting - { - player.caplayer = 0.5; - Send_Notification(NOTIF_ONE_ONLY, player, MSG_INFO, INFO_CA_JOIN_LATE); - } + // spectators / observers that weren't playing can join; they are + // immediately forced to observe in the PutClientInServer hook + // this way they are put in a team and can play in the next round + if (!allowed_to_spawn && player.caplayer) return true; - } return false; }