]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
improve team spawn logic
authorRudolf Polzer <divverent@alientrap.org>
Thu, 31 Mar 2011 19:59:05 +0000 (21:59 +0200)
committerRudolf Polzer <divverent@alientrap.org>
Thu, 31 Mar 2011 19:59:05 +0000 (21:59 +0200)
in a non-team match, ignore team spawns if there is at least one non-team spawn

qcsrc/server/cl_client.qc
qcsrc/server/defs.qh
qcsrc/server/miscfunctions.qc

index 1b10b6e254869f29b1482635c27f36fdaf963f9e..a1047ea9d07595dae83fcb3fd49953b5b24062c7 100644 (file)
@@ -132,9 +132,9 @@ vector Spawn_Score(entity spot, entity playerlist, float teamcheck, float anypoi
        prio = 0;
 
        // filter out spots for the wrong team
-       if(teamcheck)
-       if(spot.team != teamcheck)
-               return '-1 0 0';
+       if(teamcheck >= 0)
+               if(spot.team != teamcheck)
+                       return '-1 0 0';
 
        if(race_spawns)
                if(spot.target == "")
@@ -269,7 +269,7 @@ entity Spawn_FilterOutBadSpots(entity firstspot, entity playerlist, float mindis
                                        spotlist = spot;
 
                                /*
-                               if(teamcheck)
+                               if(teamcheck >= 0)
                                if(spot.team != teamcheck)
                                        error("invalid spawn added");
 
@@ -283,7 +283,7 @@ entity Spawn_FilterOutBadSpots(entity firstspot, entity playerlist, float mindis
 
        /*
                entity e;
-               if(teamcheck)
+               if(teamcheck >= 0)
                        for(e = spotlist; e; e = e.chain)
                        {
                                print("seen ", etos(e), "\n");
@@ -325,10 +325,15 @@ entity SelectSpawnPoint (float anypoint)
        if (spot)
                return spot;
 
-       teamcheck = 0;
-
-       if(!anypoint && have_team_spawns > 0)
-               teamcheck = self.team;
+       if(anypoint)
+               teamcheck = -1;
+       else if(have_team_spawns > 0)
+               teamcheck = self.team; // MUST be team
+       else if(have_team_spawns == 0 && have_noteam_spawns)
+               teamcheck = 0; // MUST be noteam
+       else
+               teamcheck = -1;
+               // if we get here, we either require team spawns but have none, or we require non-team spawns and have none; use any spawn then
 
        // get the list of players
        playerlist = findchain(classname, "player");
@@ -368,7 +373,7 @@ entity SelectSpawnPoint (float anypoint)
                print("spot mindistance: ", vtos(spot.spawnpoint_score), "\n");
 
                entity e;
-               if(teamcheck)
+               if(teamcheck >= 0)
                        for(e = firstspot; e; e = e.chain)
                                if(e.team != teamcheck)
                                        error("invalid spawn found");
index ff6658d2959f3b1cdec4dc0852253d16e979f582..d7179fafebb703f9c8b2d38ebd426d25cb2a3014 100644 (file)
@@ -410,6 +410,7 @@ float TemporaryDB;
 
 float some_spawn_has_been_used;
 float have_team_spawns; // 0 = no team spawns requested, -1 = team spawns requested but none found, 1 = team spawns requested and found
+float have_noteam_spawns; // 0 = no no-team spawns, 1 = no-team spawns exist
 
 // set when showing a kill countdown
 .entity killindicator;
index 4cf479fa9fdaf34896db02d29aa555d8ade6a77d..84dd07d94a185f3c065296f49cc3e2af6b79a017 100644 (file)
@@ -236,6 +236,8 @@ void relocate_spawnpoint()
     if (have_team_spawns != 0)
         if (self.team)
             have_team_spawns = 1;
+    if (!self.team)
+        have_noteam_spawns = 1;
 
     if (autocvar_r_showbboxes)
     {