From c28229c0d08c59c021e6fe31977e3b493581f11e Mon Sep 17 00:00:00 2001 From: terencehill Date: Fri, 6 Apr 2018 22:49:45 +0200 Subject: [PATCH] Improve implementation of autojoin on connection --- qcsrc/server/client.qc | 20 +++++++++----------- qcsrc/server/client.qh | 1 + 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 3fd9113bdd..e0f7b979c2 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -2563,7 +2563,7 @@ void PlayerPreThink (entity this) if (IS_REAL_CLIENT(this)) PrintWelcomeMessage(this); - #define MIN_SPEC_TIME 1 + local const int MIN_SPEC_TIME = 1; if (IS_PLAYER(this)) { if (IS_REAL_CLIENT(this) && time < CS(this).jointime + MIN_SPEC_TIME) error("Client can't be spawned as player on connection!"); @@ -2575,20 +2575,18 @@ void PlayerPreThink (entity this) IntermissionThink(this); return; } - else if (IS_REAL_CLIENT(this) && time < CS(this).jointime + MIN_SPEC_TIME + 1) + else if (IS_REAL_CLIENT(this) && !CS(this).autojoin_checked && time >= CS(this).jointime + MIN_SPEC_TIME) { + CS(this).autojoin_checked = true; // don't do this in ClientConnect // many things can go wrong if a client is spawned as player on connection - if (time > CS(this).jointime + MIN_SPEC_TIME) + if (MUTATOR_CALLHOOK(AutoJoinOnConnection, this) + || (!(autocvar_sv_spectate || autocvar_g_campaign || this.team_forced < 0) + && (!teamplay || autocvar_g_balance_teams))) { - if (MUTATOR_CALLHOOK(AutoJoinOnConnection, this) - || (!(autocvar_sv_spectate || autocvar_g_campaign || this.team_forced < 0) - && (!teamplay || autocvar_g_balance_teams))) - { - campaign_bots_may_start = true; - Join(this); - return; - } + campaign_bots_may_start = true; + Join(this); + return; } } else if (IS_OBSERVER(this)) { diff --git a/qcsrc/server/client.qh b/qcsrc/server/client.qh index 48d42da009..75a01c96ba 100644 --- a/qcsrc/server/client.qh +++ b/qcsrc/server/client.qh @@ -114,6 +114,7 @@ CLASS(Client, Object) ATTRIB(Client, cmd_floodtime, float, this.cmd_floodtime); ATTRIB(Client, wasplayer, bool, this.wasplayer); ATTRIB(Client, weaponorder_byimpulse, string, this.weaponorder_byimpulse); + ATTRIB(Client, autojoin_checked, bool, this.wasplayer); // networked cvars -- 2.39.2