]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/client.qc
Make bots observers (for one frame) before joining the game and put them in a team...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / client.qc
index cab642e67fd9b0f8e65a3eafedb54800e8cc3927..7bd24369e3154c200dc526599a091b1c227f1cbf 100644 (file)
@@ -540,6 +540,14 @@ void PutPlayerInServer(entity this)
        PlayerState_attach(this);
        accuracy_resend(this);
 
+       if (IS_BOT_CLIENT(this))
+       {
+               if (teamplay && Team_IsValidIndex(this.bot_forced_team))
+                       SetPlayerTeam(this, this.bot_forced_team, TEAM_CHANGE_MANUAL);
+               else
+                       this.bot_forced_team = 0;
+       }
+
        if (this.team < 0)
                TeamBalance_JoinBestTeam(this);
 
@@ -810,9 +818,7 @@ void PutPlayerInServer(entity this)
 /** Called when a client spawns in the server */
 void PutClientInServer(entity this)
 {
-       if (IS_BOT_CLIENT(this)) {
-               TRANSMUTE(Player, this);
-       } else if (IS_REAL_CLIENT(this)) {
+       if (IS_REAL_CLIENT(this)) {
                msg_entity = this;
                WriteByte(MSG_ONE, SVC_SETVIEW);
                WriteEntity(MSG_ONE, this);
@@ -2269,6 +2275,14 @@ void ObserverOrSpectatorThink(entity this)
                }
        }
 
+       if (IS_BOT_CLIENT(this) && !CS(this).autojoin_checked)
+       {
+               CS(this).autojoin_checked = true;
+               TRANSMUTE(Player, this);
+               PutClientInServer(this);
+               return;
+       }
+
        if (this.flags & FL_JUMPRELEASED) {
                if (PHYS_INPUT_BUTTON_JUMP(this) && (joinAllowed(this) || time < CS(this).jointime + MIN_SPEC_TIME)) {
                        this.flags &= ~FL_JUMPRELEASED;