From: terencehill Date: Fri, 6 Apr 2018 20:49:45 +0000 (+0200) Subject: Improve implementation of autojoin on connection X-Git-Tag: xonotic-v0.8.5~2067^2~2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=c28229c0d08c59c021e6fe31977e3b493581f11e;p=xonotic%2Fxonotic-data.pk3dir.git Improve implementation of autojoin on connection --- diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 3fd9113bd..e0f7b979c 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 48d42da00..75a01c96b 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