]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Turn another array of bools into an int
authorterencehill <piuntn@gmail.com>
Sat, 17 Jun 2017 14:17:27 +0000 (16:17 +0200)
committerterencehill <piuntn@gmail.com>
Sat, 17 Jun 2017 14:17:27 +0000 (16:17 +0200)
qcsrc/server/defs.qh
qcsrc/server/spawnpoints.qc

index 11b915027c8b2deb3029a2370013a86d00ac05fe..ca7430de31eaaa17cfecdec04e6eef1c9ae2907e 100644 (file)
@@ -220,9 +220,9 @@ float TemporaryDB;
 
 .float team_saved;
 
-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_team_spawns_forteam[17]; // 0 = this team has no spawns, 1 = this team has spawns; team 0 is the "no-team"
+bool some_spawn_has_been_used;
+int have_team_spawns; // 0 = no team spawns requested, -1 = team spawns requested but none found, 1 = team spawns requested and found
+int have_team_spawns_forteams; // if Xth bit is 1 then team X has spawns else it has no spawns; team 0 is the "no-team"
 
 // set when showing a kill countdown
 .entity killindicator;
index 3d62c149cf9996c74454ea0c0e27c04c9ad6648a..bdb9cdab787a8c4f19f26ff222930b5368bbbdc8 100644 (file)
@@ -64,7 +64,7 @@ void spawnpoint_use(entity this, entity actor, entity trigger)
        if(have_team_spawns > 0)
        {
                this.team = actor.team;
-               some_spawn_has_been_used = 1;
+               some_spawn_has_been_used = true;
        }
        //LOG_INFO("spawnpoint was used!\n");
 }
@@ -113,7 +113,7 @@ void relocate_spawnpoint(entity this)
     if (have_team_spawns != 0)
         if (this.team)
             have_team_spawns = 1;
-    have_team_spawns_forteam[this.team] = 1;
+    have_team_spawns_forteams |= BIT(this.team);
 
     if (autocvar_r_showbboxes)
     {
@@ -344,11 +344,11 @@ entity SelectSpawnPoint(entity this, bool anypoint)
                teamcheck = -1;
        else if(have_team_spawns > 0)
        {
-               if(have_team_spawns_forteam[this.team] == 0)
+               if(!(have_team_spawns_forteams & BIT(this.team)))
                {
                        // we request a spawn for a team, and we have team
                        // spawns, but that team has no spawns?
-                       if(have_team_spawns_forteam[0])
+                       if(have_team_spawns_forteams & BIT(0))
                                // try noteam spawns
                                teamcheck = 0;
                        else
@@ -358,7 +358,7 @@ entity SelectSpawnPoint(entity this, bool anypoint)
                else
                        teamcheck = this.team; // MUST be team
        }
-       else if(have_team_spawns == 0 && have_team_spawns_forteam[0])
+       else if(have_team_spawns == 0 && (have_team_spawns_forteams & BIT(0)))
                teamcheck = 0; // MUST be noteam
        else
                teamcheck = -1;