]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/client.qc
Automatically join players 1 second after they connect if they tried to join too...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / client.qc
index ce495c34709cb26be503743f0545b1db480e488a..8c744b17ddb7c1e83991bef002ea0b70adcf522a 100644 (file)
@@ -2279,7 +2279,7 @@ void ObserverThink(entity this)
        }
 
        if (this.flags & FL_JUMPRELEASED) {
        }
 
        if (this.flags & FL_JUMPRELEASED) {
-               if (PHYS_INPUT_BUTTON_JUMP(this) && joinAllowed(this)) {
+               if (PHYS_INPUT_BUTTON_JUMP(this) && (joinAllowed(this) || time < CS(this).jointime + MIN_SPEC_TIME)) {
                        this.flags &= ~FL_JUMPRELEASED;
                        this.flags |= FL_SPAWNING;
                } else if(PHYS_INPUT_BUTTON_ATCK(this) && !CS(this).version_mismatch || this.would_spectate) {
                        this.flags &= ~FL_JUMPRELEASED;
                        this.flags |= FL_SPAWNING;
                } else if(PHYS_INPUT_BUTTON_ATCK(this) && !CS(this).version_mismatch || this.would_spectate) {
@@ -2299,6 +2299,8 @@ void ObserverThink(entity this)
                                this.flags &= ~FL_SPAWNING;
                                if(joinAllowed(this))
                                        Join(this);
                                this.flags &= ~FL_SPAWNING;
                                if(joinAllowed(this))
                                        Join(this);
+                               else if(time < CS(this).jointime + MIN_SPEC_TIME)
+                                       CS(this).autojoin_checked = -1;
                                return;
                        }
                }
                                return;
                        }
                }
@@ -2321,7 +2323,7 @@ void SpectatorThink(entity this)
        }
 
        if (this.flags & FL_JUMPRELEASED) {
        }
 
        if (this.flags & FL_JUMPRELEASED) {
-               if (PHYS_INPUT_BUTTON_JUMP(this) && joinAllowed(this)) {
+               if (PHYS_INPUT_BUTTON_JUMP(this) && (joinAllowed(this) || time < CS(this).jointime + MIN_SPEC_TIME)) {
                        this.flags &= ~FL_JUMPRELEASED;
                        this.flags |= FL_SPAWNING;
                } else if(PHYS_INPUT_BUTTON_ATCK(this) || CS(this).impulse == 10 || CS(this).impulse == 15 || CS(this).impulse == 18 || (CS(this).impulse >= 200 && CS(this).impulse <= 209)) {
                        this.flags &= ~FL_JUMPRELEASED;
                        this.flags |= FL_SPAWNING;
                } else if(PHYS_INPUT_BUTTON_ATCK(this) || CS(this).impulse == 10 || CS(this).impulse == 15 || CS(this).impulse == 18 || (CS(this).impulse >= 200 && CS(this).impulse <= 209)) {
@@ -2365,6 +2367,8 @@ void SpectatorThink(entity this)
                                this.flags &= ~FL_SPAWNING;
                                if(joinAllowed(this))
                                        Join(this);
                                this.flags &= ~FL_SPAWNING;
                                if(joinAllowed(this))
                                        Join(this);
+                               else if(time < CS(this).jointime + MIN_SPEC_TIME)
+                                       CS(this).autojoin_checked = -1;
                                return;
                        }
                }
                                return;
                        }
                }
@@ -2569,17 +2573,19 @@ void PlayerPreThink (entity this)
                        IntermissionThink(this);
                return;
        }
                        IntermissionThink(this);
                return;
        }
-       else if (IS_REAL_CLIENT(this) && !CS(this).autojoin_checked && time >= CS(this).jointime + MIN_SPEC_TIME)
+       else if (IS_REAL_CLIENT(this) && CS(this).autojoin_checked <= 0 && time >= CS(this).jointime + MIN_SPEC_TIME)
        {
        {
-               CS(this).autojoin_checked = true;
+               bool early_join_requested = (CS(this).autojoin_checked < 0);
+               CS(this).autojoin_checked = 1;
                // don't do this in ClientConnect
                // many things can go wrong if a client is spawned as player on connection
                // don't do this in ClientConnect
                // many things can go wrong if a client is spawned as player on connection
-               if (MUTATOR_CALLHOOK(AutoJoinOnConnection, this)
+               if (early_join_requested || MUTATOR_CALLHOOK(AutoJoinOnConnection, this)
                        || (!(autocvar_sv_spectate || autocvar_g_campaign || (Player_GetForcedTeamIndex(this) == TEAM_FORCE_SPECTATOR))
                                && (!teamplay || autocvar_g_balance_teams)))
                {
                        campaign_bots_may_start = true;
                        || (!(autocvar_sv_spectate || autocvar_g_campaign || (Player_GetForcedTeamIndex(this) == TEAM_FORCE_SPECTATOR))
                                && (!teamplay || autocvar_g_balance_teams)))
                {
                        campaign_bots_may_start = true;
-                       Join(this);
+                       if(joinAllowed(this))
+                               Join(this);
                        return;
                }
        }
                        return;
                }
        }
@@ -2601,7 +2607,7 @@ void PlayerPreThink (entity this)
                                wep_zoomed += thiswep.wr_zoom(thiswep, this);
                }
                SetZoomState(this, PHYS_INPUT_BUTTON_ZOOM(this) || PHYS_INPUT_BUTTON_ZOOMSCRIPT(this) || wep_zoomed);
                                wep_zoomed += thiswep.wr_zoom(thiswep, this);
                }
                SetZoomState(this, PHYS_INPUT_BUTTON_ZOOM(this) || PHYS_INPUT_BUTTON_ZOOMSCRIPT(this) || wep_zoomed);
-    }
+       }
 
        if (CS(this).teamkill_soundtime && time > CS(this).teamkill_soundtime)
        {
 
        if (CS(this).teamkill_soundtime && time > CS(this).teamkill_soundtime)
        {