]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/teamplay.qc
Fix bots joining red and crashing when red team is unavailable
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / teamplay.qc
index 742b9ef6d57314f07aa88bb40f105611b5b49615..921bf0cef80c8ec64c0b4f8f9d0b4aca3890545e 100644 (file)
@@ -424,8 +424,12 @@ float TeamSmallerEqThanTeam(float ta, float tb, entity e)
 // NOTE: Assumes CheckAllowedTeams has already been called!
 float FindSmallestTeam(entity pl, float ignore_pl)
 {
-       float totalteams, t;
-       totalteams = 0;
+       int totalteams = 0;
+       int t = 1; // initialize with a random team?
+       if(c4 >= 0) t = 4;
+       if(c3 >= 0) t = 3;
+       if(c2 >= 0) t = 2;
+       if(c1 >= 0) t = 1;
 
        // find out what teams are available
        //CheckAllowedTeams();
@@ -459,7 +463,8 @@ float FindSmallestTeam(entity pl, float ignore_pl)
 
        RandomSelection_Init();
 
-       t = 1;
+       if(TeamSmallerEqThanTeam(1, t, pl))
+               t = 1;
        if(TeamSmallerEqThanTeam(2, t, pl))
                t = 2;
        if(TeamSmallerEqThanTeam(3, t, pl))