]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Improve implementation of autojoin on connection
authorterencehill <piuntn@gmail.com>
Fri, 6 Apr 2018 20:49:45 +0000 (22:49 +0200)
committerterencehill <piuntn@gmail.com>
Fri, 6 Apr 2018 20:49:45 +0000 (22:49 +0200)
qcsrc/server/client.qc
qcsrc/server/client.qh

index 3fd9113bdd18e73adc32d4e7bfdbfc42235af2fe..e0f7b979c2da12a1621e2db236202c6c44cdd952 100644 (file)
@@ -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)) {
index 48d42da0092d2f8cf059d1f2037e8aace3bbc372..75a01c96baf2314eaf7110d90a5fa264a16c9d8e 100644 (file)
@@ -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