]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Bot AI: fix initial CTF role assignment when a bot is added to the server
authorterencehill <piuntn@gmail.com>
Tue, 29 May 2018 18:38:06 +0000 (20:38 +0200)
committerterencehill <piuntn@gmail.com>
Tue, 29 May 2018 18:38:06 +0000 (20:38 +0200)
qcsrc/server/mutators/mutator/gamemode_ctf.qc

index cb78fe384b0a6c5232eef127a793a2f99fbee22c..6468bacb809a1a1bdf8a42d4396ec954a0d496cd 100644 (file)
@@ -1576,7 +1576,6 @@ void havocbot_ctf_reset_role(entity this)
 {
        float cdefense, cmiddle, coffense;
        entity mf, ef;
-       float c;
 
        if(IS_DEAD(this))
                return;
@@ -1605,11 +1604,12 @@ void havocbot_ctf_reset_role(entity this)
                return;
        }
 
-       // if there is only me on the team switch to offense
-       c = 0;
-       FOREACH_CLIENT(IS_PLAYER(it) && SAME_TEAM(it, this), { ++c; });
+       // if there is no one else on the team switch to offense
+       int count = 0;
+       // don't check if this bot is a player since it isn't true when the bot is added to the server
+       FOREACH_CLIENT(it != this && IS_PLAYER(it) && SAME_TEAM(it, this), { ++count; });
 
-       if(c==1)
+       if (count == 0)
        {
                havocbot_role_ctf_setrole(this, HAVOCBOT_CTF_ROLE_OFFENSE);
                return;